2

In web.xml I have the following:

<servlet>
        <description>JAX-WS endpoint - EARM</description>
        <display-name>jaxws-servlet</display-name>
        <servlet-name>jaxws-servlet</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>jaxws-servlet</servlet-name>
        <url-pattern>/webServices/*</url-pattern>
    </servlet-mapping>

In my application context I have the following definitions:

<bean id="helloService" class="com.foo.HelloServiceImpl">        
    <property name="regularService" ref="regularService" />
</bean>

<wss:binding url="/webServices/helloService" service="#helloService" />

I get a NullPointerException when trying to access the WSDL:

java.lang.NullPointerException
at com.sun.xml.ws.transport.http.HttpAdapter.<init>(HttpAdapter.java:145)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.<init>(ServletAdapter.java:76)
at com.sun.xml.ws.transport.http.servlet.ServletAdapterList.createHttpAdapter(ServletAdapterList.java:5 0)
at com.sun.xml.ws.transport.http.servlet.ServletAdapterList.createHttpAdapter(ServletAdapterList.java:4 7)
at com.sun.xml.ws.transport.http.HttpAdapterList.createAdapter(HttpAdapterList.java:73)
at com.sun.xml.ws.transport.http.servlet.SpringBinding.create(SpringBinding.java:24)
at com.sun.xml.ws.transport.http.servlet.WSSpringServlet.init(WSSpringServlet.java:46) 

Strange ... appears to be a configuration error but the darn thing just dies with a NullPointerException!!!!!!!! No logging is provided.

Deployed in Resin.

Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
les2
  • 14,093
  • 16
  • 59
  • 76
  • Basically, I've followed the instructions on the following site: https://jax-ws.dev.java.net/guide/Using_Metro_With_Spring_and_NetBeans_6_1.html – les2 Sep 23 '09 at 00:18
  • 1
    Yes, finally! I have stumped stackoverflow!!!!! – les2 Sep 23 '09 at 00:40
  • No, you just didn't tag the question properly :) Have you looked at the source code of `HttpAdapter` to see what's causing the exception? – skaffman Sep 23 '09 at 07:22
  • I actually did look at the source of HttpAdapater, but it wasn't helpful: http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/transport/http/HttpAdapter.java?r=1.26 144 // fill in WSDL map 145 ServiceDefinition sdef = this.endpoint.getServiceDefinition(); – les2 Sep 23 '09 at 13:41
  • i think it's a 1. not supported, 2. missing dependency / jar, or 3. plain broken and what would better tags be? – les2 Sep 23 '09 at 13:42
  • stackoverflow many times disappoints us .. finally we are told an boring philosophy "Dont expect more from anything , anyone" – Arun May 30 '12 at 13:20

2 Answers2

3

UPDATE: I finally figured out the real answer to this problem and posted it here: http://forum.springsource.org/showthread.php?p=286701

In short, Resin 3x ships with an XSD-unaware parser and you have to replace it with Apache Xerces or some other parser (see above forum post).

=========================

The following bean definitions get the Spring JAX-WS working (without using the "stupid" xbean / namespace magic). To come by this, I had to read the source and figure out the correct classes to use - sometimes by intentionally providing a property value that I knew would cause an exception (such as an invalid Class - this allowed me to see the stack trace which lead back to the bean class).

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="webServiceMethodInterceptor"
    class="com.webservice.util.interceptors.WebServiceMethodInterceptor">
    <property name="userId" value="hello" />
    <property name="password" value="world" />
    <property name="roles" value="ROLE_ANONYMOUS,ROLE_MICKEY_MOUSE" />
</bean>

<bean id="webServiceLoggingInterceptor"
    class="com.webservice.util.interceptors.LoggingInterceptor">
    <property name="level" value="debug" />
</bean>

<bean id="webServiceExceptionTranslator"
    class="com.webservice.util.interceptors.WebServiceExceptionTranslator"/>

<!-- The list of interceptors to apply to all web methods -->
<bean id="webServiceInterceptors" class="java.util.LinkedList">
    <constructor-arg index="0">
        <list>
            <value>webServiceExceptionTranslator</value>
            <value>webServiceLoggingInterceptor</value>
            <value>webServiceMethodInterceptor</value>
        </list>
    </constructor-arg>
</bean>

<!-- Proxied ExampleWebService -->
<bean id="exampleWebService" class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="target">
        <bean class="com.webservice.ExampleWebServiceImpl">
            <!-- TODO: add dependencies for web service here, for example:
            <property name="someService" ref="someService" />
            -->
        </bean>
    </property>
    <property name="interceptorNames" ref="webServiceInterceptors" />
    <property name="proxyTargetClass" value="true" />
</bean>

<!-- JAX-WS Endpoint for ExampleWebService -->
<bean class="com.sun.xml.ws.transport.http.servlet.SpringBinding">
    <property name="url" value="/webServices/exampleService" />
    <property name="service">
        <bean class="org.jvnet.jax_ws_commons.spring.SpringService">
            <property name="bean">
                <ref local="exampleWebService" />
            </property>
            <property name="impl"
                value="com.webservice.ExampleWebServiceImpl" />
        </bean>
    </property>
</bean>

Everything else is as in the tutorial linked to above (you add the JAX-WS Spring servlet in web.xml, add the servlet filter so that web service requests get routed to the jaxws servlet).

The key to using the proxied web service instance (thus enabling dependency injection, AOP, etc.) was setting proxyTargetClass="true" to force a CGLIB proxy instead of a JDK dynamic proxy (which requires an interface). JAX-WS seems to not like interfaces for some reason.

I hope this helps some one!

Regards, LES

les2
  • 14,093
  • 16
  • 59
  • 76
0

LES2: Your implementation seem most complex. What's wrong with simple usage of SpringBeanAutowiringSupport, as described in Spring manual

Asaf Mesika
  • 1,643
  • 4
  • 20
  • 33
  • is this available in spring 2.0.8 ? that's the version we are currently using (and i have zero control over what version we use - everything has to be approved by a government agency's architecture group + that version has to be supported by all the other components in the system, i suppose) – les2 Dec 11 '09 at 21:58
  • P.S. It is a requirement that we use JAX-WS RI, as described in section 17.5.7 Exporting web services using the JAX-WS RI's Spring support of the same web page. The way to use JAX-WS RI with Spring is as described in this post. There is a simpler syntax, but I couldn't get it to work! So I just created the bean definitions the old way. – les2 Dec 11 '09 at 22:01