Frederic, The problems you are experiencing are caused by the way classloading works in JBI. You probably have a copy of the same class in both SU now, right? If you have a look at http://servicemix.apache.org/classloaders.html, you'll notice that every SU has its own classloader. So you will indeed be seeing two classnames that are the same, but the cast will fail because the class definitions have been loaded by different classloaders.
The solution for this is to move you shared class into another classloader, e.g. by moving it into a shared library or by putting it in a jar in the container's lib/optional directory. At the bottom, you'll see how ServiceMix 3.2 and above will let you reference the shared library from both SU xbean.xml files. Regards, Gert Vanthienen ------------------------ Open Source SOA: http://fusesource.com Blog: http://gertvanthienen.blogspot.com/ 2009/4/7 Frederic Tuttle <[email protected]>: > I am attempting to use JNDI as suggested in the documentation to share data > (POJO) between service units, but I am getting a class cast exception. > The first SU is based on servicemix-bean and it contains data that I want to > share with other SUs. It binds itself in a JNDI context upon startup. > Another SU, based on servicemix-cxf-se is attempting to access the POJO/bean > with the identical initial context factory > (org.apache.xbean.spring.jndi.SpringInitialContextFactory) and provider URL > configuration. > The lookup is succeeding, but I get a ClassCastException when I cast the > result to the original class from which the bean was made. The instanceof > operator returns false, but the class names are the same and the hashcodes > are the same. I might be misusing JNDI, but if anyone has used this > approach, I'd be grateful to get some advice. Are there restrictions on > what can be bound ? I am using version 3.3. > > Thanks in advance. > > -FT >
