Yeah, the issue was that whenever Felix loaded a class locally from a
module it was resolving it eagerly, which apparently caused problems for
J9. After thinking about it, it doesn't really seem to make sense to
resolve the class eagerly and I am not sure why this was happening in
the first place.
Generally speaking, a class will never be loaded locally from a module
unless it is the target of a loadClass() request and the loadClass()
method will resolve the returned class if the resolve flag is set. If
the locally loaded class, however, is not the target of the original
loadClass(), but is loaded as a byproduct of it, then it will not be
resolved until later when it is used (I assume).
So the fix, which can easily be implemented in 0.8.0, is to go into the
loadClassFromModule() method of
org.apache.felix.framework.searchpolicy.ContentClassLoader and simply
delete the line that does "resolveClass(clazz)".
I will commit this to trunk too, right now.
-> richard
Thomas Watson wrote:
Richard,
Can you explain the potential fix? Chatting with you yesterday it was a
mystery to me why you were seeing this on Felix.
Tom
"Richard S. Hall" <[EMAIL PROTECTED]>
01/22/2007 07:33 PM
Please respond to
felix-dev@incubator.apache.org
To
felix-dev@incubator.apache.org
cc
Subject
Re: ClassCircularityError with j9
Chris Custine wrote:
So this may not have been specific to j9 then?
Yes or no, it is hard to say. The same code executed fine on Sun's JRE,
so it seems like it is JRE implementation specific. Whether one impl is
right or wrong is something that I cannot say, nor can I say for sure
that we wouldn't somehow run into this issue on a Sun JRE either, we
just haven't so far.
So, I am just happy that we have a potential fix. :-)
-> richard
Chris
On 1/22/07, Richard S. Hall <[EMAIL PROTECTED]> wrote:
Hello Carlos,
Sorry it took me a little while to look into this...
I think I have uncovered the issue. The short explanation is that it
appears Felix was resolving classes when it should not have been.
I will look into this some more hopefully tomorrow or Wed (I am
traveling tomorrow). I just need to verify what the proper fix
is...then
I will commit it to trunk. I expect it will be simple enough that you
should be able to back port it to the 0.8.0 release if you don't want
to
use the trunk.
I will let you know. Thanks for giving us the feedback.
-> richard
Carlos Herrando wrote:
Hello!,
I'm Carlos, I'm new in the list.
I'm trying to use Felix in a Pocket PC with the j9 vm and I'm getting
a ClassCircularityError when I start the http bundle. I've put below
the error trace. The funny thing happens when I try to start again
the
bundle, I get the same exception but with another package, and one
more time if you try to start the bundle it runs well. I'm getting
the
same ClassCircularityErrors in other bundles.
Could somebody help me with this problem?.
START LEVEL 1
ID State Level Name
[ 0] [Active ] [ 0] System Bundle (0.8.0.incubator)
[ 1] [Active ] [ 1] Apache Felix Shell Service
(0.8.0.incubator
)
[ 2] [Active ] [ 1] Apache Felix Shell TUI (0.8.0.incubator)
[ 3] [Active ] [ 1] Apache Felix Bundle Repository
(0.8.0.incubator)
->
->
-> install file:bundle/servlet.jar
Bundle ID: 4
-> start 4
DEBUG: WIRE: 4.0 -> javax.servlet.http -> 4.0
DEBUG: WIRE: 4.0 -> javax.servlet -> 4.0
DEBUG: WIRE: 4.0 -> javax.servlet.jsp -> 4.0
-> install file:bundle/http.jar
Bundle ID: 5
-> start 5
DEBUG: WIRE: 5.0 -> javax.servlet.http -> 4.0
DEBUG: WIRE: 5.0 -> javax.servlet -> 4.0
DEBUG: WIRE: 5.0 -> org.osgi.service.http -> 5.0
DEBUG: WIRE: 5.0 -> org.osgi.framework -> 0
org.osgi.framework.BundleException: Activator start error.
at
org.apache.felix.framework.Felix._startBundle(Felix.java:1305)
at
org.apache.felix.framework.Felix.startBundle(Felix.java:1201)
at
org.apache.felix.framework.BundleImpl.start(BundleImpl.java:345)
at
org.apache.felix.shell.impl.StartCommandImpl.execute(
StartCommandImpl.java:82)
at
org.apache.felix.shell.impl.Activator$ShellServiceImpl.executeCommand(
Activator.java:265)
at
org.apache.felix.shell.tui.Activator$ShellTuiRunnable.run(Activator.java
:167)
at java.lang.Thread.run(Thread.java:568)
Caused by: java.lang.ClassCircularityError:
org/mortbay/util/FileResource
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:963)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClassFromModule
(ContentClassLoader.java:58)
at
org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getClass(
ContentLoaderImpl.java:121)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource
(R4SearchPolicyCore.java:358)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(
R4SearchPolicyCore.java:136)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(
R4SearchPolicy.java:45)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(
ContentClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.ClassLoader.defineClass(ClassLoader.java:700)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.findClass(
ContentClassLoader.java:149)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClassFromModule
(ContentClassLoader.java:51)
at
org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getClass(
ContentLoaderImpl.java:121)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource
(R4SearchPolicyCore.java:358)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(
R4SearchPolicyCore.java:136)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(
R4SearchPolicy.java:45)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(
ContentClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:963)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClassFromModule
(ContentClassLoader.java:58)
at
org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getClass(
ContentLoaderImpl.java:121)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource
(R4SearchPolicyCore.java:358)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(
R4SearchPolicyCore.java:136)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(
R4SearchPolicy.java:45)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(
ContentClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:963)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClassFromModule
(ContentClassLoader.java:58)
at
org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getClass(
ContentLoaderImpl.java:121)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource
(R4SearchPolicyCore.java:358)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(
R4SearchPolicyCore.java:136)
at
org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(
R4SearchPolicy.java:45)
at
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(
ContentClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:494)
at
org.ungoverned.osgi.bundle.http.HttpActivatorImpl.initializeJetty(
HttpActivatorImpl.java:172)
at
org.ungoverned.osgi.bundle.http.HttpActivatorImpl.start(
HttpActivatorImpl.java:129)
at
org.apache.felix.framework.util.SecureAction.startActivator(
SecureAction.java:509)
at
org.apache.felix.framework.Felix._startBundle(Felix.java:1260)
... 6 more
java.lang.ClassCircularityError: org/mortbay/util/FileResource
start 5
...same exception as above...
java.lang.ClassCircularityError: org/mortbay/util/JarFileResource
start 5
OK