2 Replies Latest reply on Oct 21, 2010 3:08 PM by valig003

    Package uniqueness required for CXF web services?

    valig003

      I am running apache-servicemix-4.3.0-fuse-02-00 and prototyping web service functionality using CXF.  I have a couple fairly straightforward questions, but need to provide some background first. 

       

      I have an OSGi bundle (Maven2/Spring JDBC) which connects to a database and is exposed as an OSGi service:

          <osgi:service ref="emailDAO" auto-export="all-classes" />

      It deploys correctly and everything looks good.

       

      I then decided to write two different CXF web service bundles which use the OSGi bundle (above) for database lookups.  The first service was a Java-first approach using annotations (CXF/Spring/Maven2/OSGi).  The second was a WSDL-first approach (CXF/Spring/Maven2/OSGi).  When deployed separately, each web service bundle installs and starts correctly and gets a reference to the database connection bundle; all is good.

          <osgi:reference id="emailDAO" bean-name="emailDAO" interface="edu.umn.arch.data.EmailDAO" />

      ...

          <import resource="classpath:META-INF/cxf/cxf.xml" />     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />     <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />     <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />

          <bean name="emailServiceBean" class="edu.umn.arch.service.impl.EmailServiceImpl">         <property name="emailDataAccessor" ref="emailDAO" />     </bean>     <jaxws:endpoint id="emailWSDLService"                     implementor="#emailServiceBean"                     address="/EmailService" />...

       

      The problem comes when I try to install both the Java-first and the WSDL-first CXF services at the same time.  Whichever one is installed second automatically spews a screen of ClassNotFoundException stack traces.  The one commonality between the two bundles is that they use the same package names (edu.umn.arch.service / edu.umn.arch.service.impl).  The bean names and implementation classes are different between the two projects (so the Spring bean definitions and jaxws endpoints are named differently).  Because they each work independently, but can't seem to co-exist without class loader issues, I'm guessing this has something to do with a package name collision when resolving the spring bean definitions.  So here are my questions:

       

      (1) Can two bundles use the same package names?  (Is this a Spring thing or an OSGi thing?)

      (2) Are there any other reasons I might see the ClassNotFoundException for whichever is installed second?  (Remember that each bundle works just fine when deployed by itself). 

      (3) Is there a 'fix' that might clean up whatever the classpath issue is?  What am I missing?

       

      THANKS!