I have a Maven project with different modules like this:
- MyProject
- testlib
- common
- client
- commonserver
- webserver
I can execute webserver inside Eclipse’s tomcat without problem, I can compile it with Maven without problems but when I try to mvn tomcat:run webserver module, it complains it does not find a class defined in common:
SEVERE: Context initialization failed
java.lang.NoClassDefFoundError: com/myproject/core/MyException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getDeclaredConstructors(Class.java:1853)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:229)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:962)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:935)
I have dependencies set in the pom (and it compiles so I don’t know what’s going on).
Thanks in advance.
The problem was I was running from parent folder like this
If I do
then it works