users@glassfish.java.net

Re: Error when bundling log4j - regression?

From: Vetle Roeim <vetler_at_gmail.com>
Date: Mon, 7 Mar 2011 17:19:38 +0100

The error changes when I remove static declarations of Logger
instances, and I got our application to deploy successfully by
removing *all* static declarations.

However, I had to disable functionality to be able to do this, and we
are using 3rd party libraries that we would prefer not to change. For
instance, the error message below shows it originating in ehcache:

[#|2011-03-07T17:17:03.098+0100|SEVERE|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=68;_ThreadName=Thread-1;|log4j:ERROR
log4j called after unloading, see
http://logging.apache.org/log4j/1.2/faq.html#unload.|#]

[#|2011-03-07T17:17:03.103+0100|SEVERE|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=68;_ThreadName=Thread-1;|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.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
        at net.sf.ehcache.util.UpdateChecker.<clinit>(UpdateChecker.java:39)


On Mon, Mar 7, 2011 at 16:33, Vetle Roeim <vetler_at_gmail.com> wrote:
> Hi,
>
> We've encountered a problem when bundling log4j with a Java EE 6
> application (annotated EJBs, CDI, JPA 2 ... all the good stuff!), on
> Glassfish 3.1. Unless we have log4j in the domains/domain1/lib
> directory, we get the following error:
>
> [#|2011-03-07T16:19:29.455+0100|SEVERE|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=90;_ThreadName=Thread-1;|log4j:ERROR
> log4j called after unloading, see
> http://logging.apache.org/log4j/1.2/faq.html#unload.|#]
>
> [#|2011-03-07T16:19:29.455+0100|SEVERE|oracle-glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=90;_ThreadName=Thread-1;|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 no.evote.i18n.ResourceBundleControlDatabase.<clinit>(ResourceBundleControlDatabase.java:17)
>        at sun.misc.Unsafe.ensureClassInitialized(Native Method)
>        at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
>        at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
>        at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
>        at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
>        at java.lang.reflect.Field.get(Field.java:358)
>        at org.glassfish.web.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1835)
>
> However, at the URL specified in the error message, it says first that
> it is an error in Tomcat, and that *Glassfish had a similar problem
> and accepted the patch*.
> Has anyone else encountered this problem?
>
> We would preferrably like to solve it without putting log4j in the lib
> directory for the domain, as this adds administrative overhead (plus,
> we have our own appenders and such, so we would have to put several
> other JAR files there).
>
>
> Regards,
> Vetle
>



-- 
Vetle Roeim