Eclipse 3.0M6 classloader is a little wonky
by Kevin Dangoor
I had a BeanShell script to configure a Hibernate Session that was working before Christmas. It stopped working, and I just traced the problem to Eclipse.
For those of you following the Eclipse 3.0 track, there appears to have been an odd change to the classloader that can cause problems under certain circumstances… In 3.0M5, SomeClass.class.getClassLoader() returns a reasonable classloader. In M6, that returns null, which can certainly throw things off when they’re expecting a valid classloader.
Hibernate’s Configuration.addClass method calls getClassLoader().getResourceAsStream(…) on the class you pass in. Obviously, this will give you a null pointer exception of the classloader returned is null… gah.
Really? This works for me. I have been on 3.0M6 since it was built. I recently (yesterday) moved to the latest nightly build, but I am completely confident I didn’t get this error before.
We tried this on two machines in our office, witnessing the same behavior on both.
Since you said that it’s working okay for you, I thought that maybe it’s a BeanShell/Eclipse interaction sort of problem. We just tried it again and now it’s working. Gah.
I have the same problem as tazzzzz with Eclipse 3.1 M1.
When I try to run the following code (in a class called Utilities.java) from Eclipse:
ClassLoader loader = Utilities.class.getClassLoader();
the loader variable is always null.
If I run it from outside Eclipse everything is ok.
Does anybody know why this happens?
Thanx
I.