[ 
https://issues.apache.org/jira/browse/CXF-6874?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Colm O hEigeartaigh resolved CXF-6874.
--------------------------------------
    Resolution: Fixed

NPE is already fixed

> NPE During Code Generation By Maven Plug-In If Name Collision
> -------------------------------------------------------------
>
>                 Key: CXF-6874
>                 URL: https://issues.apache.org/jira/browse/CXF-6874
>             Project: CXF
>          Issue Type: Bug
>          Components: Build system
>    Affects Versions: 3.1.6
>            Reporter: Scott Pedigo
>            Priority: Major
>
> NPE if, in an XSD for a web service, types for the input and the output have 
> elements with the same name and base type, but not the same restrictions 
> (e.g. string type, but with min and max length defined for the input element, 
> whereas just plain string for the output element).
> See the elements {{businessRelationshipId}}, {{title}}, and 
> {{sourceSessionId}} for example, in the following:
> {code:title=Example XSD Which Causes NPE}
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema 
>       xmlns:xsd                               = 
> "http://www.w3.org/2001/XMLSchema";
>       xmlns:tns                               = 
> "http://www.ubs.com/PrinterBasket/V1";
>       targetNamespace                 = "http://www.ubs.com/PrinterBasket/V1";
>       >
>       <!-- PrinterBasket v1.1.5 WSDL - 25.02.2013 -->
>       <xsd:include schemaLocation="ReturnCode.xsd" />
>       
>       <xsd:complexType name="GetBasketItemInformation">
>         <xsd:sequence>    
>                       <xsd:element name="businessRelationshipId" 
> minOccurs="1" maxOccurs="1">
>                 <xsd:annotation>
>                     <xsd:documentation>Standard UBS identifier for a business 
> relationship. Alphanumeric.</xsd:documentation>
>                 </xsd:annotation>
>                 <xsd:simpleType>
>                                       <xsd:restriction base="xsd:string">
>                                               <xsd:minLength value="0" />
>                                               <xsd:maxLength value="16" />
>                                       </xsd:restriction>
>                               </xsd:simpleType>
>                       </xsd:element> 
>                       <xsd:element name="title" minOccurs="1" maxOccurs="1">
>                         <xsd:annotation>
>                             <xsd:documentation></xsd:documentation>
>                         </xsd:annotation>
>                         <xsd:simpleType>
>                             <xsd:restriction base="xsd:string">
>                                 <xsd:minLength value="1" />
>                                 <xsd:maxLength value="100" />
>                             </xsd:restriction>
>                         </xsd:simpleType>
>                     </xsd:element>
>                         <xsd:element name="sourceProcess" minOccurs="1" 
> maxOccurs="1">
>                         <xsd:simpleType>
>                             <xsd:restriction base="xsd:string">
>                                 <xsd:minLength value="1" />
>                                 <xsd:maxLength value="100" />
>                             </xsd:restriction>
>                         </xsd:simpleType>
>                     </xsd:element>
>                         <xsd:element name="sourceBusinessSessionId" 
> minOccurs="0" maxOccurs="1">
>                         <xsd:simpleType>
>                             <xsd:restriction base="xsd:string">
>                                 <xsd:minLength value="1" />
>                                 <xsd:maxLength value="50" />
>                             </xsd:restriction>
>                         </xsd:simpleType>
>                     </xsd:element>                       
>         </xsd:sequence>
>       </xsd:complexType>
>       <xsd:element name="getBasketItemInformation" 
> type="tns:GetBasketItemInformation" />
>       <xsd:complexType name="GetBasketItemInformationResponse">
>               <xsd:annotation>
>                       <xsd:documentation>
>                               <![CDATA[
> <p><b>ReturnCodes:</b>
> </p>
> <p>Type I (Information):
> </p>
> <p>Type W (Warning):
> </p>
> <p>Type E (Error):
> </p>
> <p>Type S (Severe):
> </p>
>                               ]]>
>                       </xsd:documentation>
>               </xsd:annotation>
>               <xsd:sequence>
>                       <xsd:element name="businessRelationshipId" 
> type="xsd:string" minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="title" type="xsd:string" 
> minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="sourceBusinessSessionId" 
> type="xsd:string" minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="dispatchStatus" type="xsd:string" 
> minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="dispatchCount" type="xsd:int" 
> minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="dispatchDate" type="xsd:date" 
> minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="dispatchGPN" type="xsd:string" 
> minOccurs="1" maxOccurs="1" />
>                       <xsd:element name="purpose" type="xsd:string" 
> minOccurs="1" maxOccurs="1" />
>                       
>             <xsd:element name="rc" type="tns:ReturnCode" minOccurs="0" 
> maxOccurs="10" />
>               </xsd:sequence>
>       </xsd:complexType>
>       <xsd:element name="getBasketItemInformationResponse" 
> type="tns:GetBasketItemInformationResponse" />
> </xsd:schema>
> {code}
> {code:title=Console Output From Maven Build With NPE}
> [ERROR] Failed to execute goal 
> org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java (genContractWS) on project 
> HPC_IMCLocalAdapterCHDocBasket: Execution genContractWS of goal 
> org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java failed: 
> java.lang.NullPointerException -> [Help 1] 
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute 
> goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java (genContractWS) on 
> project HPC_IMCLocalAdapterCHDocBasket: Execution genContractWS of goal 
> org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java failed: 
> java.lang.NullPointerException 
> at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
>  
> 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:57) 
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  
> at java.lang.reflect.Method.invoke(Method.java:606) 
> 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.PluginExecutionException: Execution 
> genContractWS of goal org.apache.cxf:cxf-codegen-plugin:3.1.6:wsdl2java 
> failed: java.lang.NullPointerException 
> at 
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
>  
> 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.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:424)
>  
> at 
> org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103) 
> at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113) 
> at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86) 
> at 
> org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.generate(WSDL2JavaMojo.java:415)
>  
> at 
> org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:260)
>  
> at 
> org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:512)
>  
> at 
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
>  
> ... 20 more 
> Caused by: java.lang.NullPointerException 
> at 
> org.apache.cxf.tools.wsdlto.frontend.jaxws.validator.WrapperStyleNameCollisionValidator.isValidOperation(WrapperStyleNameCollisionValidator.java:170)
>  
> at 
> org.apache.cxf.tools.wsdlto.frontend.jaxws.validator.WrapperStyleNameCollisionValidator.checkNameCollision(WrapperStyleNameCollisionValidator.java:62)
>  
> at 
> org.apache.cxf.tools.wsdlto.frontend.jaxws.validator.WrapperStyleNameCollisionValidator.isValid(WrapperStyleNameCollisionValidator.java:55)
>  
> at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.validate(WSDLToJavaContainer.java:738)
>  
> at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:280)
>  
> at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:165)
>  
> at 
> org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:416)
>  
> ... 27 more 
> [ERROR] 
> [ERROR] Re-run Maven using the -X switch to enable full debug logging. 
> [ERROR] 
> [ERROR] For more information about the errors and possible solutions, please 
> read the following articles: 
> [ERROR] [Help 1] 
> http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 
> [ERROR] 
> [ERROR] After correcting the problems, you can resume the build with the 
> command 
> [ERROR] mvn <goals> -rf :HPC_IMCLocalAdapterCHDocBasket 
> {code}
> {code:title=public class WrapperStyleNameCollisionValidator}
>             if (output != null) {
>                 List<WrapperElement> els = 
> ProcessorUtil.getWrappedElement(context, output.getElementQName());
>                 if (els.size() > 1) {
>                     for (WrapperElement element : els) {
>                         String mappedName = mapElementName(operation,
>                                                            
> operation.getUnwrappedOperation().getOutput(),
>                                                            element);
> *mappedName is null here*
> ===>               if (names.containsKey(mappedName)
>                             &&  !(names.get(mappedName) == 
> element.getSchemaTypeName()
>                                 || 
> names.get(mappedName).equals(element.getSchemaTypeName()))) {
>                             handleErrors(names.get(mappedName), element);
>                             return false;
>                         } else {
>                             names.put(mappedName, 
> element.getSchemaTypeName());
>                         }
>                     }
>                 }
>             }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to