0

I'm trying to unmarshal with serialization method a bean that is not the current bundle but in a commons components bundle.

I get the following error when camel tries to unmarshal my bean :

22:43:11,865 | ERROR | nModule-thread-1 | DefaultErrorHandler | 89 - org.apache.camel.camel-core - 2.8.0.fuse-06-11 | Failed delivery for exchangeId: ID-ITEM-64684-49962-1354223882336-2-1. Exhausted after delivery attempt: 1 caught: java.lang.ClassNotFoundException: commons.InformationInput java.lang.ClassNotFoundException: commons.InformationInput at java.net.URLClassLoader$1.run(URLClassLoader.java:202)[:1.6.0_33] at java.security.AccessController.doPrivileged(Native Method)[:1.6.0_33] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)[:1.6.0_33] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)[:1.6.0_33]http://stackoverflow.com/questions/6749334/osgi-bundle-access-spring-context-file-from-another-bundle at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_33] at org.apache.felix.framework.ModuleImpl.doImplicitBootDelegation(ModuleImpl.java:1610) at org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1547)

My bundle containing the bean is correctly started and i've defined the commons package in the Export-Package of the bundle definition

Does anyone managed to such thing ?

рüффп
  • 5,172
  • 34
  • 67
  • 113
yodamad
  • 1,452
  • 14
  • 24
  • Which bundle in which bundle ? :) I've import packages from commons in bundle where camel route from unmarshalling is defined. – yodamad Nov 30 '12 at 07:55
  • You should refine your question. What bundles are involved? Which bundle does what? What packages does each bundle import/export? Try to construct a minimal example, and then add that information to your question. – Björn Pollex Dec 03 '12 at 07:37
  • TO sum up : Bundle A defines a camel route which contains "unmarshal().serialization()". The bean to proceed throw this serialization is contained in a Bundle B (which contains only POJOs). Bundle A imports package of Bundle B POJOs and Bundle B export the same package. – yodamad Dec 03 '12 at 13:16

3 Answers3

1

This sometimes occurs when the bundle that is serializing/deserializing classes does not know in advance what packages must be imported.

One workaround is to use DynamicImport-Package. For example:

DynamicImport-Package: *

This then means the bundle can import classes in any package, but beware of the costs (see the linked article).

Dan Gravell
  • 7,855
  • 7
  • 41
  • 64
0

This sounds similar to Hibernate issues an OSGi environment where it fails because of class loading issues. I would recommend something classed class buddy loading. in the Manifest of your commons bundle that contains the class add this

Eclipse-BuddyPolicy:registered

Then in your dependent buddy make sure you have it added as a dependent bundle and this to its manifest.

Eclipse-RegisterBuddy:com.nameofmycommonbundle

This should solve your problem.

Here is a reference to hibernate reference

Björn Pollex
  • 75,346
  • 28
  • 201
  • 283
Duncan Krebs
  • 3,366
  • 2
  • 33
  • 53
0

I find a workaroud by enabling dynamicimport on camel-core bundle. This can be done on karaf console : dev:dynamicimport <camel-core-bundle-id>

yodamad
  • 1,452
  • 14
  • 24