You can't deploy the custom catgory and factory in the
same jar as the ejb-jar because each deployment results
in a new type of TraceCategory. In Java the identity of
a class is determined by both the class name and its
ClassLoader. The first time you deploy it works and the
log4j Category class saves away the TraceCategory
instance with a category name of MyMDB.class.getName()
in the Hierarchy instance hashtable. On subsequent deployments
a new instance is not created because a category with
the name MyMDB.class.getName() already exists but its
type != the TraceCategory in the newly loaded ejb-jar
because different ClassLoaders were used.

You have to put your log4j customizations in the JBoss
lib/ext directory or some other path added via the
ClassPathExtension MBean.


Michael Hustler wrote:

> I am using log4j as the trace mechanisim for all of my beans.  I have
> extended log4j slightly to add new categories.  The typical static
> definition inside each bean class is:
>       static TraceCategory trace =
>               (TraceCategory) TraceCategory.getInstance( MyMDB.class );
> 
> MDB or Entity Bean the problem is the same.
> 
> The first time I deploy everything works great.
> 
> If I deploy a second time (while the server is still running) I get a
> ClassCastException:
>    ERROR 2001-05-18 08:55:28,952 [Auto deploy]
> java.lang.ExceptionInInitializerError: java.lang.ClassCastException
> 
> This is due to the static initializer shown above.  I have tried moving the
> initialization to the constructor instead with no success.  The
> getInstance() method above looks like this:
> 
>       public static Category getInstance( String name )
>       { 
>               return Category.getInstance( name, factory );
>       }
> 
> I have a single JAR file that I deploy.  It contains both MyMDB class and
> the TraceCategory class.
> 
> Your help is greately appreciated!!
> 
> -mike
> 


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to