我有一个jsf应用程序,可以在tomcat 7的eclipse上正常工作。问题发生在我打包它(使用mvn包..)并将.war文件放在tomcat webapps目录中进行部署。
在tomcat控制台中我得到了:SEVERE: Error listenerStart
Nov 2, 2012 12:38:09 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/jsf_prime_ldap] startup failed due to previous errors
Nov 2, 2012 12:38:09 AM org.apache.catalina.loader.WebappClassLoader checkThread
LocalMapForLeaks
SEVERE: The web application [/jsf_prime_ldap] created a ThreadLocal with key of
type [com.sun.faces.config.ConfigureListener$1] (value [com.sun.faces.config.Con
figureListener$1@6972f1]) and a value of type [com.sun.faces.config.ConfigureLis
tener.ServletContextAdapter] (value [com.sun.faces.config.ConfigureListener$Serv
letContextAdapter@18fee4f]) but failed to remove it when the web application was
stopped. Threads are going to be renewed over time to try and avoid a probable
memory leak.
有关此问题的更多详细信息,在localhost的tomcat日志文件中我有:
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.IllegalAccessError: tried to access class com.sun.faces.context.ApplicationMap from class com.sun.faces.config.InitFacesContext$ServletContextAdapter
at com.sun.faces.config.InitFacesContext$ServletContextAdapter.getApplicationMap(InitFacesContext.java:331)
at javax.faces.FactoryFinder$FactoryManagerCacheKey.<init>(FactoryFinder.java:850)
at javax.faces.FactoryFinder$FactoryManagerCache.getApplicationFactoryManager(FactoryFinder.java:719)
at javax.faces.FactoryFinder$FactoryManagerCache.access$100(FactoryFinder.java:691)
at javax.faces.FactoryFinder.setFactory(FactoryFinder.java:373)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:666)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:417)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:348)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Nov 2, 2012 12:38:09 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.IllegalAccessError: com/sun/faces/context/ApplicationMap
at com.sun.faces.config.InitFacesContext$ServletContextAdapter.getApplicationMap(InitFacesContext.java:331)
at javax.faces.FactoryFinder$FactoryManagerCacheKey.<init>(FactoryFinder.java:850)
at javax.faces.FactoryFinder$FactoryManagerCache.removeApplicationFactoryManager(FactoryFinder.java:810)
at javax.faces.FactoryFinder.releaseFactories(FactoryFinder.java:395)
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:378)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
在tomcat lib目录中我添加了这些jar: 公地的BeanUtils-1.8.3 / 公地集合-3.2.1 / 公地消化器-1.5 / 共享记录-1.1.1 / EL-IMPL-2.2 / JSF的API-2.1.11 / JSF的IMPL-2.1.11 / JSP的API-2.1 / JSTL-1.2 / primefaces-3.4.1
应用程序的pom文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jsfprimeldap</groupId>
<artifactId>jsf_prime_ldap</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jsf_prime_ldap Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<!-- PrimeFaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.4.1</version>
</dependency>
<!-- JSF 2 -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<!-- EL -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.1_02</version>
</dependency>
<!-- Tomcat 6 need this <dependency> <groupId>com.sun.el</groupId> <artifactId>el-ri</artifactId>
<version>1.0</version> </dependency> -->
</dependencies>
<build>
<finalName>jsf_prime_ldap</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
和我的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>jsf_prime_ldap</display-name>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
我在谷歌没有发现任何类似的问题..我希望在这里找到解决这个问题的方法。 谢谢你的帮助
答案 0 :(得分:1)
在tomcat lib目录中的我添加了这些jar:commons-beanutils-1.8.3 / commons-collections-3.2.1 / commons-digester-1.5 / commons-logging-1.1.1 / el-impl -2.2 / jsf-api-2.1.11 / jsf-impl-2.1.11 / jsp-api-2.1 / jstl-1.2 / primefaces-3.4.1
撤消此步骤。如果您不确定,请完全重新安装Tomcat。除非你真正明白自己在做什么,否则不要碰它。这是整个问题的原因。类路径已成为一个混乱,重复的JAR /类相互冲突。
特定于Webapp的JAR不属于那里。它们属于EL和JSP JAR的/WEB-INF/lib
,期望; Tomcat已经成为JSP / Servlet / EL容器已经自己的实现。您不应该将不同容器make / version的JSP / Servlet / EL库放在类路径中。
从技术上讲,至少JSF JAR,JSTL JAR和PrimeFaces JAR都应该在/WEB-INF/lib
。但是,当您使用Maven时,它应该已经注意到了这一点。你不需要做任何事情。所以你需要做的就是从非法的JAR /类中释放Tomcat。