Results 1 to 4 of 4

Thread: JAX-WS autowiring doesn't work on WebLogic Server

  1. #1
    Join Date
    Aug 2008
    Posts
    3

    Default JAX-WS autowiring doesn't work on WebLogic Server

    Hi,

    Recently I'm trying to add Spring's autowiring support to my JAX-WS web services by having them inherit from SpringBeanAutowiringSupport, i.e.

    #WebService
    public class Foo extends SpringBeanAutowiringSupport {

    #Autowired
    private Bar bar;

    }

    And also, define these services in web.xml:

    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    <servlet>
    <servlet-name>Foo</servlet-name>
    <servlet-class>xxx.Foo</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>

    But however, at runtime I found the dependency injection never happened. After looking into Spring's code, I guess the problem might be that Spring probably requires that my WS servlet and ContextLoaderListener should be able to get access to exactly the same thread context class loader (i.e. the classloader for the webapp), but when weblogic processes my servlet, it temporarily sets the thread context class loader to a dedicated JAXWS class loader which inherits from the regular webapp class loader, and this causes that my servlet can't share the spring application context of the webapp, so that the DI gets ignored.

    If I'm not doing anything wrong, I just wonder if there's any solution on the spring side?

    Thanks a lot!

  2. #2
    Join Date
    Oct 2008
    Posts
    1

    Default

    I am trying to do the same thing and it doesnt seem to work. Has anyone tried using the SpringBeanAutowiringSupport on endpoint and got the injection working? I have spent a lot of time on this and am going nowhere. I am using weblogic 10.3 onJava 6

  3. #3
    Join Date
    May 2008
    Posts
    22

    Default

    Hi,

    I doesn't work for me either. I am using tc Server v6.0 with Spring 2.5.6.SEC01 and Apache CXF 2.2.4

    My web.xml is:
    Code:
    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
        classpath:org/example/remoting/jaxw/cxf-context.xml</param-value>
       </context-param>
       <listener>
         <listenerclass>
          org.springframework.web.context.ContextLoaderListener
        </listener-class>
    	</listener>
    	<servlet>
    	<servlet-name>CXFServlet</servlet-name>
    		<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>CXFServlet</servlet-name>
    		<url-pattern>/cxf/*</url-pattern>
    	</servlet-mapping>
    The cxf-context.xml is:
    Code:
    <import resource="classpath:META-INF/cxf/cxf.xml" />
    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
    
    <context:annotation-config />
    
    <bean id="helloWorld" class="org.example.remoting.SimpleHelloWorld" />
    
    <jaxws:endpoint id="helloWorldService"
      implementor="org.example.remoting.jaxws.HelloWorldEndpoint" address="/helloWorldService" />
    My endpoint implementation is
    Code:
    @WebService
    public class HelloWorldEndpoint extends SpringBeanAutowiringSupport implements RemoteHelloWorld{
    
    	@Autowired
    	private HelloWorld helloWorld;
    	
    	@Override
    	public String getMessage() throws RemoteException {
    		return helloWorld.getMessage();
    	}
    }
    In the logs I see:
    Code:
    DEBUG: org.springframework.web.context.support.SpringBeanAutowiringSupport - Current WebApplicationContext is not available for processing of HelloWorldEndpoint: Make sure this class gets constructed in a Spring web application. Proceeding without injection.
    Zoltan

  4. #4
    Join Date
    May 2008
    Posts
    34

    Default

    There is a bug opened for that in JIRA: http://jira.springframework.org/browse/SPR-5652

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •