KernelBundleClassLoader - Wiring problem? [message #1160108] |
Mon, 28 October 2013 20:49  |
Eclipse User |
|
|
|
I'm doing direct OAuth2 authentication to Salesforce.com using org.springframework.security.oauth2.client.OAuth2RestTemplate. Since the content type of retrieved data is JSON, I have to manually add an 'org.springframework.http.converter.json.MappingJacksonHttpMessageConverter', as
restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
While my bundle 'erp.salesforce' directly declares imports for 'org.codehaus.jackson' and org.codehaus.jackson.map, the bundle will fail to start even when I deliberately start both jackson-core-asl-1.9.9.jar and jackson-mapper-asl-1.9.9.jar (which are of course valid OSGi bundles) before starting my application bundle.
Here is what the log output looks like (slightly trimmed for "other common frames"):
[2013-10-28 15:39:42.965] fs-watcher <HD0002E> Hot deploy failed for file 'erp.salesforce-1.0.0-SNAPSHOT.jar'. org.eclipse.virgo.nano.deployer.api.core.DeploymentException: BundleException
at org.eclipse.virgo.kernel.install.artifact.internal.bundle.StandardBundleDriver.startBundle(StandardBundleDriver.java:199)
... other common frames omitted
Caused by: org.osgi.framework.BundleException: Exception in com.mycompany.erp.salesforce.impl.Activator.start() of bundle com.mycompany.erp.salesforce.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
... other common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/codehaus/jackson/JsonProcessingException
at com.mycompany.erp.salesforce.oauth2.AutomatedAccess.<init>(AutomatedAccess.java:66)
at com.mycompany.erp.salesforce.impl.Activator.tryAutomatedAccess(Activator.java:46)
at com.mycompany.erp.salesforce.impl.Activator.start(Activator.java:31)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 35 common frames omitted
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.codehaus.jackson.JsonProcessingException in KernelBundleClassLoader: [bundle=org.springframework.web_3.1.0.RELEASE]
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:150)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 41 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.JsonProcessingException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:146)
... 42 common frames omitted
Note in particular this piece of information:
ExtendedClassNotFoundException: org.codehaus.jackson.JsonProcessingException in KernelBundleClassLoader: [bundle=org.springframework.web_3.1.0.RELEASE]
Now, I was able to overcome this by modifying the ./configuration/java6-server.profile
by adding a couple lines, to declare these as "system" packages in the parent classloader.
org.osgi.framework.system.packages = \
org.codehaus.jackson,\
org.codehaus.jackson.map,\
and, the whole thing works beautifully -- but I think there must be a (probably simple) programmatic way to extend the classpath during Bundle activation. (I was a little surprised that the Virgo and Gemini wouldn't do this as-is.) Is this a fairly common problem, that injecting something into a Spring module requires classes outside the scope of its default wiring within the OSGi environment?
|
|
|
Re: KernelBundleClassLoader - Wiring problem? [message #1177105 is a reply to message #1160108] |
Fri, 08 November 2013 14:33  |
Eclipse User |
|
|
|
I don't know if the classpath can be extended programatically, but, in this case, I think that would be better to add an fragment attached to this spring bundle. This fragment can control the imports, if some is missing, like in this case. Do you have tried that?
|
|
|
Powered by
FUDForum. Page generated in 0.04793 seconds