I`m trying to run a simple application with spring java based configuration on jboss, but no success. This application works fine both on jetty and tomcat. The jboss log loo
Well, for someone else who is facing this problem, it just works fine on the new Wildfly. If you don't have any specific container to run your application, you can choose between jboss 7 and wildfly AND wants to run spring java config, try it out on wildfly!
As per the answers provided by Michael R and István Pató, the servlet mapping in JBoss must be "/*", not "/". However, the other solutions cause @Component annotated objects to be instantiated twice. The following solves the double initialization by first calling super.onStartup
and then adding another mapping for the dispatcher servlet:
public class WebApplicationInitializerImpl implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) throws ServletException {
super.onStartup(container);
Dynamic registration = (Dynamic) container.getServletRegistration(EmbeddedWebApplicationContext.DISPATCHER_SERVLET_NAME);
registration.setLoadOnStartup(1);
registration.addMapping("/*");
}
}