简体   繁体   中英

Run web app in local tomcat fails with LinkageException

When deploying a web app to a local tomcat (in eclipse), the startup failes with this error:

SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener

java.lang.LinkageError: loader constraint violation: when resolving interface method "javax.servlet.jsp.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)

the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, com/sun/faces/config/ConfigureListener, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, javax/servlet/jsp/JspApplicationContext, have different Class objects for the type p.JspApplicationContext.addELResolver(Ljavax/el/ELResolver;)

What is going on here? I have already read that it might have something to do with having servlet jars in the WEB-INF/lib, but that doesn't seem to be the matter here:

WEB-INF / lib JAR

There is no "javax.*" jar in there, so why does this fail for a class in that package?

Remove the servlet-api from you application. This should never be in a webapp distributiuon.

Tomcat (or any container) must provide these classes from its own classpath so that multiple instances of the classes are not classloaded.

If you are using maven this needs to be a provided dependency.

The problem is caused due to the bitness. Check which bit of OS you are using and install jre for that bit. Because tomcat is a java application and it has no bitness. that means it can run on both 64 as well as 32 bit.

It is possible to have both 64 and 32 bit versions of Java installed. If Tomcat 7 installer finds Java 7 32 bit installed (only), then it will install tomcat 7 into the Program files (x86) directory. But the Tomcat 7 installer will pick the 64 bit version Java, and install itself into the Program Files folder.

But you can't assume that Tomcat 7 is using 64 bit Java in this case, because the user could have added 64 bit Java after installing tomcat 7, and tomcat 7 doesn't know to change its 'bitness' from 32 to 64 when this happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM