[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: Plug-in classpath problems with hibernate

I have been playing with J2EE server and I had the simmilar class laoding problems. I have my J2EE/JMS API wrapped in a separate plugin and my application in another plugin.

I was having a ClassNotFoundException while looking up JMS connection and topics on JNDI.

I solved the problem my setting the context class laoder of the current thread to the classloader of the plugin wrapping J2EE/JMS API.

ClassLoader newloader = YourPlugin.getDefault().getClass().getClassLoader();

ClassLoader oldLoader  = Thread.getContextClassLoader();

Thread.currentThread().setContextClassLoader(newLoader);
//Do your stuff here

Thread.currentThread().setContextClassLoader(oldLoader);

It solved my problem of looking up Objects on JNDI.

Regards

Raj
Tran Khiet wrote:

Be assured, I am in the situation as you do. The problem seems to be
generalized on libraries using manipulating java beans at runtime: almost
all frameworks such as hibernate or spring. The answer to your question
seems crucial although I don't have the solution nor find any.
Khiet.

Luc Feys wrote:


I suddenly remembered that in hibernate one can specify the mapping files in code (using the hibernate API). So I tried that (again using ClassLoader.getResource), which worked fine. But now the problem has just shifted, because hibernate is now unable to find my persistent classes that correspond to my .hbm mapping files.


So I'm back to question 1: is it possible to make a required plug-in access classes and resources of the application that uses the required plug-in? I guess I could make the hibernate plug-in dependent on my rcp app (but that would create a circular reference, which is probably not allowed?). And that would also mean that I can not reuse my hibernate plug-in in other projects, so what would be the use of putting the jar's in a separate plug-in then?


Or am I seriously missing something over here?


Thanks in advance for your help.