8 Replies Latest reply on Feb 26, 2009 11:25 AM by Marcel Casado

    CXF wsdl2java maven plugin with  xmlbeans databinding problem

    Marcel Casado Novice

      Hi,

       

      I've been trying to create a web service implementation wsdl first approach using maven "cxf-codegen-plugin" (2.1.4)  with xmlbeans databinding (required).

      I also must use a xsdconfig file to customize the schema binding to java classes due some compilation errors on the binding java classes due the schema.

       

      So at this point I'm not sure if I have to use a combination of  the "xmlbeans-maven-plugin" first to create the java bindings from my schema so I can set up the xsdconfig file location  and then use  "cxf-codegen-plugin" with xmlbeans databinding and -keep to generate the service stubs from the WSDL or if I can get all done only using  "cxf-codegen-plugin" with xmlbeans databinding in which case I don't know how to get my xsdconfig set up.

       

      So trying to use both plugins working together to get the job done I 'm getting an exception when the ""cxf-codegen-plugin" with xmlbeans databinding kicks in after the bindings has been generated by the "xmlbeans-maven-plugin".

       

      Configuring mojo 'org.codehaus.mojo:xmlbeans-maven-plugin:2.3.2:xmlbeans' -->

         (f) catalogLocation = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/catalog/resolver-catalog.xml

         (f) classGenerationDirectory = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/generated/classes

         (f) debug = false

         (f) defaultXmlConfigDir = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/xsdconfig

         (f) download = true

         (f) generatedSchemaDirectory = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/xmlbeans-xsds

         (f) javaSource = 1.5

         (f) jaxb = false

         (f) memoryMaximumSize = 1048m

         (f) noAnn = false

         (f) noJavac = false

         (f) noPvr = false

         (f) noUpa = false

         (f) noVDoc = false

         (f) project = MavenProject: org.apache.servicemix.samples.cxf-wsdl-first:wsdl-first-cxfse-su:3.4.0.1-fuse @ /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/pom.xml

         (f) quiet = true

         (f) schemaDirectory = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources

         (f) sourceGenerationDirectory = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/jaxws

         (f) sourceSchemas =

         (f) staleFile = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/generated-sources/xmlbeans/.staleFlag

         (f) verbose = false

         (f) xmlConfigs = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/schemas/schemaConfig/XsdConfig.xml

      -- end configuration --

      xmlbeans:xmlbeans {execution: default}

      The schema Directory is /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources

      Artifact count: 75

      looking for artifact schemas.

      The schema Directory is /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources

      Artifact count: 75

      looking for artifact schemas.

      Number of XSD Files: 0

      Number of WSDL Files: 1

      Creating a list of config files.

      A list was given.

      looking for resolver catalog at /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/catalog/resolver-catalog.xml

      Stale flag file exists.

      Comparing to xsd's modification time.

      0 xsd to compare.

      Comparing to wsdl's modification time.

      1 wsdl to compare.

      All schema objects are up to date.

       

       

       

      Configuring mojo 'org.apache.cxf:cxf-codegen-plugin:2.1.4:wsdl2java' -->

         (f) classesDirectory = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/classes

         (f) markerDirectory = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/cxf-codegen-plugin-markers

         (f) project = MavenProject: org.apache.servicemix.samples.cxf-wsdl-first:wsdl-first-cxfse-su:3.4.0.1-fuse @ /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/pom.xml

         (f) sourceRoot = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/jaxws

         (f) testWsdlRoot = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/test/resources/wsdl

         (f) useCompileClasspath = false

         (s) wsdl = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wcs1_1_2.wsdl

         (s) dataBinding = xmlbeans

         (s) extraargs =

         (f) wsdlOptions = [Lorg.apache.cxf.maven_plugin.WsdlOption;@bc9d1a

         (f) wsdlRoot = /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wsdl

      -- end configuration --

      cxf-codegen:wsdl2java {execution: default}

       

      .......

       

      Calling wsdl2java with args: -verbose, -d, /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/jaxws, -db, xmlbeans, -classdir, /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/generated/classes, -keep, -impl, file:/Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wcs1_1_2.wsdl

      Feb 23, 2009 8:23:04 PM org.apache.cxf.tools.wsdlto.core.PluginLoader loadPlugin

      INFO: Replaced default databinding jaxb

      Feb 23, 2009 8:23:04 PM org.apache.cxf.tools.wsdlto.core.PluginLoader loadPlugin

      INFO: Replaced default frontend jaxws

      Loading FrontEnd jaxws ...

      Loading DataBinding xmlbeans ...

      wsdl2java -verbose -d /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/jaxws -db xmlbeans -classdir /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/generated/classes -keep -impl file:/Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wcs1_1_2.wsdl

      wsdl2java - Apache CXF 2.1.4

       

      ...

       

      org.apache.cxf.tools.common.ToolException: java.lang.NullPointerException

           at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:240)

           at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83)

           at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:103)

           at org.apache.cxf.maven_plugin.WSDL2JavaMojo.processWsdl(WSDL2JavaMojo.java:360)

           at org.apache.cxf.maven_plugin.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:257)

           at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)

           at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)

           at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)

           at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)

           at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)

           at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)

           at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)

           at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)

           at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)

           at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)

           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

           at java.lang.reflect.Method.invoke(Method.java:589)

           at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)

           at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)

           at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

           at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

      Caused by: java.lang.NullPointerException

           at org.apache.cxf.xmlbeans.tools.XMLBeansToolingDataBinding.getType(XMLBeansToolingDataBinding.java:120)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ProcessorUtil.getType(ProcessorUtil.java:83)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.FaultProcessor.processFault(FaultProcessor.java:124)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.FaultProcessor.process(FaultProcessor.java:54)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.OperationProcessor.process(OperationProcessor.java:67)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.PortTypeProcessor.process(PortTypeProcessor.java:143)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.wsdlDefinitionToJavaModel(WSDLToJavaProcessor.java:88)

           at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.process(WSDLToJavaProcessor.java:60)

           at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:197)

           at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:232)

           ... 22 more

       

       

      I'm trying to attach a zip file (fuse esb cxf-wsdl-first adapted with my wsdl and schemas ) but it's complaining is too large so I'm just attaching the pom.xml.

       

      Any help will be greatly appreciated since I tried everything and I'm stuck without any idea what is wrong.

       

      Thanks,

       

      -Marcel

        • 1. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
          Torsten Mielke Apprentice

          Can you run a mvn clean on your testcase and see if it reduces the size so that you can attach it here? A testcase would certainly be very useful.

           

          Edited by: tmielke on Feb 24, 2009 10:59 AM

          • 2. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
            Marcel Casado Novice

            Hi,

             

            I did run clean before I zipped but it has a large number of schemas. The size is 1.2 M. Is there other way I can send you the testcase ?.

             

            -Marcel

            • 3. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
              Torsten Mielke Apprentice

              Can you send your testcase directly to Torsten.Mielke@progress.com please? I will then look into it.

              • 4. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
                Torsten Mielke Apprentice

                Thanks for your testcase. I can see the same problem here also when trying a different version of that plugin.

                Not sure about the root cause yet but perhaps some schema includes do not work correctly.

                 

                A workaround for the time being is to run mvn -e -X install as it outputs the exact wsdl2java command.

                In my case it is:

                wsdl2java -verbose -d c:\Temp\TestCases\Forum\cxf-wsdl-first\wsdl-first-cxfse-su\target\jaxws -db xmlbeans -classdir c:\Temp\TestCases\Forum\cxf-wsdl-first\wsdl-first-cxfse-su\target/generated/classes -keep -impl file:/c:/Temp/TestCases/Forum/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wcs1_1_2.wsdl

                 

                 

                When running the command manually it works fine.

                I will try to dig deeper.

                • 5. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
                  Torsten Mielke Apprentice

                  From what I can see there are errors in your xsd files. If you run the schema validator against the top level wsdl file:

                  wsdl2java -validate -verbose file:/c:/Temp/TestCases/Forum/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wcs1_1_2.wsdl

                   

                  it will result in an error:

                  WSDLToJava Error: Thrown by JAXB : Two declarations cause a collision in the ObjectFactory class.

                   

                  By attaching a debugger against wsdl2java I could pin-point it down to a couple of definitions in defaultStyle.xsd

                   

                   

                  but after having changed these, there are more errors reported in different schema files.

                   

                  I highly suggest you get your set of wsdl and schema files being successfully validated by wsdl2java before moving on.

                   

                  I attach the modified defaultStyle.xsd, see comments starting with tmielke for any changes made.

                  • 6. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
                    Torsten Mielke Apprentice

                    Some more information about the not very descriptive SaxParseException2 is available at

                    https://jaxb.dev.java.net/guide/Dealing_with_errors.html

                    • 7. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
                      Marcel Casado Novice

                      First give you thanks for looking into it Torsten.

                       

                      I tried myself the cxf wsdl2java command line utility before and it runs ok with xmlbeans binding but the binding java code does not compile since it creates methods with the same signature in some classes due to some elements on the schema and the way xmlbeans creates the naming of this elements (like for "pos" element  you get a getPosList() if several are allowed and the same method for an element called posList ). Here is the need to generate the binding classes with xmlbeans plugin and specify the xsdconfig file that fixes the problem first since I can not specify the xsdconfig file in the cxf codegenerator plugin.

                       

                      So I ran an experiment generating first the xmlbeans binding using the xmlbeans plugin and then running cxf wsdl2java command line tool :

                       

                      ./wsdl2java  -db xmlbeans -server -impl -keep -ant -verbose  -validate -d /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/jaxws   -classdir  /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/target/generated/classes  /Users/marcel/fuse_wcs/cxf-wsdl-first/wsdl-first-cxfse-su/src/main/resources/wcs1_1_2.wsdl

                       

                      And this worked fine, the impl stubs were generated. I tried to add -compile also but I ran into out memory .

                       

                      But in the medium term we want the ability to run this using maven and the xmlbeans and cxf codegen (wsdl2java) plugins .

                       

                      Edited by: marcelcasado on Feb 26, 2009 4:28 PM

                       

                      Edited by: marcelcasado on Feb 27, 2009 4:51 PM

                      • 8. Re: CXF wsdl2java maven plugin with  xmlbeans databinding problem
                        Marcel Casado Novice

                        First say the schemas are third party so we can not mess with them a lot.

                         

                        We are aware of this problems in those schemas and jaxb but I will say that in this specific case the problem is in the way that jaxb is able to create the bindings for elements with similar names but not identical. The schemas validate well with Xerces in the Oxygen IDE for example. I will say the schemas does not follow the best practices in this case but they are valid schemas. Xmlbeans does not has this problem with this since it detects it an generates FeatureStyleDocument.java and FeatureStyleDocument2.java  but as I mentioned in my previous post it has others hence the need to use a xsdconfig file to amend them.

                         

                        Attached a custom binding file to fix the jaxb problems of similar elements without modifying the schemas.

                         

                        With jaxb and the custom data binding file the maven codegen plugin works great but I have the requirement to use xmlbeans instead.

                         

                        Edited by: marcelcasado on Feb 26, 2009 4:24 PM