为什么 Tomcat 在取消部署期间会抛出“java.lang.IllegalStateException: Class invariant conflict”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6564553/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does Tomcat throw 'java.lang.IllegalStateException: Class invariant violation' during undeployment?
提问by mkuff
I have a web-app (Tomcat 6, log4j 1.2.16), which starts with a listener. Undeploying the application throws the following exception:
我有一个 web 应用程序(Tomcat 6,log4j 1.2.16),它从一个监听器开始。取消部署应用程序会引发以下异常:
INFO (HqListener.java:28) - HqListener exited!
log4j:ERROR log4j called after unloading, see http://logging.apache.org/log4j/1.2/faq.html#unload.
java.lang.IllegalStateException: Class invariant violation
at org.apache.log4j.LogManager.getLoggerRepository(LogManager.java:199)
at org.apache.log4j.LogManager.getLogger(LogManager.java:228)
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at com.mchange.v2.log.log4j.Log4jMLog.getMLogger(Log4jMLog.java:51)
at com.mchange.v2.log.MLog.getLogger(MLog.java:145)
at com.mchange.v2.sql.SqlUtils.<clinit>(SqlUtils.java:37)
at com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:290)
at com.mchange.v2.c3p0.DataSources.pooledDataSource(DataSources.java:316)
at org.hibernate.connection.C3P0ConnectionProvider.configure(C3P0ConnectionProvider.java:181)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143)
at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:51)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:90)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at net.hq.util.Db.init(Db.java:15)
at net.hq.process.ConnectionGateway.run(ConnectionGateway.java:89)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "HQ Gateway Thread" java.lang.NullPointerException
at net.hq.process.ConnectionGateway.run(ConnectionGateway.java:129)
at java.lang.Thread.run(Thread.java:662)
Jul 3, 2011 3:03:53 AM org.apache.catalina.core.StandardContext stop
HqListener.java
is my listener and it reports a successful shutdown.
HqListener.java
是我的听众,它报告成功关闭。
How do I get rid of this exception message?
如何摆脱此异常消息?
采纳答案by JoshDM
Check this jira bug for your solution: http://java.net/jira/browse/GLASSFISH-16767
检查此 jira 错误以获取解决方案:http: //java.net/jira/browse/GLASSFISH-16767
Similar resolved issue on stackoverflow here: Undeploying a Grails App from Glassfish gets a Class invariant violation
stackoverflow 上的类似问题已解决:Undeploying a Grails App from Glassfish gets a Class invariant conflict
Setting the property
设置属性
<jvm-options>
-Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false
</jvm-options>
in the domain.xml file in Glassfish resolves the issue; not certain where to set this in Tomcat, perhaps server.xml?
在 Glassfish 的 domain.xml 文件中解决了这个问题;不确定在 Tomcat 中的何处设置它,也许是 server.xml?
回答by user2344491
The way I solved this problem (in glassfish environment) is to avoid declaring the logger as static, e.g.
我解决这个问题的方法(在 glassfish 环境中)是避免将记录器声明为静态,例如
private static final Logger logger = LoggerFactory.getLogger(BootStrapListener.class);
If you remove static
from the above declaration, you will no longer get the above error.
如果您static
从上述声明中删除,您将不再出现上述错误。