Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring configuration in JBossWS
    text
    copied!<p>I'm trying to expose a web service using JBossWS (native stack) and also take advantage of Spring's dependency injection. Here is a scrubbed down version of my code:</p> <p><strong>web.xml:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"&gt; &lt;display-name&gt;Test Service&lt;/display-name&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt; /WEB-INF/applicationContext.xml &lt;/param-value&gt; &lt;/context-param&gt; &lt;listener&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;/listener&gt; &lt;servlet&gt; &lt;servlet-name&gt;EndpointService&lt;/servlet-name&gt; &lt;servlet-class&gt;com.blah.webservice.EndpointService&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;EndpointService&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p><strong>applicationContext.xml:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;context:spring-configured /&gt; &lt;context:load-time-weaver /&gt; &lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.blah.webservice" /&gt; &lt;/beans&gt; </code></pre> <p><strong>EndpointService.java</strong></p> <pre><code>package com.blah.webservice; import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service @WebService @SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE) public class EndpointService { private TestService testService; public EndpointService() {} @Autowired public EndpointService(TestService testService) { this.testService = testService; } @WebMethod public String endpointEcho(String echo) { return echo; } @WebMethod public String serviceEcho(String echo) { return testService.serviceEcho(echo); } } </code></pre> <p><strong>TestService.java:</strong></p> <pre><code>package com.blah.webservice; import org.springframework.stereotype.Service; @Service public class TestService { public TestService() {} public String serviceEcho(String echo) { return echo; } } </code></pre> <p>When I build this and deploy to JBoss, it starts up just fine and I can see Spring is pre-instantiating my classes but when I issue calls to the web service, endpointEcho works as expected while serviceEcho throws a NullPointerException. It seems that when JBossWS instantiates the endpoint class, it isn't finding out about my Spring configuration. Is there a simple way that I can tell JBossWS about Spring? I feel like I'm either missing some very small detail, or I'm approaching this all wrong. Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload