'Jars in Tomcat/lib not recognized at runtime
In preparation for updating my JDK, I would like to remove the servlet-api
, jsp-api
and el-api
jars from the JAVA_HOME/jre/lib/ext
directory and instead add them to the classpath as is recommended.
I attempt to do this by adding these dependencies with the provided scope.
However, when I deploy my web application (locally), I still get a ClassNotFoundException
, which I think is caused by the 3 missing jars (when I include them in the old jdk location, this exception disappears).
java.lang.ClassNotFoundException: javax.servlet.jsp.tagext.BodyTagSupport
I double checked to make sure that the j2ee classpath is well defined for the project. From my understanding, the application should have access to the 3 jars from my server container (Tomcat) at runtime. Indeed, it seems that this classpath was well defined:
j2ee.platform.classpath
j2ee.server.home
are both defined in my project properties file.
Also, as far as I know I'm not including any of these jars in WEB-INF/lib
so I don't think that's what's causing the issue either. I do define the jars as dependencies but I give them the provided
scope, with versions for each jar as dictated by this chart: https://tomcat.apache.org/whichversion.html (for Tomcat version 8.0.43).
I'm building the application with ant
on Netbeans.
Are there any other suggestions for why these jar files are not recognized at runtime?
Solution 1:[1]
When I had started the project, I clumsily placed some dependency jars in JAVA-HOME/jre/lib/ext
.
Removing these jars solved the issue. They had dependencies bundled with them that included jsp-api.jar
or servlet-api.jar
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | theyuv |