NoClassDefFoundError when trying to reference external jar files
I have some 3rd party jar files that I want to reference in my tomcat web application. I added this line to catalina.properties:
shared.loader=/home/ollie/dev/java/googleapi_samples/gdata/java/lib/*.jar
but I'm still getting this error:
org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/google/gdata/u开发者_如何学Pythontil/ServiceException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
I verified that the com.google.gdata.util.ServiceException is in the gdata-core-1.0.jar file which is in the directory:
/home/ollie/dev/java/googleapi_samples/gdata/java/lib
I did bounce tomcat after I modified catalina.properties.
Update 1: I tried copying the gdata-core-1.0.jar file into /var/lib/tomcat6/webapp/examples/WEB-INF/lib as a test but that didn't fix the problem either.
Update 2: It actually does work when I copy the jar file directly into the WEB-INF/lib directory. There was a permissions issue that I had to resolve. But it's still not working when I use the shared.loader setting. I reconfirmed that the path is correct.
I'm not sure about this one, but there are two potential causes:
There's a file permission issue in path as specified in
shared.loader
, probably the same as you had when fiddling with/WEB-INF/lib
.You aren't editing the
catalina.properties
file of the Tomcat instance you think you're using. For example, if you're running Tomcat from inside Eclipse, you need to ensure that you've configured Eclipse to take over Tomcat rather than using workspace metadata (where Eclispe actually runs based on a copy of Tomcat conf files). To do this, undeploy/remove all projects, doubleclick Tomcat entry and select Use Tomcat installation in Server locations section. Then the config files in Tomcat's own/conf
folder will be used. Otherwise you need to edit it inServers
project of Eclipse workspace.
Can you try prefixing the path with file://
?
shared.loader=file:///home/ollie/dev/java/googleapi_samples/gdata/java/lib/*.jar
精彩评论