felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil Bartlett <njbartl...@gmail.com>
Subject Re: ClassNotFoundException
Date Tue, 15 May 2012 19:34:12 GMT
As the stack trace shows, some code within Hibernate has done a 
Class.forName() to look up com.MyClass. Of course in a modular world, 
just a class name is not enough to find a class; you also have to know 
which module has that class. In this case it looks like Hibernate has 
guessed that it can just call Class.forName() with one argument, which 
causes it to use its own classloader, which then delegates up to the 
surrounding web container.

In other words, Hibernate is stupid, and breaks modularity! It's well 
known to OSGi programmers as a "difficult" library to use.

If Hibernate could import the package containing the domain class, then 
all would be well. Since you don't want to rebuild Hibernate for every 
possible domain package, you could look at creating a fragment with 
Hibernate as its host and adding the Import-Package for the domain.


> Chad.Davis@emc.com <mailto:Chad.Davis@emc.com>
> 15 May 2012 20:17
> I'm working with a Felix container embedded into a Tomcat deployed 
> Webapp. Felix is started inside of an ApplicationContextListener. We 
> then install some bundles at run time. Mostly, it kind of works ;) 
> However, there are glitches. Though I don't pretend to understand the 
> details, I gather that there are issues with running Felix inside of a 
> webapp like this. I would love to have some insight on that topic.
> My current and specific issue is this.
> My bundles all resolve, which to me means that all of my imported 
> classes should be visible. However, one of my bundle activator's blows 
> up complaining about a class not found. That class is from a package 
> that DEFINITELY has resolved. So, what's happening here? Here's a bit 
> of my stack trace. Is it right for the WebappClassLoader to be 
> involved here?
> Caused by: java.lang.ClassNotFoundException: com.MyClass
> at 
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438)
> at 
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Unknown Source)
> at 
> org.hibernate.annotations.common.util.ReflectHelper.classForName(ReflectHelper.java:78)
> Thanks!
> Chad

View raw message