You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by green804 <gi...@fox.com> on 2007/08/31 02:01:52 UTC

Null Pointer in WSDLServiceFactory

I have this code working in my development environment, but when I employ to
our test environment I'm getting a null pointer.  I'm not sure why this is
happening.  Can someone give me any pointers?  I'm really desperate to find
a solution.

java.lang.NullPointerException
        at
org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:81)
        at
org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:112)
        at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:104)
        at
org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:55)
        at javax.xml.ws.Service.<init>(Service.java:57)
        at com.mysite.services.news.NewsService.<init>(NewsService.java:41)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

>From code:

@WebServiceClient(name = "NewsService", targetNamespace =
"http://services.mysite.com/News", wsdlLocation =
"http://mysite.com/services/NewsService.svc?wsdl")
public class NewsService extends Service {

    private final static URL WSDL_LOCATION;
    private final static QName SERVICE = new
QName("http://services.mysite.com/News", "NewsService");
    private final static QName BasicHttpBinding = new
QName("http://services.mysite.com/News", "basicHttpBinding");
    static {
        URL url = null;
        try {
            url = new
URL("http://mysite.com/services/NewsService.svc?wsdl");
        } catch (MalformedURLException e) {
            System.err.println("Can not initialize the default wsdl from
http://mysite.com/services/NewsService.svc?wsdl");
            // e.printStackTrace();
        }
        WSDL_LOCATION = url;
    }

    public NewsService(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public NewsService() {
        super(WSDL_LOCATION, SERVICE);
    }

    /**
     * 
     * @return
     *     returns BasicHttpBinding
     */
    @WebEndpoint(name = "basicHttpBinding")
    public NewsServiceContract getBasicHttpBinding() {
        return (NewsServiceContract)super.getPort(BasicHttpBinding,
NewsServiceContract.class);
    }


-- 
View this message in context: http://www.nabble.com/Null-Pointer-in-WSDLServiceFactory-tf4357565.html#a12418426
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Null Pointer in WSDLServiceFactory

Posted by green804 <gi...@fox.com>.
You were right.  I changed code to use the
org.apache.cxf.jaxws.JaxWsProxyFactoryBean so I could load the bus.  This
seemed to fix my problems.  Thanks for pointing me in the right direction.



Willem2 wrote:
> 
> Hi,
> 
> I did not find any jaxws:** or the server factory bean in your spring
> configuration file.
> Did you wrap the server factory bean in your
> com.mysite.services.types.ObjectFactory ?
> If so , can you show me the code of the  ObjectFactory ?
> 
> I think you did not load the bus correctly.
> 
> Willem.
> 
> green804 wrote:
>> 
>> I am not currently implementing a bus.  Do I need to do this?  I am using
>> Spring 2.0 and this is running on tomcat.  I've included the Spring
>> context file for this client.  I'm calling a service that's in .NET.
>> 
>> How would I configure this?
>> 
>> <beans xmlns="http://www.springframework.org/schema/beans"
>> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> 	xmlns:jaxws="http://cxf.apache.org/jaxws"
>> 	xsi:schemaLocation="
>> http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
>> 
>>     <import resource="classpath:META-INF/cxf/cxf.xml" />
>> 	<import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"
>> />
>> 	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>> 	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>> 
>>    <bean id="newsServiceClient"
>> class="com.mysite.services.news.NewsService">
>>    </bean>
>>    
>>    <bean id="mysiteObjectFactory"
>> class="com.mysite.services.types.ObjectFactory"></bean>
>> 
>> </beans>
>> 
>> 
>> 
>> 
>> 
>> Willem2 wrote:
>>> 
>>> Hi ,
>>> 
>>>  It looks like the WSDLServiceFactory can 't  get the WSDLManager from 
>>> the bus when you try to create a service model for the client.
>>> 
>>>  public WSDLServiceFactory(Bus b, String url, QName sn) {
>>>         setBus(b);
>>>         try {
>>>             // use wsdl manager to parse wsdl or get cached definition
>>>             definition = 
>>> getBus().getExtension(WSDLManager.class).getDefinition(url);  // The NPE 
>>> is thrown form here
>>>         } catch (WSDLException ex) {
>>>             throw new ServiceConstructionException(new 
>>> Message("SERVICE_CREATION_MSG", LOG), ex);
>>>         }
>>>        
>>>         serviceName = sn;
>>>     }
>>> 
>>> It could be your WSDLManager does not be set to the bus.
>>> Can you tell me how did you initialize the bus?
>>> Did you use the spring configuration or load the bus by other means?
>>> 
>>> Maybe you can set the log level to INFO for more information.
>>> 
>>> 
>>> Willem.
>>> 
>>>    
>>> green804 wrote:
>>>> I have this code working in my development environment, but when I
>>>> employ to
>>>> our test environment I'm getting a null pointer.  I'm not sure why this
>>>> is
>>>> happening.  Can someone give me any pointers?  I'm really desperate to
>>>> find
>>>> a solution.
>>>>
>>>> java.lang.NullPointerException
>>>>         at
>>>> org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:81)
>>>>         at
>>>> org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:112)
>>>>         at
>>>> org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:104)
>>>>         at
>>>> org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:55)
>>>>         at javax.xml.ws.Service.<init>(Service.java:57)
>>>>         at
>>>> com.mysite.services.news.NewsService.<init>(NewsService.java:41)
>>>>         at
>>>> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>>> Method)
>>>>         at
>>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>>
>>>> >From code:
>>>>
>>>> @WebServiceClient(name = "NewsService", targetNamespace =
>>>> "http://services.mysite.com/News", wsdlLocation =
>>>> "http://mysite.com/services/NewsService.svc?wsdl")
>>>> public class NewsService extends Service {
>>>>
>>>>     private final static URL WSDL_LOCATION;
>>>>     private final static QName SERVICE = new
>>>> QName("http://services.mysite.com/News", "NewsService");
>>>>     private final static QName BasicHttpBinding = new
>>>> QName("http://services.mysite.com/News", "basicHttpBinding");
>>>>     static {
>>>>         URL url = null;
>>>>         try {
>>>>             url = new
>>>> URL("http://mysite.com/services/NewsService.svc?wsdl");
>>>>         } catch (MalformedURLException e) {
>>>>             System.err.println("Can not initialize the default wsdl
>>>> from
>>>> http://mysite.com/services/NewsService.svc?wsdl");
>>>>             // e.printStackTrace();
>>>>         }
>>>>         WSDL_LOCATION = url;
>>>>     }
>>>>
>>>>     public NewsService(URL wsdlLocation, QName serviceName) {
>>>>         super(wsdlLocation, serviceName);
>>>>     }
>>>>
>>>>     public NewsService() {
>>>>         super(WSDL_LOCATION, SERVICE);
>>>>     }
>>>>
>>>>     /**
>>>>      * 
>>>>      * @return
>>>>      *     returns BasicHttpBinding
>>>>      */
>>>>     @WebEndpoint(name = "basicHttpBinding")
>>>>     public NewsServiceContract getBasicHttpBinding() {
>>>>         return (NewsServiceContract)super.getPort(BasicHttpBinding,
>>>> NewsServiceContract.class);
>>>>     }
>>>>
>>>>
>>>>   
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Null-Pointer-in-WSDLServiceFactory-tf4357565.html#a12483236
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Null Pointer in WSDLServiceFactory

Posted by Willem2 <ni...@iona.com>.
Hi,

I did not find any jaxws:** or the server factory bean in your spring
configuration file.
Did you wrap the server factory bean in your
com.mysite.services.types.ObjectFactory ?
If so , can you show me the code of the  ObjectFactory ?

I think you did not load the bus correctly.

Willem.

green804 wrote:
> 
> I am not currently implementing a bus.  Do I need to do this?  I am using
> Spring 2.0 and this is running on tomcat.  I've included the Spring
> context file for this client.  I'm calling a service that's in .NET.
> 
> How would I configure this?
> 
> <beans xmlns="http://www.springframework.org/schema/beans"
> 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns:jaxws="http://cxf.apache.org/jaxws"
> 	xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
> 
>     <import resource="classpath:META-INF/cxf/cxf.xml" />
> 	<import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"
> />
> 	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> 	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
> 
>    <bean id="newsServiceClient"
> class="com.mysite.services.news.NewsService">
>    </bean>
>    
>    <bean id="mysiteObjectFactory"
> class="com.mysite.services.types.ObjectFactory"></bean>
> 
> </beans>
> 
> 
> 
> 
> 
> Willem2 wrote:
>> 
>> Hi ,
>> 
>>  It looks like the WSDLServiceFactory can 't  get the WSDLManager from 
>> the bus when you try to create a service model for the client.
>> 
>>  public WSDLServiceFactory(Bus b, String url, QName sn) {
>>         setBus(b);
>>         try {
>>             // use wsdl manager to parse wsdl or get cached definition
>>             definition = 
>> getBus().getExtension(WSDLManager.class).getDefinition(url);  // The NPE 
>> is thrown form here
>>         } catch (WSDLException ex) {
>>             throw new ServiceConstructionException(new 
>> Message("SERVICE_CREATION_MSG", LOG), ex);
>>         }
>>        
>>         serviceName = sn;
>>     }
>> 
>> It could be your WSDLManager does not be set to the bus.
>> Can you tell me how did you initialize the bus?
>> Did you use the spring configuration or load the bus by other means?
>> 
>> Maybe you can set the log level to INFO for more information.
>> 
>> 
>> Willem.
>> 
>>    
>> green804 wrote:
>>> I have this code working in my development environment, but when I
>>> employ to
>>> our test environment I'm getting a null pointer.  I'm not sure why this
>>> is
>>> happening.  Can someone give me any pointers?  I'm really desperate to
>>> find
>>> a solution.
>>>
>>> java.lang.NullPointerException
>>>         at
>>> org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:81)
>>>         at
>>> org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:112)
>>>         at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:104)
>>>         at
>>> org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:55)
>>>         at javax.xml.ws.Service.<init>(Service.java:57)
>>>         at
>>> com.mysite.services.news.NewsService.<init>(NewsService.java:41)
>>>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>>         at
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>
>>> >From code:
>>>
>>> @WebServiceClient(name = "NewsService", targetNamespace =
>>> "http://services.mysite.com/News", wsdlLocation =
>>> "http://mysite.com/services/NewsService.svc?wsdl")
>>> public class NewsService extends Service {
>>>
>>>     private final static URL WSDL_LOCATION;
>>>     private final static QName SERVICE = new
>>> QName("http://services.mysite.com/News", "NewsService");
>>>     private final static QName BasicHttpBinding = new
>>> QName("http://services.mysite.com/News", "basicHttpBinding");
>>>     static {
>>>         URL url = null;
>>>         try {
>>>             url = new
>>> URL("http://mysite.com/services/NewsService.svc?wsdl");
>>>         } catch (MalformedURLException e) {
>>>             System.err.println("Can not initialize the default wsdl from
>>> http://mysite.com/services/NewsService.svc?wsdl");
>>>             // e.printStackTrace();
>>>         }
>>>         WSDL_LOCATION = url;
>>>     }
>>>
>>>     public NewsService(URL wsdlLocation, QName serviceName) {
>>>         super(wsdlLocation, serviceName);
>>>     }
>>>
>>>     public NewsService() {
>>>         super(WSDL_LOCATION, SERVICE);
>>>     }
>>>
>>>     /**
>>>      * 
>>>      * @return
>>>      *     returns BasicHttpBinding
>>>      */
>>>     @WebEndpoint(name = "basicHttpBinding")
>>>     public NewsServiceContract getBasicHttpBinding() {
>>>         return (NewsServiceContract)super.getPort(BasicHttpBinding,
>>> NewsServiceContract.class);
>>>     }
>>>
>>>
>>>   
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Null-Pointer-in-WSDLServiceFactory-tf4357565.html#a12436647
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Null Pointer in WSDLServiceFactory

Posted by green804 <gi...@fox.com>.
I am not currently implementing a bus.  Do I need to do this?  I am using
Spring 2.0 and this is running on tomcat.  I've included the Spring context
file for this client.  I'm calling a service that's in .NET.

How would I configure this?

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

   <bean id="newsServiceClient"
class="com.mysite.services.news.NewsService">
   </bean>
   
   <bean id="mysiteObjectFactory"
class="com.mysite.services.types.ObjectFactory"></bean>

</beans>





Willem2 wrote:
> 
> Hi ,
> 
>  It looks like the WSDLServiceFactory can 't  get the WSDLManager from 
> the bus when you try to create a service model for the client.
> 
>  public WSDLServiceFactory(Bus b, String url, QName sn) {
>         setBus(b);
>         try {
>             // use wsdl manager to parse wsdl or get cached definition
>             definition = 
> getBus().getExtension(WSDLManager.class).getDefinition(url);  // The NPE 
> is thrown form here
>         } catch (WSDLException ex) {
>             throw new ServiceConstructionException(new 
> Message("SERVICE_CREATION_MSG", LOG), ex);
>         }
>        
>         serviceName = sn;
>     }
> 
> It could be your WSDLManager does not be set to the bus.
> Can you tell me how did you initialize the bus?
> Did you use the spring configuration or load the bus by other means?
> 
> Maybe you can set the log level to INFO for more information.
> 
> 
> Willem.
> 
>    
> green804 wrote:
>> I have this code working in my development environment, but when I employ
>> to
>> our test environment I'm getting a null pointer.  I'm not sure why this
>> is
>> happening.  Can someone give me any pointers?  I'm really desperate to
>> find
>> a solution.
>>
>> java.lang.NullPointerException
>>         at
>> org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:81)
>>         at
>> org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:112)
>>         at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:104)
>>         at
>> org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:55)
>>         at javax.xml.ws.Service.<init>(Service.java:57)
>>         at
>> com.mysite.services.news.NewsService.<init>(NewsService.java:41)
>>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>         at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>
>> >From code:
>>
>> @WebServiceClient(name = "NewsService", targetNamespace =
>> "http://services.mysite.com/News", wsdlLocation =
>> "http://mysite.com/services/NewsService.svc?wsdl")
>> public class NewsService extends Service {
>>
>>     private final static URL WSDL_LOCATION;
>>     private final static QName SERVICE = new
>> QName("http://services.mysite.com/News", "NewsService");
>>     private final static QName BasicHttpBinding = new
>> QName("http://services.mysite.com/News", "basicHttpBinding");
>>     static {
>>         URL url = null;
>>         try {
>>             url = new
>> URL("http://mysite.com/services/NewsService.svc?wsdl");
>>         } catch (MalformedURLException e) {
>>             System.err.println("Can not initialize the default wsdl from
>> http://mysite.com/services/NewsService.svc?wsdl");
>>             // e.printStackTrace();
>>         }
>>         WSDL_LOCATION = url;
>>     }
>>
>>     public NewsService(URL wsdlLocation, QName serviceName) {
>>         super(wsdlLocation, serviceName);
>>     }
>>
>>     public NewsService() {
>>         super(WSDL_LOCATION, SERVICE);
>>     }
>>
>>     /**
>>      * 
>>      * @return
>>      *     returns BasicHttpBinding
>>      */
>>     @WebEndpoint(name = "basicHttpBinding")
>>     public NewsServiceContract getBasicHttpBinding() {
>>         return (NewsServiceContract)super.getPort(BasicHttpBinding,
>> NewsServiceContract.class);
>>     }
>>
>>
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/Null-Pointer-in-WSDLServiceFactory-tf4357565.html#a12428830
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Null Pointer in WSDLServiceFactory

Posted by Willem Jiang <ni...@iona.com>.
Hi ,

 It looks like the WSDLServiceFactory can 't  get the WSDLManager from 
the bus when you try to create a service model for the client.

 public WSDLServiceFactory(Bus b, String url, QName sn) {
        setBus(b);
        try {
            // use wsdl manager to parse wsdl or get cached definition
            definition = 
getBus().getExtension(WSDLManager.class).getDefinition(url);  // The NPE 
is thrown form here
        } catch (WSDLException ex) {
            throw new ServiceConstructionException(new 
Message("SERVICE_CREATION_MSG", LOG), ex);
        }
       
        serviceName = sn;
    }

It could be your WSDLManager does not be set to the bus.
Can you tell me how did you initialize the bus?
Did you use the spring configuration or load the bus by other means?

Maybe you can set the log level to INFO for more information.


Willem.

   
green804 wrote:
> I have this code working in my development environment, but when I employ to
> our test environment I'm getting a null pointer.  I'm not sure why this is
> happening.  Can someone give me any pointers?  I'm really desperate to find
> a solution.
>
> java.lang.NullPointerException
>         at
> org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:81)
>         at
> org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:112)
>         at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:104)
>         at
> org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:55)
>         at javax.xml.ws.Service.<init>(Service.java:57)
>         at com.mysite.services.news.NewsService.<init>(NewsService.java:41)
>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>         at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>
> >From code:
>
> @WebServiceClient(name = "NewsService", targetNamespace =
> "http://services.mysite.com/News", wsdlLocation =
> "http://mysite.com/services/NewsService.svc?wsdl")
> public class NewsService extends Service {
>
>     private final static URL WSDL_LOCATION;
>     private final static QName SERVICE = new
> QName("http://services.mysite.com/News", "NewsService");
>     private final static QName BasicHttpBinding = new
> QName("http://services.mysite.com/News", "basicHttpBinding");
>     static {
>         URL url = null;
>         try {
>             url = new
> URL("http://mysite.com/services/NewsService.svc?wsdl");
>         } catch (MalformedURLException e) {
>             System.err.println("Can not initialize the default wsdl from
> http://mysite.com/services/NewsService.svc?wsdl");
>             // e.printStackTrace();
>         }
>         WSDL_LOCATION = url;
>     }
>
>     public NewsService(URL wsdlLocation, QName serviceName) {
>         super(wsdlLocation, serviceName);
>     }
>
>     public NewsService() {
>         super(WSDL_LOCATION, SERVICE);
>     }
>
>     /**
>      * 
>      * @return
>      *     returns BasicHttpBinding
>      */
>     @WebEndpoint(name = "basicHttpBinding")
>     public NewsServiceContract getBasicHttpBinding() {
>         return (NewsServiceContract)super.getPort(BasicHttpBinding,
> NewsServiceContract.class);
>     }
>
>
>