Thanks, I re-packaged the TraceCategory into a separate .jar file and stuck
it in lib/ext and this works.

However, I'm not completely sure I understand why the other didn't work.
Before the second deployment the previous is undeployed.  Why does the
TraceCategory instance live beyond this undeployment.  And is there
something specific I can do such that it is destroyed and will not affect a
second deployment?

Perhaps I am looking at this wrong.  Should helper classes not be part of
the deployed jar file?  Is that jar file only for EJBs?  In general, should
helper classes be installed elsewhere and pointed to by a ClassPathExtension
MBean?

thanks,
-mike.

-----Original Message-----
From: Scott M Stark [mailto:[EMAIL PROTECTED]]
Sent: Saturday, May 19, 2001 7:19 PM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] 2nd Deployment Fails


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

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

Reply via email to