You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Mahler Thomas <th...@itellium.com> on 2003/11/13 09:54:35 UTC

FW: ojb and orion


> -----Original Message-----
> From: Joshua Swartz [mailto:joshua.swartz@edlending.com]
> Sent: Wednesday, November 12, 2003 11:27 PM
> To: thma@apache.org
> Subject: ojb and orion
> 
> 
> Hello,
> 
> I'm writing to let you know about a problem that OJB users 
> are seeing and how to fix it. 
> 
> I am currently deploying two separate .ear files within Orion 
(http://www.orionserver.com). Each has OJB's jars and all jar dependencies.
The problem is that once one application is loaded, the other will fail to
load. This is directly caused by Orion's management of classloaders.
Specifically, the problem I was seeing was the second application would try
to load classes using the first application's classloader. Because I don't
have Orion's source code, I can't step through and give you a more detailed
explanation of the problem other than it is definitely a ClassLoader
problem.

You can fix this (I did) by making the following change to
org.apache.ojb.broker.util.ClassHelper:

The getClass(String,boolean) method does the following:
- return Class.forName(className, initialize,
Thread.currentThread().getContextClassLoader());

In my situation in Orion, this works fine with only the one application.
When I try to load the second application, that method returns the Class
requested from the -wrong- classloader (the classloader used for the first
application). 

To correct this, all you have to do is:
- return Class.forName(className);

Per the Javadocs for java.lang.Class, the forName(String) method will
initialize a class if it's not already been initialized, so the boolean
argument may be omitted for our intents and purposes. 

Here is a thread from the OJB mailing list related:
http://www.mail-archive.com/ojb-user@db.apache.org/msg04100.html

Here is a description of classloaders in Orion:
http://kb.atlassian.com/content/atlassian/howto/classloaders.jsp

Thank you for your time.

-Joshua Swartz

PS: OJB is the best O/R API out there!
PPS: I am interested in helping the project if you'd like any help

---
Joshua Swartz
Education Lending Group, Inc.
Information Systems
513-723-9222 x.215
 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Re: FW: ojb and orion

Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi,
...
>>
>>I am currently deploying two separate .ear files within Orion 
> 
> (http://www.orionserver.com). Each has OJB's jars and all jar dependencies.
> The problem is that once one application is loaded, the other will fail to
> load. This is directly caused by Orion's management of classloaders.
> Specifically, the problem I was seeing was the second application would try
> to load classes using the first application's classloader. Because I don't
> have Orion's source code, I can't step through and give you a more detailed
> explanation of the problem other than it is definitely a ClassLoader
> problem.
> 
> You can fix this (I did) by making the following change to
> org.apache.ojb.broker.util.ClassHelper:
> 
> The getClass(String,boolean) method does the following:
> - return Class.forName(className, initialize,
> Thread.currentThread().getContextClassLoader());
> 
> In my situation in Orion, this works fine with only the one application.
> When I try to load the second application, that method returns the Class
> requested from the -wrong- classloader (the classloader used for the first
> application). 
> 
> To correct this, all you have to do is:
> - return Class.forName(className);
> 
hmm, I though calling
Thread.currentThread().getContextClassLoader()
to get the context ClassLoader is j2ee conform?

Using
Class.forName(className);
often only returns the system ClassLoader and cause
many depolyment problems in other appServer (ok, if
the "container" does not set the context ClassLoader
the system ClassLoader will be returned too).

Thus use of
Class.forName(className);
is not an option.

Maybe we need to do several variants. First use
Class.forName(className, initialize,
Thread.currentThread().getContextClassLoader());
catch ClassNotFoundException and then do ...? What?

regards,
Armin

> Per the Javadocs for java.lang.Class, the forName(String) method will
> initialize a class if it's not already been initialized, so the boolean
> argument may be omitted for our intents and purposes. 
> 
> Here is a thread from the OJB mailing list related:
> http://www.mail-archive.com/ojb-user@db.apache.org/msg04100.html
> 
> Here is a description of classloaders in Orion:
> http://kb.atlassian.com/content/atlassian/howto/classloaders.jsp
> 
> Thank you for your time.
> 
> -Joshua Swartz
> 
> PS: OJB is the best O/R API out there!
> PPS: I am interested in helping the project if you'd like any help
> 
> ---
> Joshua Swartz
> Education Lending Group, Inc.
> Information Systems
> 513-723-9222 x.215
>  
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org