I have a web-app (Tomcat 6, log4j 1.2.16), which starts with a listener. Undeploying the application throws the following exception:
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.
How do I get rid of this exception message?
Check this jira bug for your solution: http://java.net/jira/browse/GLASSFISH-16767
Similar resolved issue on stackoverflow here: Undeploying a Grails App from Glassfish gets a Class invariant violation
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?
The way I solved this problem (in glassfish environment) is to avoid declaring the logger as static, e.g.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With