Null pointer exception on startup with WSDL-first endpoint #32

Closed
steven-s opened this Issue Aug 19, 2013 · 3 comments

Projects

None yet

2 participants

@steven-s

I seem to be receiving the following error when I start up my application with an endpoint where I have an existing WSDL:

Message: Error creating bean with name 'myDataServiceBean': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.apache.cxf.endpoint.Server org.apache.cxf.jaxws.JaxWsServerFactoryBean.create()] threw exception; nested exception is java.lang.NullPointerException
    Line | Method
->>  593 | createApplicationContext in grails.spring.BeanBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     53 | loadAdditionalConfig     in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . in     ''
|    334 | innerRun                 in java.util.concurrent.FutureTask$Sync
|    166 | run . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1145 | runWorker                in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run                      in java.lang.Thread
Caused by BeanDefinitionStoreException: Factory method [public org.apache.cxf.endpoint.Server org.apache.cxf.jaxws.JaxWsServerFactoryBean.create()] threw exception; nested exception is java.lang.NullPointerException
->>  593 | createApplicationContext in grails.spring.BeanBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     53 | loadAdditionalConfig     in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init . . . . . . . . . . in     ''
|    334 | innerRun                 in java.util.concurrent.FutureTask$Sync
|    166 | run . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1145 | runWorker                in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run                      in java.lang.Thread
Caused by NullPointerException: null
->>  170 | getClassCode             in org.apache.cxf.common.util.ASMHelper
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    320 | generateMessagePart      in org.apache.cxf.jaxws.WrapperClassGenerator
|    234 | createWrapperClass . . . in     ''
|    137 | generate                 in     ''
|    669 | generatedWrapperBeanClass in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    638 | getExtraClass            in     ''
|    424 | buildServiceFromWSDL . . in org.apache.cxf.service.factory.ReflectionServiceFactoryBean
|    534 | initializeServiceModel   in     ''
|    248 | create . . . . . . . . . in     ''
|    205 | create                   in org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean
|    101 | createEndpoint . . . . . in org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory
|    159 | create                   in org.apache.cxf.frontend.ServerFactoryBean
|    211 | create . . . . . . . . . in org.apache.cxf.jaxws.JaxWsServerFactoryBean
|    593 | createApplicationContext in grails.spring.BeanBuilder
|     53 | loadAdditionalConfig . . in org.grails.cxf.servlet.GrailsCxfServlet
|     25 | init                     in     ''
|    334 | innerRun . . . . . . . . in java.util.concurrent.FutureTask$Sync
|    166 | run                      in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    615 | run                      in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . . . . . . . .  in java.lang.Thread

I haven't had much success trying to pinpoint the root of the issue. I have tried configuring this same service to be a plain JAX_WS endpoint instead of JAX_WS_WSDL and that seemed to launch without issue.

The application appears to still launch successfully, even with this error. I can even reach the services page and generate a client that appears to be correct with the cxf-client plugin. The client receives soap faults when it attempts to use the service though.

I have some additional debug output if that helps any:

INFO: Initializing Spring root WebApplicationContext

2013-08-19 14:19:38,284 [localhost-startStop-1] DEBUG artefact.EndpointBeanConfiguration  - Cxf Bus wired.
2013-08-19 14:19:38,898 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use [JAX_WS_WSDL].
2013-08-19 14:19:38,899 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to exclude methods [getClass, setTransactional, isTransactional, getMetaMethods, getMetaClass, setErrors, setClass, setProperty, invokeMethod,  getErrors, setMetaMethods, getProperty, setMetaClass, getTransactional].
2013-08-19 14:19:38,899 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use address [/myData].
2013-08-19 14:19:38,900 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to servlet [CxfServlet].
2013-08-19 14:19:38,900 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use WSDL [file:/C:/Users/auser/.grails/2.2.2/projects/myproject/resources/com/example/MyDataService.wsdl].
2013-08-19 14:19:38,901 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use soap 1.2 [false].
2013-08-19 14:19:47,542 [localhost-startStop-1] DEBUG logging.LogUtils  - Using org.apache.cxf.common.logging.Slf4jLogger for logging.
2013-08-19 14:19:48,002 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.ws.policy.PolicyAnnotationListener.
2013-08-19 14:19:48,031 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.service.factory.FactoryBeanListenerManager.
2013-08-19 14:19:48,036 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.ws.policy.PolicyEngineImpl.
2013-08-19 14:19:48,037 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.ws.policy.PolicyDataEngineImpl.
2013-08-19 14:19:48,039 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.bus.managers.CXFBusLifeCycleManager.
2013-08-19 14:19:48,040 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.bus.managers.ServerRegistryImpl.
2013-08-19 14:19:52,365 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.transport.http.HTTPTransportFactory.
2013-08-19 14:19:52,377 [localhost-startStop-1] DEBUG servlet.GrailsCxfServlet  - Loading additional bean configuration for [CxfServlet].
2013-08-19 14:19:52,418 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use [JAX_WS_WSDL].
2013-08-19 14:19:52,418 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to exclude methods [getClass, setTransactional, isTransactional, getMetaMethods, getMetaClass, setErrors, setClass, setProperty, invokeMethod,   getErrors, setMetaMethods, getProperty, setMetaClass, getTransactional].
2013-08-19 14:19:52,418 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use address [/myData].
2013-08-19 14:19:52,419 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to servlet [CxfServlet].
2013-08-19 14:19:52,419 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use WSDL [file:/C:/Users/auser/.grails/2.2.2/projects/myproject/resources/com/example/MyDataService.wsdl].
2013-08-19 14:19:52,419 [localhost-startStop-1] DEBUG artefact.DefaultGrailsEndpointClass  - Endpoint [com.example.MyDataService] configured to use soap 1.2 [false].
2013-08-19 14:19:52,430 [localhost-startStop-1] DEBUG servlet.GrailsCxfServlet  - Cxf endpoint bean wired for [com.example.MyDataService] on [CxfServlet] servlet.
2013-08-19 14:19:52,466 [localhost-startStop-1] INFO  factory.ReflectionServiceFactoryBean  - Creating Service {http://example.com/}MyDataServicePorts from WSDL: file:/C:/Users/auser/.grails/2.2.2/projects/myproject/resources/com/example/MyDataService.wsdl
2013-08-19 14:19:52,511 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.binding.xml.wsdl11.XMLWSDLExtensionLoader.
2013-08-19 14:19:52,519 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.ws.addressing.impl.AddressingWSDLExtensionLoader.
2013-08-19 14:19:52,522 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.transport.http.HTTPWSDLExtensionLoader.
2013-08-19 14:19:52,524 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.wsdl11.WSDLManagerImpl.
2013-08-19 14:19:52,553 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.catalog.OASISCatalogManager.
2013-08-19 14:19:52,665 [localhost-startStop-1] DEBUG wsdl11.WSDLServiceBuilder  - Operation {http://example.com/}searchData cannot be unwrapped, input message must reference global element declaration with same localname as operation
2013-08-19 14:19:52,673 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.binding.soap.SoapBindingFactory.
2013-08-19 14:19:52,685 [localhost-startStop-1] DEBUG spring.ConfigurerImpl  - Could not determine bean name for instance of class org.apache.cxf.binding.soap.SoapTransportFactory.
@steven-s

It looks like this issue may be related to lists in the data types used in the service. I created an example app to try to replicate the issues, and once I added a list to one of the request parameters, the same exception appeared.

@ctoestreich
Contributor

Lists, and especially Maps, can be tricky. Can you paste the signature of the your service endpoint method with the annotations?

@steven-s

I will push the example app to a repo when I have better access. For now, my service class looks like the following:

package com.example

import javax.jws.WebService

import org.grails.cxf.utils.EndpointType
import org.grails.cxf.utils.GrailsCxfEndpoint

@WebService(name = "MyDataService",
targetNamespace = "http://example.com/",
serviceName = "MyDataServicePorts",
portName = "MyDataService")
@GrailsCxfEndpoint(expose = EndpointType.JAX_WS_WSDL, wsdl = "com/example/MyDataService.wsdl")
class MyDataService {

    MyDataResponse searchData(MyDataRequest query) {
        MyDataResponse result = new MyDataResponse()

        result.message = "Query Received!"

        return result
    }
}

The request class:

package com.example;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyDataRequest", propOrder = { "query" })
@XmlRootElement(name = "myDataRequest")
public class MyDataRequest {
    @XmlElement
    protected String query;

    public String getQuery() {
        return query;
    }
}

The response class:

package com.example;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyDataResponse", propOrder = { "message", "subMessages" })
@XmlRootElement(name = "myDataResponse")
public class MyDataResponse {
    @XmlElement
    protected String message;

    @XmlElement(name="subMessages")
    protected List<String> subMessages = new ArrayList<String>();

    public String getMessage() {
        return message;
    }

    public List<String> getSubMessages() {
        if (subMessages == null) {
            subMessages = new ArrayList<String>();
        }

        return subMessages;
    }
}

The WSDL:

<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="MyDataService" targetNamespace="http://example.com/"
    xmlns:http="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://example.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:types>
        <xs:schema elementFormDefault="qualified" targetNamespace="http://example.com/"
            xmlns:tns="http://example.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:complexType name="MyDataRequest">
                <xs:sequence maxOccurs="1" minOccurs="1">
                    <xs:element name="query" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="MyDataResponse">
                <xs:sequence maxOccurs="1" minOccurs="1">
                    <xs:element name="message" type="xs:string" />
                    <xs:element name="subMessages" type="xs:string"
                        minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
            </xs:complexType>
            <xs:element name="myDataRequest" type="tns:MyDataRequest" />
            <xs:element name="myDataResponse" type="tns:MyDataResponse" />
        </xs:schema>
    </wsdl:types>

    <!-- Search Data messages -->
    <wsdl:message name="SearchDataInput">
        <wsdl:part name="request" element="tns:myDataRequest" />
    </wsdl:message>
    <wsdl:message name="SearchDataOutput">
        <wsdl:part name="response" element="tns:myDataResponse" />
    </wsdl:message>

    <wsdl:portType name="MyDataService">
        <wsdl:operation name="searchData">
            <wsdl:input message="tns:SearchDataInput" name="SearchDataInput" />
            <wsdl:output message="tns:SearchDataOutput" name="SearchDataOutput" />
        </wsdl:operation>
    </wsdl:portType>

    <wsdl:binding name="MyDataSoapBinding" type="tns:MyDataService">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
            style="document" />
        <wsdl:operation name="searchData">
            <soap:operation soapAction="" />
            <wsdl:input name="SearchDataInput">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="SearchDataOutput">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="MyDataServicePorts">
        <wsdl:port name="MyDataService" binding="tns:MyDataSoapBinding">
            <soap:address location="/services/myData" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

I have been trying to tweak the annotations and WSDL file to see if I can resolve the issue, but so far I have had no luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment