I have an interesting problem with spring build webapp maven. When building inside eclipse, everything is fine, but when building through maven and deploying to the tomcat 8 webapp container, it fails to start with the following error:
Caused by: java.lang.NoClassDefFoundError: FilterConfig
Now I tried all the obvious and well-documented dependency problems (setting up the scope provided for javax.servlet-api and importing JSP-api and making sure that they are from the latest versions, like this is a Java 8 project). I made sure that all compiler plugins have the latest versions:
War Maven Plugin 3.1.0
Maven compiler plugin 3.6.1
but the web server does not start without errors displayed on the output of the maven console. After long head scratches and painstaking comparisons between the (working) eclipse of the build and the mysteriously unsatisfactory MAW equivalent, it was found that in some of the class files generated by the MAW there were texts describing compilation problems. (From the "Open s> Text Editor" option in eclipse, the following was extracted from the .class file: some characters had to be omitted, since they would not copy correctly)
Unresolved compilation problems: The import javax.servlet.Filter cannot be resolved The import javax.servlet.FilterChain cannot be resolved The import javax.servlet.FilterConfig cannot be resolved The import javax.servlet.ServletException cannot be resolved The import javax.servlet.ServletRequest cannot be resolved The import javax.servlet.ServletResponse cannot be resolved The import javax.servlet.http.HttpServletRequest cannot be resolved The import javax.servlet.http.HttpSession cannot be resolved Filter cannot be resolved to a type FilterConfig cannot be resolved to a type ServletException cannot be resolved to a type ServletRequest cannot be resolved to a type ServletResponse cannot be resolved to a type FilterChain cannot be resolved to a type ServletException cannot be resolved to a type HttpServletRequest cannot be resolved to a type HttpServletRequest cannot be resolved to a type HttpSession cannot be resolved to a type
I cannot understand how the maven process succeeds and that no errors are displayed with any of the mvn goals I tried
mvn complier: compile
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building xxxx 2.0.1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ EBPP --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 5 resources [INFO] [INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ EBPP --- [INFO] Nothing to compile - all classes are up to date [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.413 s [INFO] Finished at: 2017-06-28T15:11:45+01:00 [INFO] Final Memory: 9M/213M [INFO] ------------------------------------------------------------------------
above, but with -x showed a lot of debugging output, but did not suggest anything with compilation, in fact it claims that unresolved dependencies are defined in the class file
... [DEBUG] javax.servlet:javax.servlet-api:jar:3.1.0:provided [DEBUG] org.apache.velocity:velocity:jar:1.7:compile [DEBUG] commons-collections:commons-collections:jar:3.2.1:compile [DEBUG] commons-lang:commons-lang:jar:2.4:compile [DEBUG] javax.servlet.jsp:jsp-api:jar:2.2:provided ...
mvn dependency: build-classpath
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building xxxx 2.0.1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.8:build-classpath (default-cli) @ EBPP --- [INFO] Dependencies classpath: C:\Users\xxxxxx\.m2\repository\org\springframework\webflow\spring-webflow\2.4.5.RELEASE\spring-webflow-2.4.5.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\xxxxxx\.m2\repository\opensymphony\ognl\2.6.11\ognl-2.6.11.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\webflow\spring-binding\2.4.5.RELEASE\spring-binding-2.4.5.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\webflow\spring-js\2.4.5.RELEASE\spring-js-2.4.5.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\webflow\spring-js-resources\2.4.5.RELEASE\spring-js-resources-2.4.5.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-beans\4.3.0.RELEASE\spring-beans-4.3.0.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-context\4.3.0.RELEASE\spring-context-4.3.0.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-aop\4.3.0.RELEASE\spring-aop-4.3.0.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-expression\4.3.0.RELEASE\spring-expression-4.3.0.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-web\4.3.0.RELEASE\spring-web-4.3.0.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-webmvc\4.3.0.RELEASE\spring-webmvc-4.3.0.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-core\4.3.9.RELEASE\spring-core-4.3.9.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\com\xxxxxxx\ebpp\JComms\2.0.1\JComms-2.0.1.jar;C:\Users\xxxxxx\.m2\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;C:\Users\xxxxxx\.m2\repository\javax\mail\mail\1.4.7\mail-1.4.7.jar;C:\Users\xxxxxx\.m2\repository\javax\activation\activation\1.1\activation-1.1.jar;C:\Users\xxxxxx\.m2\repository\org\apache\httpcomponents\httpclient\4.5.1\httpclient-4.5.1.jar;C:\Users\xxxxxx\.m2\repository\org\apache\httpcomponents\httpcore\4.4.3\httpcore-4.4.3.jar;C:\Users\xxxxxx\.m2\repository\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;C:\Users\xxxxxx\.m2\repository\commons-httpclient\commons-httpclient\3.1\commons-httpclient-3.1.jar;C:\Users\xxxxxx\.m2\repository\com\xxxxxxx\ebpp\JCore\2.0.1\JCore-2.0.1.jar;C:\Users\xxxxxx\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;C:\Users\xxxxxx\.m2\repository\org\apache\velocity\velocity\1.7\velocity-1.7.jar;C:\Users\xxxxxx\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;C:\Users\xxxxxx\.m2\repository\commons-lang\commons-lang\2.4\commons-lang-2.4.jar;C:\Users\xxxxxx\.m2\repository\javax\servlet\jsp\jsp-api\2.2\jsp-api-2.2.jar;C:\Users\xxxxxx\.m2\repository\junit\junit\3.8.2\junit-3.8.2.jar;C:\Users\xxxxxx\.m2\repository\org\springframework\spring-context-support\4.3.9.RELEASE\spring-context-support-4.3.9.RELEASE.jar;C:\Users\xxxxxx\.m2\repository\com\xxxxxxx\xxxxxxx\440\xxxxxxx-440.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.331 s [INFO] Finished at: 2017-06-28T15:13:05+01:00 [INFO] Final Memory: 13M/213M [INFO] ------------------------------------------------------------------------
mvn validate
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building xxx 2.0.1 [INFO] ------------------------------------------------------------------------ [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.109 s [INFO] Finished at: 2017-06-28T15:15:32+01:00 [INFO] Final Memory: 7M/213M [INFO] ------------------------------------------------------------------------
I'm really at a standstill. I assume maven is using a different compiler from eclipse, but I really ran out of ideas.
Has anyone else come across this before?
Thanks in advance.