3 Replies Latest reply on Jun 8, 2016 8:35 AM by prabahard

    Using XMLBeans binding for JAX-WS web services

    weiqigao

      Hi,

       

      My last post in this forum was made six years ago.  How's everybody?

       

      I need to port some JAX-WS web services that use XMLBeans as the data binding from another application server.  I'm using JBoss AS 7.0.2 Final, but I could be using JBoss 7.1.1 Final as well.

       

      I searched the forum and other internet sites and understand that this is possible in some twisted way.  My development process will be a

       

        "Schemas for the parameters and return types first, generate XMLBeans for them using XMLBeans.  Then Java first using the XMLBeans in service methods and depends on the runtime to generate the WSDL."

       

      I have a prototype of this development flow working with plain Apache CXF.  The trick is to put an CXF annotation onto the SEI class:

       

        @javax.jws.WebService

        @org.apache.cxf.annotations.DataBinding(import org.apache.cxf.xmlbeans.XmlBeansDataBinding.class)

        public interface Demo {

          DemoResponseDocument foo(DemoRequestDocument request);

        }

       

      where DemoRequestDocument and DemoResponseDocument are XMLBeans generated classes from the schema.

       

      And I'm trying to deploy it in JBoss.  I noticed that the cxf-rt-databinding-xmlbeans-2.4.1.jar is not included in the JBoss AS 7.0.2 Final distribution.  The XMLBeans jar is also absent from the distrubution.  I did put the cxf-rt-databinding-xmlbeans-2.4.1.jar file into the proper place and updated the module.xml file.  I put the xmlbeans-2.4.0.jar into my WEB-INF/lib directory.  When I deployed it into JBoss AS 7.0.2 Final, I got the following error that I did not see when I run it with CXF directly:

       

      15:49:15,623 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-13) register: jboss.ws:context=demo,endpoint=Demo

      15:49:15,628 INFO  [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-13) Creating Service {http://foo.com/}Demo from class foo.Demo

      15:49:15,631 INFO  [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-13) remove: jboss.ws:context=demo,endpoint=Demo

      15:49:15,632 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-13) MSC00001: Failed to start service jboss.deployment.unit."demo.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."demo.war".INSTALL: Failed to process phase INSTALL of deployment "demo.war"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_07]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_07]

          at java.lang.Thread.run(Thread.java:722) [:1.7.0_07]

      Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Service class foo.Demo method total part {http://foo/}DemoRequest cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.

          at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)

          at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:88)

          at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)

          at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)

          at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:116)

          at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:109)

          at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:132)

          at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.internalDeploy(AspectDeploymentProcessor.java:79)

          at org.jboss.as.webservices.deployers.TCCLDeploymentProcessor.deploy(TCCLDeploymentProcessor.java:42)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]

          ... 5 more

      Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Service class foo.Demo method total part {http://foo/}DemoRequest cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.

          at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createBareMessage(ReflectionServiceFactoryBean.java:1164)

          at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:449)

          at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)

          at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)

          at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)

          at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)

          at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)

          at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:157)

          at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)

          at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)

          at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)

          ... 14 more

       

      What am I missing?  I'd appreciate any helps or pointers.

        • 1. Re: Using XMLBeans binding for JAX-WS web services
          weiqigao

          I was able to resolve the above issues with some JBoss-Modules magic:

           

          1. Add "Dependencies: org.jboss.ws.cxf.jbossws-cxf-client services export, org.apache.xmlbeans services export" line to MANIFEST.MF of the war

          2. Add a dependency line for "javax.api" in the org/apache/xmlbeans/main/module.xml

          3. Modify the org.apache.cxf module.xml file to add dependency on xmlbeans

           

          --

          Weiqi

          • 2. Re: Using XMLBeans binding for JAX-WS web services
            asoldano

            Thanks for having shared this; yes, the proper approach on AS7 basically implies creating a jboss module for xmlbeans, adding the cxf-rt-databinding-xmlbeans jar to the cxf module and fixing the module dependencies as mentioned in the message above.

            • 3. Re: Using XMLBeans binding for JAX-WS web services
              prabahard

              Hi, I have followed your suggestion and my steps are below

               

              1. added xmlbeans to the module

              2. in the module.xml add the below

               

              <?xml version="1.0" encoding="UTF-8"?>

              <module xmlns="urn:jboss:module:1.0" name="org.xmlbeans">

                <resources>

                  <resource-root path="xbean-2.4.0.jar"/>

                      <!-- Insert resources here -->

                </resources>

                <dependencies>

                  <module name="javax.api" />

                </dependencies>

              </module>

               

              3. go to cxf main module.xml edit it by adding the below dependencies module

               

                      <!-- Added for XMLBean so that CXF uses XMLBean -->

                      <module name="org.xmlbeans" />

               

              4. Download cxf-rt-databinding-xmlbeans-3.1.4.jar and place it under modules\system\layers\base\org\apache\cxf\impl\main

               

              5. Update module.xml under modules\system\layers\base\org\apache\cxf\impl\main for the new add resource

                          <resource-root path="cxf-rt-databinding-xmlbeans-3.1.4.jar"/>

               

              6. in EAR jboss-deployment-structure.xml add the following dependencies

                          <module name="org.xmlbeans" services="export" />

                          <module name="org.jboss.ws.cxf.jbossws-cxf-client" services="export" />

               

               

              However, I am still getting the same JAXB loading issue. So I tried to comment the <!-- <resource-root path="cxf-rt-databinding-jaxb-3.1.4.jar"/> --> in the cxf-impl so it can load the newly added xmlbeans. When I do so it is complain about missing class

              Caused by: java.lang.ClassNotFoundException: org.apache.cxf.jaxb.JAXBDataBinding from [Module "org.apache.cxf.impl:main" from local module loader @33e5ccce (finder: local module finder @5a42bbf4 (roots: C:\Prabahar\dev\wildfly-10.0.0.Final\modules,C:\Prabahar\dev\wildfly-10.0.0.Final\modules\system\layers\base))]

                  at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

               

              Please suggest a way to overcome this issue, thanks!