Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Problem with OSGi class loader: Hibernate is not able to load class
Problem with OSGi class loader: Hibernate is not able to load class [message #201656] Thu, 21 April 2005 14:45 Go to next message
Eclipse UserFriend
Hello,

I want to use Hibernate in one of my plug-ins. Hibernate needs to load a
class using java.lang.ClassLoader.loadClass(String) for compiling the
mapping document.

I have this code in my start(BundleContext) method of the plug-in class
extending Plugin:

[...]
TestCase temp = new TestCase(null, null, null);

Configuration cfg = new Configuration()
.configure(hibernateConfigFile.toFile())
.addClass(TestCase.class)
[...]

It's no problem to create the instance "temp" in the first line of the
code snippet, the execution reaches the next line without any error. So,
I think the class loader is able to find the class TestCase...

But if the addClass(Class) method is called, the plug-in throws the
following Exception: [see below]

Can someone help me with this problem? I have no clue how to solve this.
In the first line, the plug-in finds the class, in the next one it does
not...

Regards,
Martin


org.hibernate.MappingException: class
org.deltadebugging.ddchange.eclipse.core.junit.internal.resu lt.TestCase
not found while looking for property: id
at
org.hibernate.util.ReflectHelper.reflectedPropertyClass(Refl ectHelper.java:81)
at
org.hibernate.mapping.SimpleValue.setTypeUsingReflection(Sim pleValue.java:254)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:359)
at
org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonVal ues(HbmBinder.java:293)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235 )
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
at org.hibernate.cfg.Configuration.add(Configuration.java:360)
at org.hibernate.cfg.Configuration.addInputStream(Configuration .java:397)
at org.hibernate.cfg.Configuration.addClass(Configuration.java: 465)
at
org.deltadebugging.ddchange.eclipse.core.CorePlugin.start(Co rePlugin.java:82)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$1 .run(BundleContextImpl.java:958)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:954)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:937)
at
org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:421)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:293)
at
org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLoca lClass(EclipseClassLoader.java:110)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:371)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:402)
at
org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader. loadClass(AbstractClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at
org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:307)
at
org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:336)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1313)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:131)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:124)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:113)
at
org.eclipse.jdt.internal.junit.ui.JUnitPlugin.loadTestRunLis teners(JUnitPlugin.java:382)
at
org.eclipse.jdt.internal.junit.ui.JUnitPlugin.getTestRunList eners(JUnitPlugin.java:415)
at
org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.startTe stRunListening(TestRunnerViewPart.java:691)
at
org.eclipse.jdt.internal.junit.ui.JUnitPlugin.connectTestRun ner(JUnitPlugin.java:208)
at
org.eclipse.jdt.internal.junit.ui.JUnitPlugin$2.run(JUnitPlu gin.java:269)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:106)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:2750)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2435)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1377)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:335)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
at org.eclipse.core.launcher.Main.run(Main.java:704)
at org.eclipse.core.launcher.Main.main(Main.java:688)
Caused by: java.lang.ClassNotFoundException:
org.deltadebugging.ddchange.eclipse.core.junit.internal.resu lt.TestCase
at
org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:404)
at
org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader. loadClass(AbstractClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302 )
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper. java:108)
at
org.hibernate.util.ReflectHelper.reflectedPropertyClass(Refl ectHelper.java:77)
... 50 more
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201666 is a reply to message #201656] Thu, 21 April 2005 15:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chaves.inf.no.ufsc.spam.br

This is a very f.a.q. You should be able to find the answer by searching
the newsgroups. For instance:

http://www.eclipse.org/search/search.cgi?q=hibernate+classlo ading+classloader

Martin Burger wrote:
> Hello,
>
> I want to use Hibernate in one of my plug-ins. Hibernate needs to load a
> class using java.lang.ClassLoader.loadClass(String) for compiling the
> mapping document.
>
> I have this code in my start(BundleContext) method of the plug-in class
> extending Plugin:
>
> [...]
> TestCase temp = new TestCase(null, null, null);
>
> Configuration cfg = new Configuration()
> .configure(hibernateConfigFile.toFile())
> .addClass(TestCase.class)
> [...]
>
> It's no problem to create the instance "temp" in the first line of the
> code snippet, the execution reaches the next line without any error. So,
> I think the class loader is able to find the class TestCase...
>
> But if the addClass(Class) method is called, the plug-in throws the
> following Exception: [see below]
>
> Can someone help me with this problem? I have no clue how to solve this.
> In the first line, the plug-in finds the class, in the next one it does
> not...
>
> Regards,
> Martin
>
>
> org.hibernate.MappingException: class
> org.deltadebugging.ddchange.eclipse.core.junit.internal.resu lt.TestCase
> not found while looking for property: id
> at
> org.hibernate.util.ReflectHelper.reflectedPropertyClass(Refl ectHelper.java:81)
>
> at
> org.hibernate.mapping.SimpleValue.setTypeUsingReflection(Sim pleValue.java:254)
>
> at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:359)
> at
> org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonVal ues(HbmBinder.java:293)
>
> at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235 )
> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
> at org.hibernate.cfg.Configuration.add(Configuration.java:360)
> at
> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:397)
> at org.hibernate.cfg.Configuration.addClass(Configuration.java: 465)
> at
> org.deltadebugging.ddchange.eclipse.core.CorePlugin.start(Co rePlugin.java:82)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl$1 .run(BundleContextImpl.java:958)
>
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:954)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:937)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:421)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:293)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLoca lClass(EclipseClassLoader.java:110)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:371)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:402)
>
> at
> org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader. loadClass(AbstractClassLoader.java:93)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:307)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:336)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1313)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:131)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:124)
>
> at
> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:113)
>
> at
> org.eclipse.jdt.internal.junit.ui.JUnitPlugin.loadTestRunLis teners(JUnitPlugin.java:382)
>
> at
> org.eclipse.jdt.internal.junit.ui.JUnitPlugin.getTestRunList eners(JUnitPlugin.java:415)
>
> at
> org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.startTe stRunListening(TestRunnerViewPart.java:691)
>
> at
> org.eclipse.jdt.internal.junit.ui.JUnitPlugin.connectTestRun ner(JUnitPlugin.java:208)
>
> at
> org.eclipse.jdt.internal.junit.ui.JUnitPlugin$2.run(JUnitPlu gin.java:269)
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:106)
>
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:2750)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2435)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1377)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:254)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)
> at
> org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)
> at
> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:335)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:129)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
> at org.eclipse.core.launcher.Main.run(Main.java:704)
> at org.eclipse.core.launcher.Main.main(Main.java:688)
> Caused by: java.lang.ClassNotFoundException:
> org.deltadebugging.ddchange.eclipse.core.junit.internal.resu lt.TestCase
> at
> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:404)
>
> at
> org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader. loadClass(AbstractClassLoader.java:93)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302 )
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:141)
> at
> org.hibernate.util.ReflectHelper.classForName(ReflectHelper. java:108)
> at
> org.hibernate.util.ReflectHelper.reflectedPropertyClass(Refl ectHelper.java:77)
>
> ... 50 more
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201674 is a reply to message #201666] Thu, 21 April 2005 15:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chaves.inf.no.ufsc.spam.br

Also:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=87775

Rafael Chaves wrote:
> This is a very f.a.q. You should be able to find the answer by searching
> the newsgroups. For instance:
>
> http://www.eclipse.org/search/search.cgi?q=hibernate+classlo ading+classloader
>
>
> Martin Burger wrote:
>
>> Hello,
>>
>> I want to use Hibernate in one of my plug-ins. Hibernate needs to load
>> a class using java.lang.ClassLoader.loadClass(String) for compiling
>> the mapping document.
>>
>> I have this code in my start(BundleContext) method of the plug-in
>> class extending Plugin:
>>
>> [...]
>> TestCase temp = new TestCase(null, null, null);
>>
>> Configuration cfg = new Configuration()
>> .configure(hibernateConfigFile.toFile())
>> .addClass(TestCase.class)
>> [...]
>>
>> It's no problem to create the instance "temp" in the first line of the
>> code snippet, the execution reaches the next line without any error.
>> So, I think the class loader is able to find the class TestCase...
>>
>> But if the addClass(Class) method is called, the plug-in throws the
>> following Exception: [see below]
>>
>> Can someone help me with this problem? I have no clue how to solve
>> this. In the first line, the plug-in finds the class, in the next one
>> it does not...
>>
>> Regards,
>> Martin
>>
>>
>> org.hibernate.MappingException: class
>> org.deltadebugging.ddchange.eclipse.core.junit.internal.resu lt.TestCase
>> not found while looking for property: id
>> at
>> org.hibernate.util.ReflectHelper.reflectedPropertyClass(Refl ectHelper.java:81)
>>
>> at
>> org.hibernate.mapping.SimpleValue.setTypeUsingReflection(Sim pleValue.java:254)
>>
>> at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:359)
>> at
>> org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonVal ues(HbmBinder.java:293)
>>
>> at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235 )
>> at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
>> at org.hibernate.cfg.Configuration.add(Configuration.java:360)
>> at
>> org.hibernate.cfg.Configuration.addInputStream(Configuration .java:397)
>> at org.hibernate.cfg.Configuration.addClass(Configuration.java: 465)
>> at
>> org.deltadebugging.ddchange.eclipse.core.CorePlugin.start(Co rePlugin.java:82)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.BundleContextImpl$1 .run(BundleContextImpl.java:958)
>>
>> at java.security.AccessController.doPrivileged(Native Method)
>> at
>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:954)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:937)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:421)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:293)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseClassLoader.findLoca lClass(EclipseClassLoader.java:110)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:371)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:402)
>>
>> at
>> org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader. loadClass(AbstractClassLoader.java:93)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>> at
>> org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:307)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:336)
>>
>> at
>> org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1313)
>>
>> at
>> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:131)
>>
>> at
>> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:124)
>>
>> at
>> org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:113)
>>
>> at
>> org.eclipse.jdt.internal.junit.ui.JUnitPlugin.loadTestRunLis teners(JUnitPlugin.java:382)
>>
>> at
>> org.eclipse.jdt.internal.junit.ui.JUnitPlugin.getTestRunList eners(JUnitPlugin.java:415)
>>
>> at
>> org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.startTe stRunListening(TestRunnerViewPart.java:691)
>>
>> at
>> org.eclipse.jdt.internal.junit.ui.JUnitPlugin.connectTestRun ner(JUnitPlugin.java:208)
>>
>> at
>> org.eclipse.jdt.internal.junit.ui.JUnitPlugin$2.run(JUnitPlu gin.java:269)
>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>> at
>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:106)
>>
>> at
>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:2750)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2435)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1377)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1348)
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:254)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)
>> at
>> org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)
>> at
>> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:335)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:129)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:324)
>> at org.eclipse.core.launcher.Main.basicRun(Main.java:185)
>> at org.eclipse.core.launcher.Main.run(Main.java:704)
>> at org.eclipse.core.launcher.Main.main(Main.java:688)
>> Caused by: java.lang.ClassNotFoundException:
>> org.deltadebugging.ddchange.eclipse.core.junit.internal.resu lt.TestCase
>> at
>> org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:404)
>>
>> at
>> org.eclipse.osgi.framework.adaptor.core.AbstractClassLoader. loadClass(AbstractClassLoader.java:93)
>>
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302 )
>> at java.lang.Class.forName0(Native Method)
>> at java.lang.Class.forName(Class.java:141)
>> at
>> org.hibernate.util.ReflectHelper.classForName(ReflectHelper. java:108)
>> at
>> org.hibernate.util.ReflectHelper.reflectedPropertyClass(Refl ectHelper.java:77)
>>
>> ... 50 more
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201813 is a reply to message #201666] Sat, 23 April 2005 09:44 Go to previous messageGo to next message
Eclipse UserFriend
Rafael Chaves schrieb am 21.04.2005 21:15:

> This is a very f.a.q. You should be able to find the answer by searching
> the newsgroups. For instance:
>
> http://www.eclipse.org/search/search.cgi?q=hibernate+classlo ading+classloader

Oh, sorry! I searched in the archive for the wrong words...

If I understand it in the right way: It is not possible to pack the
Hibernate JAR and it's dependencies (asm.jar, ...) in an own plug-in?
(The org.junit plug-in does this for the junit.jar archive.) If these
JARs are in an separate plug-in, Hibernate is not able to get the
classes in the "real" plug-in!?

Please correct me if I'm wrong.

Thanks,
Martin
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201844 is a reply to message #201813] Sat, 23 April 2005 13:19 Go to previous messageGo to next message
Eclipse UserFriend
On Sat, 23 Apr 2005 15:44:03 +0200, Martin Burger <m@rtin-burger.de> wrote:

> Rafael Chaves schrieb am 21.04.2005 21:15:
>
>> This is a very f.a.q. You should be able to find the answer by
>> searching the newsgroups. For instance:
>>
>> http://www.eclipse.org/search/search.cgi?q=hibernate+classlo ading+classloader
>
> Oh, sorry! I searched in the archive for the wrong words...
>
> If I understand it in the right way: It is not possible to pack the
> Hibernate JAR and it's dependencies (asm.jar, ...) in an own plug-in?
> (The org.junit plug-in does this for the junit.jar archive.) If these
> JARs are in an separate plug-in, Hibernate is not able to get the
> classes in the "real" plug-in!?
>
> Please correct me if I'm wrong.

correct.

a cludgy workaround is to use a context classloader which includes your
model classes.

/max
>
> Thanks,
> Martin



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201852 is a reply to message #201813] Sat, 23 April 2005 13:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chaves.inf.no.ufsc.spam.br

You *can* pack Hibernate as a plug-in. The challenge is that Hibernate
assumes it can find user classes in the current context classloader, and
that is not the case in Eclipse (a plug-in has a very well defined
classpath).

As mentioned by Max, plug-in developers work around that by setting the
context classloader to be the plug-in classloader before interacting
with Hibernate. But you have then to restore it after the interaction ends.

This is cumbersome, and the PR I mentioned in my other post is intended
to address that problem.

Rafael

Martin Burger wrote:
> If I understand it in the right way: It is not possible to pack the
> Hibernate JAR and it's dependencies (asm.jar, ...) in an own plug-in?
> (The org.junit plug-in does this for the junit.jar archive.) If these
> JARs are in an separate plug-in, Hibernate is not able to get the
> classes in the "real" plug-in!?
>
> Please correct me if I'm wrong.
>
> Thanks,
> Martin
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201875 is a reply to message #201852] Sat, 23 April 2005 17:36 Go to previous messageGo to next message
Eclipse UserFriend
On Sat, 23 Apr 2005 19:35:10 +0200, Rafael Chaves
<chaves@inf.no.ufsc.spam.br> wrote:

> You *can* pack Hibernate as a plug-in. The challenge is that Hibernate
> assumes it can find user classes in the current context classloader, and
> that is not the case in Eclipse (a plug-in has a very well defined
> classpath).

I would like to add that this is very correct behavior for any other
environment
than eclipse ;)

> This is cumbersome, and the PR I mentioned in my other post is intended
> to address that problem.

I missed that one ? what was it ?

/max

>
> Rafael
>
> Martin Burger wrote:
>> If I understand it in the right way: It is not possible to pack the
>> Hibernate JAR and it's dependencies (asm.jar, ...) in an own plug-in?
>> (The org.junit plug-in does this for the junit.jar archive.) If these
>> JARs are in an separate plug-in, Hibernate is not able to get the
>> classes in the "real" plug-in!?
>> Please correct me if I'm wrong.
>> Thanks,
>> Martin



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201881 is a reply to message #201852] Sat, 23 April 2005 17:37 Go to previous messageGo to next message
Eclipse UserFriend
On Sat, 23 Apr 2005 19:35:10 +0200, Rafael Chaves
<chaves@inf.no.ufsc.spam.br> wrote:

> You *can* pack Hibernate as a plug-in. The challenge is that Hibernate
> assumes it can find user classes in the current context classloader, and
> that is not the case in Eclipse (a plug-in has a very well defined
> classpath).

I would like to add that this is very correct behavior in any other
environment than eclipse ;)

> This is cumbersome, and the PR I mentioned in my other post is intended
> to address that problem.

I missed that one - what PR ?

/max

> Rafael
>
> Martin Burger wrote:
>> If I understand it in the right way: It is not possible to pack the
>> Hibernate JAR and it's dependencies (asm.jar, ...) in an own plug-in?
>> (The org.junit plug-in does this for the junit.jar archive.) If these
>> JARs are in an separate plug-in, Hibernate is not able to get the
>> classes in the "real" plug-in!?
>> Please correct me if I'm wrong.
>> Thanks,
>> Martin



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201889 is a reply to message #201875] Sun, 24 April 2005 01:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: chaves.inf.no.ufsc.spam.br

Max Rydahl Andersen wrote:
> On Sat, 23 Apr 2005 19:35:10 +0200, Rafael Chaves
> <chaves@inf.no.ufsc.spam.br> wrote:
>
>> You *can* pack Hibernate as a plug-in. The challenge is that
>> Hibernate assumes it can find user classes in the current context
>> classloader, and that is not the case in Eclipse (a plug-in has a
>> very well defined classpath).
>
>
> I would like to add that this is very correct behavior for any other
> environment
> than eclipse ;)

This is probably related to the fact that Eclipse manages classloading
so heavy-handedly, but execution flows freely across plug-ins. So
Eclipse cannot enforce threads to have the expected context classloader.
If Eclipse was in charge of calling plug-ins (IoC) and intercepting
cross-plug-in interactions (as an EJB server might be able to do), that
could be enforced.

>
>> This is cumbersome, and the PR I mentioned in my other post is
>> intended to address that problem.
>
>
> I missed that one ? what was it ?

Here it is:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=87775

Rafael
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201898 is a reply to message #201889] Sun, 24 April 2005 04:45 Go to previous messageGo to next message
Eclipse UserFriend
On Sun, 24 Apr 2005 07:06:14 +0200, Rafael Chaves
<chaves@inf.no.ufsc.spam.br> wrote:

> Max Rydahl Andersen wrote:
>> On Sat, 23 Apr 2005 19:35:10 +0200, Rafael Chaves
>> <chaves@inf.no.ufsc.spam.br> wrote:
>>
>>> You *can* pack Hibernate as a plug-in. The challenge is that
>>> Hibernate assumes it can find user classes in the current context
>>> classloader, and that is not the case in Eclipse (a plug-in has a
>>> very well defined classpath).
>> I would like to add that this is very correct behavior for any other
>> environment
>> than eclipse ;)
>
> This is probably related to the fact that Eclipse manages classloading
> so heavy-handedly, but execution flows freely across plug-ins. So
> Eclipse cannot enforce threads to have the expected context classloader.
> If Eclipse was in charge of calling plug-ins (IoC) and intercepting
> cross-plug-in interactions (as an EJB server might be able to do), that
> could be enforced.

yes this is correct and to work in non-j2ee, like j2se environments we
fallback to Class.forName() but that also doesnt work since if you bundle
hibernate as a separate plugin then it wont be able to see the classes
of the plugins that uses the hibernate plugin.

Eclipses (or OSGI's) classloading is something very different than any
other classloading mechanism and hence one will have trouble with alot
of frameworks out there that dynamically instantiates classes - from the
top of my head log4j custom appenders, xerces custom xml parser dom impl,
hibernate helper/user classes, any runtime AOP, jdbc drivers, etc.

the list is long....


>
>>
>>> This is cumbersome, and the PR I mentioned in my other post is
>>> intended to address that problem.
>> I missed that one ? what was it ?
>
> Here it is:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=87775

a ok - that is the bug im already monitoring - thanks anyway.

/max
Re: Problem with OSGi class loader: Hibernate is not able to load class [message #201905 is a reply to message #201889] Sun, 24 April 2005 04:46 Go to previous message
Eclipse UserFriend
On Sun, 24 Apr 2005 07:06:14 +0200, Rafael Chaves
<chaves@inf.no.ufsc.spam.br> wrote:

Max Rydahl Andersen wrote:
On Sat, 23 Apr 2005 19:35:10 +0200, Rafael Chaves
<chaves@inf.no.ufsc.spam.br> wrote:

You *can* pack Hibernate as a plug-in. The challenge is that Hibernate
assumes it can find user classes in the current context classloader, and
that is not the case in Eclipse (a plug-in has a very well defined
classpath).
I would like to add that this is very correct behavior for any other
environment
than eclipse

This is probably related to the fact that Eclipse manages classloading so
heavy-handedly, but execution flows freely across plug-ins. So Eclipse
cannot enforce threads to have the expected context classloader. If
Eclipse was in charge of calling plug-ins (IoC) and intercepting
cross-plug-in
interactions (as an EJB server might be able to do), that could be
enforced.

yes this is correct and to work in non-j2ee, like j2se environments we
fallback to Class.forName() but that also doesnt work since if you bundle
hibernate as a separate plugin then it wont be able to see the classes
of the plugins that uses the hibernate plugin.

Eclipses (or OSGI's) classloading is something very different than any
other classloading mechanism and hence one will have trouble with alot
of frameworks out there that dynamically instantiates classes - from the
top of my head log4j custom appenders, xerces custom xml parser dom impl,
hibernate helper/user classes, any runtime AOP, jdbc drivers, etc.

the list is long....




This is cumbersome, and the PR I mentioned in my other post is intended
to address that problem.
I missed that one ? what was it ?

Here it is:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=87775

a ok - that is the bug im already monitoring - thanks anyway.

/max
Previous Topic:CVS Integration
Next Topic:TextViewer (jface) like the java editor
Goto Forum:
  


Current Time: Thu May 29 04:10:05 EDT 2025

Powered by FUDForum. Page generated in 0.19087 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top