I’ve encountered a rather tricky bug while injecting a dependency in a Spring Boot application:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Error creating bean with name 'be.solidsyntax.ConsumingService':
Injection of resourcedependencies failed;
nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'dependency' is expected to be of type 'be.solidsyntax.Dependency'
but was actually of type 'com.sun.proxy.$Proxy121'
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor
.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:391)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener
.injectDependencies(DependencyInjectionTestExecutionListener.java:119)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener
.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure
.SpringBootDependencyInjectionTestExecutionListener
.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44)

In most cases this exception is caused by injecting a bean which was enhanced by a Spring aspect into a field referencing an implementation instead on an interface. This was not the case in my setup.

Read more »

While playing around with some new frameworks I’ve tried to connect my Spring Boot application to a MongoDB Atlas replicaset.
In order to do so the MongoDB Reactive Streams Java Driver needs to connect using SSL. This didn’t seem to work out of the box as I’ve got the following exception:

1
2
3
4
5
6
7
8
9
10
11
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'reactiveStreamsMongoClient'
defined in class path resource
[org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.class]:
Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [com.mongodb.reactivestreams.client.MongoClient]:
Factory method 'reactiveStreamsMongoClient' threw exception;
nested exception is java.lang.UnsupportedOperationException:
No SSL support in java.nio.channels.AsynchronousSocketChannel.
For SSL support use com.mongodb.connection.netty.NettyStreamFactoryFactory

According to the documentation the “streamType=netty” option needs to be added to the connection URL. This however dit not make the error go away.
I’ve managed to fix the problem by setting the streamFactoryFactory to Netty using a MongoClientSettingsBuilderCustomizer.

Using Kotlin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@SpringBootApplication
class Application {
val eventLoopGroup = NioEventLoopGroup()
@Bean
fun mongoSettingsNettyConnectionFactoy() = MongoClientSettingsBuilderCustomizer {
it.sslSettings(SslSettings.builder()
.enabled(true)
.invalidHostNameAllowed(true)
.build())
.streamFactoryFactory(NettyStreamFactoryFactory.builder()
.eventLoopGroup(eventLoopGroup).build())
}
@PreDestroy
fun shutDownEventLoopGroup() {
eventLoopGroup.shutdownGracefully()
}
}
fun main(args: Array<String>) {
runApplication<Application>(*args)
}

Using Java:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@SpringBootApplication
public class Application {
private NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
public static void main(String[] args) {
SpringApplication.run(SpringReactiveExampleApplication.class, args);
}
@Bean
public MongoClientSettingsBuilderCustomizer sslCustomizer() {
return clientSettingsBuilder -> clientSettingsBuilder
.sslSettings(SslSettings.builder()
.enabled(true)
.invalidHostNameAllowed(true)
.build())
.streamFactoryFactory(NettyStreamFactoryFactory.builder()
.eventLoopGroup(eventLoopGroup).build());
}
@PreDestroy
public void shutDownEventLoopGroup() {
eventLoopGroup.shutdownGracefully();
}
}

I’ve been reading up on how to use CSS Grid layout. Which reminded me of how a lot of games in the past used a grid based playing field (e.g. Bomberman,Boulder Dash,…).
So I’ve decided to get some practice an recreate a basic Snake game using JavaScript and Css Grid layout.

The code is written in vanilla JavaScript and CSS. No external libraries or Pre-processors where used.

The source is, as always, available on GitHub.

I’ve started working on a front-end project using Angular in combination with the Angular-CLI. By default Angular-CLI scaffolds a project configured to use TypeScript and the (optional) scss-sass css preprocessor.

In order to get a better grip on both technologies I’ve followed a scss and TypeScript cours on Udemy. For reference all examples and snippets have been added to my GitHub account.

Feel free to have a look:

A few weeks ago I gave a technical talk about the new reactive programming capabilities of the upcoming Spring Boot 2.0 release.

The talk discusses the need for reactive programming and the current landscape of implementations. You can view the slides here.

I’ve created a sample application to accompany the talk. It contains a web application build on Spring Boot 2.0, the MongoDB Reactive Streams Java Driver and Oboe.js.

The source is available on GitHub.