Bugs item #951248, was opened at 2004-05-10 13:38
Message generated for change (Comment added) made by ejort
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=951248&group_id=22866

Category: JBossMX
Group: v3.2
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Fabiano C. de Oliveira (fabcipriano)
>Assigned to: Adrian Brock (ejort)
Summary: UnifiedClassLoader problem with Class.forName()

Initial Comment:
Running in a :
Windows NT sp 6a
Sun JDK 1.4.2_04
JBoss 3.2.3

We have done a connector package it in a rar file, and
a EJB jar file that use this connector package it in a
jar file.

When JBoss start for the first time We deploy the RAR
and after this the JAR EJB. At this moment all is ok.
The problem happen when we redeploy the RAR and the EJB
bean after this. So we receive a ClassCastException
when we try use the getConection() in the EJB code.

After search for the problem in the end we have
discover that when the connector use Class.forName() to
instance our Connection class it use a previous old
UnifiedClassLoader, because this we receive a
ClassCastException. But when we use a
Thread.currentThread().getContextClassLoader().loadClass()
to load the Connector class all works fine after
redeploy !!!

To simulate this problem we have attached two files. A
foo.jar that have a simple example.Foo class and a
BeanShell that load the example.Foo using
Class.forName() each 10 secunds. To reproduce the problem:
1. deploy foo.jar
2. deploy the beanshell
3. undeploy the foo.jar
4. wait 15 secunds
5. we receive a message log from the bean shell saying
that it have found the Foo class !!! But the correct
should be a ClassNotFound Exception !!!

Is ClassLoader.loadClass is used all works fine. This
is a JBoss or Java VM bug ?

----------------------------------------------------------------------

>Comment By: Adrian Brock (ejort)
Date: 2004-05-10 14:43

Message:
Logged In: YES 
user_id=9459

If you searched the forums or the mailing list, 
you would know this is an FAQ.

1) It is a bug in Sun's JVM, it does some horrible
caching inside Class.forName which breaks hot
deployment. 
It was introduced in java1.4 (java 1.3 does not
have this problem).
If you can get them to fix it - it would also allow us
to hot deploy jdbc drivers.
2) Class.forName() is inappropriate in anything
but a toy java application.
You should use:

Thread.currentThread().getContextClassLoader().loadClass()

IMHO Class.forName() should be a 
deprecated part of the j2se api.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=951248&group_id=22866


-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to