You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2013/08/01 22:26:34 UTC
Re: CXF XJC Maven Plugin (xsdtojava) Maven plugin usage
The m2eclipse integration stuff is a complete pain. The API for passing warnings/messages back to Eclipse REQUIRES a File object. If you use a classpath URL or if a schema imports something from an http url or something, it will NPE as we don't have a File object. For the cxf-codegen-plugin, I actually create a "fake" File object to pass that wrappers the appropriate URL. Guess I need to copy that over to the xjc plugin. :-(
Dan
On Jul 26, 2013, at 4:17 AM, Julio Carlos Barrera Juez <ju...@i2cat.net> wrote:
> I have created a bug of the failure
> https://issues.apache.org/jira/browse/CXF-5158. Besides I have created a
> bug related to the documentation
> https://issues.apache.org/jira/browse/CXF-5160. I have linked both.
>
>
> On 25 July 2013 15:14, Jason Pell <ja...@pellcorp.com> wrote:
>
>> Can you raise a jira for this. Explaining that the docs show class path
>> urls that cause the npe but file urls work. Could be a docs or code bug.
>> On 25/07/2013 11:09 PM, "Julio Carlos Barrera Juez" <
>> juliocarlos.barrera@i2cat.net> wrote:
>>
>>> It worked!! I used ${basedir}/src/main/resources/ and it worked.
>>>
>>> Maybe the documentation should be aware of this issue. Avoid using
>>> "classpath:" URIs.
>>>
>>> Thank you very much!
>>>
>>>
>>> On 25 July 2013 15:00, Jason Pell <ja...@pellcorp.com> wrote:
>>>
>>>> Can you try referencing the XSD via absolute path rather than a
>>> classpath,
>>>> just for a test.
>>>>
>>>> You can use something like:
>>>>
>>>> ${basedir}/src/main/resources/schemas/document.xsd
>>>>
>>>> I see the exact kind of error reported for the codegen plugin in the
>>> past.
>>>> All the examples i can see don't use classpath:
>>>>
>>>>
>>>> On Thu, Jul 25, 2013 at 10:18 PM, Marco Westermann <
>> MarWestermann@gmx.de
>>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I don't know why you get the error. But I also use a plugin to
>> generate
>>>>> java classes from xsd. Here is my plugin-config from pom.xml:
>>>>>
>>>>> <plugin>
>>>>> <groupId>org.codehaus.mojo</**groupId>
>>>>> <artifactId>jaxb2-maven-**plugin</artifactId>
>>>>> <version>1.3.1</version>
>>>>> <executions>
>>>>> <execution>
>>>>> <id>xjc</id>
>>>>> <phase>generate-sources</**phase>
>>>>> <goals>
>>>>> <goal>xjc</goal>
>>>>> </goals>
>>>>> </execution>
>>>>> </executions>
>>>>> </plugin>
>>>>>
>>>>>
>>>>> the xsd's have to be under src/main/xsd/
>>>>>
>>>>> and the generated classes are under target/generated-sources/jaxb
>>>>>
>>>>> hope that helps you as well.
>>>>>
>>>>> regards, Marco
>>>>>
>>>>> Am 25.07.2013 14:01, schrieb Julio Carlos Barrera Juez:
>>>>>
>>>>> I have changed the version to 2.6.2 and I'm getting the same issue:
>>>>>>
>>>>>> [ERROR] Failed to execute goal
>>>>>> org.apache.cxf:cxf-xjc-plugin:**2.6.2:xsdtojava (generate-sources)
>> on
>>>>>> project
>>>>>> org.opennaas.extensions.**juniper.servicecatalog: null:
>>>>>> MojoExecutionException: NullPointerException -> [Help 1]
>>>>>> org.apache.maven.lifecycle.**LifecycleExecutionException: Failed to
>>>>>> execute
>>>>>> goal org.apache.cxf:cxf-xjc-plugin:**2.6.2:xsdtojava
>>> (generate-sources)
>>>>>> on
>>>>>> project org.opennaas.extensions.**juniper.servicecatalog: null
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>> MojoExecutor.java:217)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>> MojoExecutor.java:153)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>> MojoExecutor.java:145)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.**LifecycleModuleBuilder.**
>>>>>> buildProject(**LifecycleModuleBuilder.java:**84)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.**LifecycleModuleBuilder.**
>>>>>> buildProject(**LifecycleModuleBuilder.java:**59)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.LifecycleStarter.**
>>>>>> singleThreadedBuild(**LifecycleStarter.java:183)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.LifecycleStarter.**
>>>>>> execute(LifecycleStarter.java:**161)
>>>>>> at
>> org.apache.maven.DefaultMaven.**doExecute(DefaultMaven.java:**320)
>>>>>> at org.apache.maven.DefaultMaven.**execute(DefaultMaven.java:156)
>>>>>> at org.apache.maven.cli.MavenCli.**execute(MavenCli.java:537)
>>>>>> at org.apache.maven.cli.MavenCli.**doMain(MavenCli.java:196)
>>>>>> at org.apache.maven.cli.MavenCli.**main(MavenCli.java:141)
>>>>>> 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:597)
>>>>>> at
>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>> launchEnhanced(Launcher.java:**290)
>>>>>> at
>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>> launch(Launcher.java:230)
>>>>>> at
>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>> mainWithExitCode(Launcher.**java:409)
>>>>>> at org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>> main(Launcher.java:352)
>>>>>> Caused by: org.apache.maven.plugin.**MojoExecutionException
>>>>>> at
>>>>>> org.apache.cxf.maven_plugin.**AbstractXSDToJavaMojo.execute(**
>>>>>> AbstractXSDToJavaMojo.java:**320)
>>>>>> at org.apache.cxf.maven_plugin.**XSDToJavaMojo.execute(**
>>>>>> XSDToJavaMojo.java:42)
>>>>>> at
>>>>>> org.apache.maven.plugin.**DefaultBuildPluginManager.**executeMojo(**
>>>>>> DefaultBuildPluginManager.**java:101)
>>>>>> at
>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>> MojoExecutor.java:209)
>>>>>> ... 19 more
>>>>>> Caused by: java.lang.NullPointerException
>>>>>> at
>>>>>> org.sonatype.plexus.build.**incremental.**DefaultBuildContext.**
>>>>>> getMessage(**DefaultBuildContext.java:88)
>>>>>> at
>>>>>> org.sonatype.plexus.build.**incremental.**DefaultBuildContext.**
>>>>>> addMessage(**DefaultBuildContext.java:110)
>>>>>> at
>>>>>>
>>> org.apache.cxf.maven_plugin.**AbstractXSDToJavaMojo$**Listener.error(**
>>>>>> AbstractXSDToJavaMojo.java:**149)
>>>>>> at
>>>>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>>>>> ErrorReceiverFilter.java:77)
>>>>>> at
>>>>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>>>>> ErrorReceiverFilter.java:77)
>>>>>> at
>>>>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>>>>> ErrorReceiverFilter.java:77)
>>>>>> at
>>>>>> com.sun.org.apache.xerces.**internal.jaxp.validation.**
>>>>>> XMLSchemaFactory.newSchema(**XMLSchemaFactory.java:233)
>>>>>> at
>>>>>> com.sun.tools.xjc.reader.**xmlschema.parser.**
>>>>>> SchemaConstraintChecker.check(**SchemaConstraintChecker.java:**101)
>>>>>> at com.sun.tools.xjc.ModelLoader.**loadXMLSchema(ModelLoader.**
>>>>>> java:357)
>>>>>> at com.sun.tools.xjc.ModelLoader.**load(ModelLoader.java:167)
>>>>>> at com.sun.tools.xjc.ModelLoader.**load(ModelLoader.java:113)
>>>>>> at com.sun.tools.xjc.Driver.run(**Driver.java:313)
>>>>>> at
>>>>>> org.apache.cxf.maven_plugin.**AbstractXSDToJavaMojo.execute(**
>>>>>> AbstractXSDToJavaMojo.java:**307)
>>>>>> ... 22 more
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 25 July 2013 12:53, Jason Pell <jp...@apache.org> wrote:
>>>>>>
>>>>>> Can you try this again using 2.6.2 version of the plugin
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Jul 25, 2013 at 6:45 PM, Julio Carlos Barrera Juez <
>>>>>>> juliocarlos.barrera@i2cat.net> wrote:
>>>>>>>
>>>>>>> I have just executed the goals with MAven debug option (-X) and
>> this
>>>> is
>>>>>>>>
>>>>>>> the
>>>>>>>
>>>>>>>> output:
>>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>>> MojoExecutor.java:217)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>>> MojoExecutor.java:153)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>>> MojoExecutor.java:145)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.**LifecycleModuleBuilder.**
>>>>>>> buildProject(**LifecycleModuleBuilder.java:**84)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.**LifecycleModuleBuilder.**
>>>>>>> buildProject(**LifecycleModuleBuilder.java:**59)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.LifecycleStarter.**
>>>>>>> singleThreadedBuild(**LifecycleStarter.java:183)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.LifecycleStarter.**
>>>>>>> execute(LifecycleStarter.java:**161)
>>>>>>>
>>>>>>>> at
>>> org.apache.maven.DefaultMaven.**doExecute(DefaultMaven.java:**320)
>>>>>>>> at
>> org.apache.maven.DefaultMaven.**execute(DefaultMaven.java:156)
>>>>>>>> at org.apache.maven.cli.MavenCli.**execute(MavenCli.java:537)
>>>>>>>> at org.apache.maven.cli.MavenCli.**doMain(MavenCli.java:196)
>>>>>>>> at org.apache.maven.cli.MavenCli.**main(MavenCli.java:141)
>>>>>>>> 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:597)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>>> launchEnhanced(Launcher.java:**290)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>>> launch(Launcher.java:230)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>>> mainWithExitCode(Launcher.**java:409)
>>>>>>>
>>>>>>>> at
>>>>>>>> org.codehaus.plexus.**classworlds.launcher.Launcher.**
>>>>>>>> main(Launcher.java:352)
>>>>>>>> Caused by: org.apache.maven.plugin.**MojoExecutionException
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.cxf.maven_plugin.**AbstractXSDToJavaMojo.execute(**
>>>>>>> AbstractXSDToJavaMojo.java:**320)
>>>>>>>
>>>>>>>> at
>>>>>>>> org.apache.cxf.maven_plugin.**XSDToJavaMojo.execute(**
>>>>>>>> XSDToJavaMojo.java:42)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>> org.apache.maven.plugin.**DefaultBuildPluginManager.**executeMojo(**
>>>>>>> DefaultBuildPluginManager.**java:101)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.maven.lifecycle.**internal.MojoExecutor.execute(**
>>>>>>> MojoExecutor.java:209)
>>>>>>>
>>>>>>>> ... 19 more
>>>>>>>> Caused by: java.lang.NullPointerException
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.sonatype.plexus.build.**incremental.**DefaultBuildContext.**
>>>>>>> getMessage(**DefaultBuildContext.java:88)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.sonatype.plexus.build.**incremental.**DefaultBuildContext.**
>>>>>>> addMessage(**DefaultBuildContext.java:110)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>> org.apache.cxf.maven_plugin.**AbstractXSDToJavaMojo$**Listener.error(*
>>>>>>> *AbstractXSDToJavaMojo.java:**149)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>>>>>> ErrorReceiverFilter.java:77)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>>>>>> ErrorReceiverFilter.java:77)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.tools.xjc.util.**ErrorReceiverFilter.error(**
>>>>>>> ErrorReceiverFilter.java:77)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.org.apache.xerces.**internal.jaxp.validation.**
>>>>>>> XMLSchemaFactory.newSchema(**XMLSchemaFactory.java:233)
>>>>>>>
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.tools.xjc.reader.**xmlschema.parser.**
>>>>>>> SchemaConstraintChecker.check(**SchemaConstraintChecker.java:**101)
>>>>>>>
>>>>>>>> at com.sun.tools.xjc.ModelLoader.**loadXMLSchema(ModelLoader.**
>>>>>>>> java:357)
>>>>>>>> at com.sun.tools.xjc.ModelLoader.**load(ModelLoader.java:167)
>>>>>>>> at com.sun.tools.xjc.ModelLoader.**load(ModelLoader.java:113)
>>>>>>>> at com.sun.tools.xjc.Driver.run(**Driver.java:313)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.cxf.maven_plugin.**AbstractXSDToJavaMojo.execute(**
>>>>>>> AbstractXSDToJavaMojo.java:**307)
>>>>>>>
>>>>>>>> ... 22 more
>>>>>>>>
>>>>>>>> Maybe it could help.
>>>>>>>>
>>>>>>>>
>>>>>>>> On 25 July 2013 09:32, Julio Carlos Barrera Juez <
>>>>>>>> juliocarlos.barrera@i2cat.net> wrote:
>>>>>>>>
>>>>>>>> I want to get Java classes from an XSD document. I want to use
>> CXF
>>>> XJC
>>>>>>>>> Maven Plugin, but I'm experiencing some problems. I have followed
>>> the
>>>>>>>>> documentation here: http://cxf.apache.org/cxf-xjc-**plugin.html<
>>>> http://cxf.apache.org/cxf-xjc-plugin.html>
>>>>>>>>> .
>>>>>>>>>
>>>>>>>>> I have this POM (more or less):
>>>>>>>>>
>>>>>>>>> ...
>>>>>>>>> <plugin>
>>>>>>>>> <groupId>org.apache.cxf</**groupId>
>>>>>>>>> <artifactId>cxf-xjc-plugin</**artifactId>
>>>>>>>>> <version>2.6.1</version>
>>>>>>>>> <executions>
>>>>>>>>> <execution>
>>>>>>>>> <id>generate-sources</id>
>>>>>>>>> <phase>generate-sources</**phase>
>>>>>>>>> <goals>
>>>>>>>>> <goal>xsdtojava</goal>
>>>>>>>>> </goals>
>>>>>>>>> <configuration>
>>>>>>>>> <sourceRoot>${basedir}/target/**generated/src/main/java</**
>>>>>>>>> sourceRoot>
>>>>>>>>> <xsdOptions>
>>>>>>>>> <xsdOption>
>>>>>>>>> <xsd>classpath:/path/to/xsd/**document.xsd</xsd>
>>>>>>>>> <packagename>org.company.**package.whatever</packagename>
>>>>>>>>> </xsdOption>
>>>>>>>>> </xsdOptions>
>>>>>>>>> </configuration>
>>>>>>>>> </execution>
>>>>>>>>> </executions>
>>>>>>>>> </plugin>
>>>>>>>>> ...
>>>>>>>>>
>>>>>>>>> When I execute the goal I'm getting:
>>>>>>>>>
>>>>>>>>> Failed to execute goal
>>>> org.apache.cxf:cxf-xjc-plugin:**2.6.1:xsdtojava
>>>>>>>>> (generate-sources) on project org.company.myproject: null:
>>>>>>>>> MojoExecutionException: NullPointerException -> [Help 1]
>>>>>>>>>
>>>>>>>>> Am I Missing any parameter in the configuration?
>>>>>>>>>
>>>>>>>>>
>>>>>
>>>>
>>>
>>
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com