2 Replies Latest reply on May 7, 2011 1:22 AM by sterlingsmith

    cxf NullPointerException org.apache.cxf.wsdl11.WSDLServiceFactory

    sterlingsmith

      Hi All,

       

      I'm trying to get a soap client using the cxf / spring framework working; works great from within the Eclipse IDE.

       

      After building it for external use however, I get the following (debug dump follows):

       

      I'd appreciate any clues...could the WSDL be causing this?

       

      -


      DEBUG BEGIN

      -


      May 3, 2011 8:15:07 PM com.novell.iwm.csb.dhcp.DhcpScopeAdd main

      May 3, 2011 8:15:07 PM org.springframework.context.support.AbstractApplicationCo

      ntext prepareRefresh

      INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@781f6226: start

      up date Tue May 03 20:15:07 EDT 2011; root of context hierarchy

      May 3, 2011 8:15:07 PM org.apache.cxf.bus.spring.BusApplicationContext getConfig

      Resources

      INFO: Loaded configuration file cxf.xml.

      May 3, 2011 8:15:07 PM org.springframework.beans.factory.xml.XmlBeanDefinitionRe

      ader loadBeanDefinitions

      INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xm

      l]

      May 3, 2011 8:15:07 PM org.springframework.beans.factory.xml.XmlBeanDefinitionRe

      ader loadBeanDefinitions

      INFO: Loading XML bean definitions from class path resource http://cxf.xml/

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.xml.XmlBeanDefinitionRe

      ader loadBeanDefinitions

      INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xm

      l]

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.support.DefaultListable

      BeanFactory registerBeanDefinition

      INFO: Overriding bean definition for bean 'cxf': replacing [Generic bean: class

      http://org.apache.cxf.bus.spring.springbus/; scope=; abstract=false; lazyInit=false; a

      utowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factory

      BeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=sh

      utdown; defined in class path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]] with [Generic bea

      n: class http://org.apache.cxf.bus.spring.springbus/; scope=; abstract=false; lazyInit

      =false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false

      ; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMeth

      odName=shutdown; defined in class path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]]

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.support.DefaultListable

      BeanFactory registerBeanDefinition

      INFO: Overriding bean definition for bean 'org.apache.cxf.bus.spring.BusWiringBe

      anFactoryPostProcessor': replacing [Generic bean: class [org.apache.cxf.bus.spri

      ng.BusWiringBeanFactoryPostProcessor]; scope=; abstract=false; lazyInit=false; a

      utowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factory

      BeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nu

      ll; defined in class path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]] with [Generic bean: c

      lass http://org.apache.cxf.bus.spring.buswiringbeanfactorypostprocessor/; scope=; abst

      ract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate

      =true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNa

      me=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cx

      f.xml]]

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.support.DefaultListable

      BeanFactory registerBeanDefinition

      INFO: Overriding bean definition for bean 'org.apache.cxf.bus.spring.Jsr250BeanP

      ostProcessor': replacing [Generic bean: class [org.apache.cxf.bus.spring.Jsr250B

      eanPostProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; depen

      dencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; facto

      ryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class

      path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]] with [Generic bean: class [org.apache.cxf

      .bus.spring.Jsr250BeanPostProcessor]; scope=; abstract=false; lazyInit=false; au

      towireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryB

      eanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=nul

      l; defined in class path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]]

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.support.DefaultListable

      BeanFactory registerBeanDefinition

      INFO: Overriding bean definition for bean 'org.apache.cxf.bus.spring.BusExtensio

      nPostProcessor': replacing [Generic bean: class [org.apache.cxf.bus.spring.BusEx

      tensionPostProcessor]; scope=; abstract=false; lazyInit=false; autowireMode=0; d

      ependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; f

      actoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in c

      lass path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]] with [Generic bean: class [org.apache

      .cxf.bus.spring.BusExtensionPostProcessor]; scope=; abstract=false; lazyInit=fal

      se; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; fa

      ctoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodNa

      me=null; defined in class path resource http://META-INF/cxf/cxf.xml|http://meta-inf/cxf/cxf.xml]]

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.xml.XmlBeanDefinitionRe

      ader loadBeanDefinitions

      INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-se

      rvlet.xml]

      May 3, 2011 8:15:08 PM org.springframework.beans.factory.support.DefaultListable

      BeanFactory preInstantiateSingletons

      INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.

      DefaultListableBeanFactory@7162e295: defining beans [cxf,org.apache.cxf.bus.spri

      ng.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostPro

      cessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor]; root of factory hie

      rarchy

      May 3, 2011 8:15:08 PM com.novell.iwm.csb.dhcp.DhcpScopeAdd main

      SEVERE: An exception occurred, exiting [Ljava.lang.StackTraceElement;@68302e67

      java.lang.NullPointerException

      at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.ja

      va:91)

      at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203

      )

      at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)

      at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderI

      mpl.java:90)

      at javax.xml.ws.Service.<init>(Unknown Source)

      at com.novell.iwm.csb.cmos.CmosWebServices.<init>(CmosWebServices.java:5

      4)

      at com.novell.iwm.csb.dhcp.DhcpScopeAdd.main(DhcpScopeAdd.java:143)

      -


      DEBUG END

      -


      -


      POM BEGIN

      -


       

      $/src/main/java</sourceRoot>                             <wsdlOptions>                                 <wsdlOption>                                     <wsdl>$/src/main/wsdl/CmosWebServices.wsdl$/src/main/resources/bindings.xml

      -


      POM END

      -


      -


      CXF.XML BEGIN

      -


       

      -


      CXF.XML END

      -


      NOTE: I did have the cxf-soap exception XML in the above file, but I received an informational message that it was deprecated on the version I was using so I removed it.

       

      -


      BINDINGS.XML BEGIN

      -


      <jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"

              xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">

              <jaxb:globalBindings mapSimpleTypeDef="true">

                      <xjc:generateElementProperty>false</xjc:generateElementProperty>

              </jaxb:globalBindings>

      </jaxb:bindings>

      -


      BINDINGS.XML END

      -


      NOTE: The wsdl I am using wsdl2java was on Apache Axis, and was generating JAXBElement on the return calls, so this addresses that.

       

      -


      CODE SNIPPET THAT CAUSES PROBLEM BEGIN

      -


      CmosWebServices cmosService = new CmosWebServices();

      CmosWebServicesPortType cmosSoap = cmosService.getCmosWebServicesHttpSoap11Endpoint();

      -


      CODE SNIPPET THAT CAUSES PROBLEM END

      -


       

        • 1. Re: cxf NullPointerException org.apache.cxf.wsdl11.WSDLServiceFactory
          njiang

          Hi,

           

          You need to pass the wsdl URL into the CmosWebServices construction.

          If you take a look at the CmosWebServices, you will find the default WSDL URL is using absolut path. When you wrap the classes into jar for external user to use, you will face the default WSDL URL can't find any WSDL issue.

           

          Willem

          • 2. Re: cxf NullPointerException org.apache.cxf.wsdl11.WSDLServiceFactory
            sterlingsmith

            Yes, I did see that, and it's actually a follow up question.

             

            I am currently getting this problem running this on the same machine outside of Eclipse. It runs with a Run configuration but after packaging this with Maven (mvn assembly:assembly) the problem occurs running this on the same machine (so the file exists at run time). I suspect the problem you are indicating would be my NEXT problem after this worked running this outside of Eclipse and I moved it to the target machine.

             

            Any other ideas?

             

            (assuming I have another idea for my problem, here's my follow up question to the absolute path)

             

            BTW, what are best practices for making sure the Wsdl is available at runtime and/or idea for packaging and deployment (it's final resting place is a server outside of the Fuse ESB)? The generated wsdl path is a file path; wouldn't it be better to use a URL path where the service actually resides? If so, can I simply use a http path? I have to include the wsdl in my project as a file; perhaps I need a technique for referencing a target wsdl for wsdl2java using an external location?