wadl2java fails with NullPointerException if status codes of multiple response elements are not in ascending numerical order ----------------------------------------------------------------------------------------------------------------------------
Key: CXF-3759 URL: https://issues.apache.org/jira/browse/CXF-3759 Project: CXF Issue Type: Bug Affects Versions: 2.4.2 Reporter: Oliver Jelinski Priority: Minor Strangely, if I have the status codes in the response not in ascending order in the wadl-document, wadl2java fails with NPE. For example the following works correctly: <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd" > <resources base="http://localhost:9900/MyService"> <resource path="/MyResource" id="my.Resource"> <method name="GET" id="putSomething"> <request /> <response status="200" /> <response status="400" /> </method> </resource> </resources> </application> ... while the following doesn't: <?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd" > <resources base="http://localhost:9900/MyService"> <resource path="/MyResource" id="my.Resource"> <method name="GET" id="putSomething"> <request /> <response status="400" /> <response status="200" /> </method> </resource> </resources> </application> ... but throws the following exception: [ERROR] Failed to execute goal org.apache.cxf:cxf-wadl2java-plugin:2.4.2:wadl2java (generate-sources) on project XXX: java.lang.NullPointerException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-wadl2java-plugin:2.4.2:wadl2java (generate-sources) on project XXX: java.lang.NullPointerException 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:319) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534) 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: java.lang.NullPointerException at org.apache.cxf.maven_plugin.wadlto.AbstractCodeGeneratorMojo.callCodeGenerator(AbstractCodeGeneratorMojo.java:458) at org.apache.cxf.maven_plugin.wadlto.WADL2JavaMojo.execute(WADL2JavaMojo.java:101) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ... 19 more Caused by: org.apache.cxf.tools.common.ToolException: java.lang.NullPointerException at org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.execute(JAXRSContainer.java:75) at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) at org.apache.cxf.tools.wadlto.WADLToJava.run(WADLToJava.java:65) at org.apache.cxf.tools.wadlto.WADLToJava.run(WADLToJava.java:57) at org.apache.cxf.maven_plugin.wadlto.AbstractCodeGeneratorMojo.callCodeGenerator(AbstractCodeGeneratorMojo.java:455) ... 22 more Caused by: java.lang.NullPointerException at org.apache.cxf.helpers.DOMUtils.getChildrenWithName(DOMUtils.java:341) at org.apache.cxf.jaxrs.ext.codegen.SourceGenerator.writeResponseType(SourceGenerator.java:598) at org.apache.cxf.jaxrs.ext.codegen.SourceGenerator.writeResourceMethod(SourceGenerator.java:505) at org.apache.cxf.jaxrs.ext.codegen.SourceGenerator.writeMethods(SourceGenerator.java:416) at org.apache.cxf.jaxrs.ext.codegen.SourceGenerator.writeResourceClass(SourceGenerator.java:331) at org.apache.cxf.jaxrs.ext.codegen.SourceGenerator.generateResourceClasses(SourceGenerator.java:208) at org.apache.cxf.jaxrs.ext.codegen.SourceGenerator.generateSource(SourceGenerator.java:173) at org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.processWadl(JAXRSContainer.java:128) at org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.execute(JAXRSContainer.java:58) at org.apache.cxf.tools.wadlto.jaxrs.JAXRSContainer.execute(JAXRSContainer.java:67) ... 26 more -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira