Geomajas Community Documentation
To assure the spring dependency injection is used, you should obtain beans through either injection (possibly autowiring) or the application context. When you directly instantiate classes which require spring dependency injection, you are likely to encounter NullPointerException or other problems.
@Component public class MyClass { @Autowired private ApplicationContainer applicationContainer; public void myMethod() { Command command = applicationContext.getBean("controller.general.LogCommand", Command.class); .....
We recommend using the annotations when possible.
You cannot assume that (auto) wired services are initialized while the application context is being built. If you need to do some initialization of the bean state, this should be removed from the setters which are called while building the context, and moved to a post construct method.
@PostConstruct private postConstruct() { // dome some stuff here }