19.3 Common Problems

The following section covers common problems folks stumble upon when using Micronaut.

Dependency injection is not working

The most common reason that Dependency Injection fails to work is when you either don’t have the appropriate annotation processor configured or your IDE is incorrectly configured. See the section on Language Support for how to get setup in your language.

A NoSuchMethodError occurs loading beans (Groovy)

Groovy by default imports the groovy.lang package which includes a class called @Singleton that is an AST transformation that makes your class a singleton (adding a private constructor and static retrieval method). This annotation is easily confused with the javax.inject.Singleton annotation used to define singleton beans in Micronaut. Make sure you are using the correct annotation in your Groovy classes.

It is taking much longer to start my application than it should (*nix OS)

This is likely due to a bug that has to do with executions of java.net.InetAddress.getLocalHost() causing a long delay. The solution is to edit your /etc/hosts file to add an entry that contains your host name. To find your host name, simply enter hostname in the terminal and the value will be output. Then edit your /etc/hosts file to add or change entries like the example below, replacing <hostname> with your host name.

  1. 127.0.0.1 localhost <hostname>
  2. ::1 localhost <hostname>

To learn more about this issue, see this stackoverflow answer