|
Re: How to exclude Groovy plugin jars from Tomcat classpath [message #1219227 is a reply to message #1210470] |
Mon, 02 December 2013 18:27 |
Eclipse User |
|
|
|
On 11/25/2013 8:48 PM, steve B wrote:
> I have a Spring MVC project that uses Maven imported into Eclipse Kepler
> SR1 JEE and deployed to Tomcat 7 within Eclipse. Everything was fine
> until I recently added elasticsearch as a dependency to the Maven pom
> file and now when I start Tomcat I get an exception
> java.lang.ClassCastException:
> org.springframework.web.servlet.DispatcherServlet cannot be cast to
> javax.servlet.Servlet
>
> Launching the server in verbose mode, I see that its because the servlet
> API is now being loaded from 2 places:
> the Tomcat installation folder where it normally comes from
> Loaded javax.servlet.Servlet from
> file:/C:/ProgramFiles/apache-tomcat-7.0.33/lib/servlet-api.jar
>
> but also from the Groovy plugin I have installed
> Loaded javax.servlet.Servlet from
> file:/C:/ProgramFiles/eclipse/plugins/org.codehaus.groovy_1.8.6.xx-20130703-1600-e43-RELEASE/lib/servlet-api-2.4.jar
>
>
> I can't figure out why this is happening. If I rename the servlet jar
> file in the plugin's lib folder (i.e. change the extension from .jar to
> something else so that its not recognized), Tomcat starts up without an
> exception but that's a hack and so I'd like to know what the cause is
> and if I'm missing some WTP configuration to exclude plugin library jars
> from the Tomcat classpath.
>
> Thanks.
Try using a later version of Groovy, that supports the servlet API that
matches your version of Tomcat.
The latest version of Groovy is 2.2.1 - at least 5 or 6 releases beyond
what you have.
Otherwise, you'll have to rename the jar to avoid the collision.
|
|
|
|
|
|
|
|
Re: How to exclude Groovy plugin jars from Tomcat classpath [message #1220439 is a reply to message #1220138] |
Wed, 11 December 2013 17:51 |
Larry Isaacs Messages: 1354 Registered: July 2009 |
Senior Member |
|
|
On 12/9/2013 11:34 PM, steve B wrote:
> Downloaded the latest Tomcat and created a new runtime and server config
> in WTP but I got the LinkageError for "javax/servlet/ServletResponse".
>
> It seems that Maven/m2e is somehow involved in this because I don't get
> the error if I remove the elasticsearch dependency from the pom, this
> started happening only after adding that dependency. Looking at the
> dependency hierarchy when I view the pom in Eclipse, elasticsearch
> doesn't have a dependency on anything other than Lucene so its unclear
> why it has an effect on the server classpath.
>
> Thanks,
> Steve
If you look at the published webapp under
"<workspace>/.metadata/.plugins/org.eclipse.wst.server.core/tmp?/wtpwebapps",
do you see "servlet-api" jar(s) included in its "WEB-INF/lib"?
While it is technically not correct to include a servlet-api jar in
WEB-INF/lib of a webapp, Tomcat tries to help out by ignoring the jar.
If this is occurring, you would see an INFO message in the console log
like the following:
INFO: validateJarFile(<path to jar>) - jar not loaded. See Servlet Spec
2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Are you seeing this?
Cheers,
Larry
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04158 seconds