Announcement Announcement Module
Collapse
No announcement yet.
No WebApplicationContext found: no ContextLoaderListener registered? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No WebApplicationContext found: no ContextLoaderListener registered?

    Hi All,

    I have written a sample Hello World service using Spring and Axis deployed under JBoss AS. I can see the service through http://localhost:8080/axis/services/HelloWorld but when i try to access this service through a stand alone java program i am getting following error.

    --------------------------------------------------------------------------
    15:44:19,032 INFO [EXCEPTIONS] AxisFault:
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    at org.springframework.web.context.support.WebApplica tionContextUtils.getRequiredWebApplicationContext( WebApplicationContextUtils.java:86)
    at org.springframework.remoting.jaxrpc.ServletEndpoin tSupport.init(ServletEndpointSupport.java:85)
    at org.apache.axis.providers.java.JavaProvider.getNew ServiceObject(JavaProvider.java:238)

    --------------------------------------------------------------------------

    Please help.

    following is my code.

    package com.apress.prospring.ch16.remoting.jaxrpc;

    import java.rmi.RemoteException;

    import javax.xml.rpc.ServiceException;

    import org.springframework.remoting.jaxrpc.ServletEndpoin tSupport;

    import com.apress.prospring.ch16.remoting.HelloWorld;
    import com.apress.prospring.ch16.remoting.rmi.RemoteHello World;

    public class JaxRpcHelloWorld extends ServletEndpointSupport implements
    RemoteHelloWorld {

    private HelloWorld helloWorld;

    protected void onInit() throws ServiceException {

    helloWorld = (HelloWorld) getApplicationContext().getBean(
    "helloWorldService");
    }

    public String getMessage() throws RemoteException {
    return helloWorld.getMessage();
    }
    }

    -------------------------------------------------------------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>
    org.springframework.web.context.ContextLoaderServl et
    </servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
    <servlet-name>axis</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>axis</servlet-name>
    <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
    </web-app>
    --------------------------------------------------------------------------
    package com.apress.prospring.ch16.remoting.jaxrpc;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.FileSystemXmlA pplicationContext;

    import com.apress.prospring.ch16.remoting.HelloWorld;

    public class HelloWorldClient {

    public static void main(String[] args) {
    ApplicationContext ctx = new FileSystemXmlApplicationContext(
    "client.xml");

    HelloWorld helloWorld = (HelloWorld)ctx.getBean("helloWorldService");
    System.out.println(helloWorld.getMessage());
    }
    }
    --------------------------------------------------------------------------
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="helloWorldService"
    class="org.springframework.remoting.jaxrpc.JaxRpcP ortProxyFactoryBean">
    <property name="serviceFactoryClass">
    <value>org.apache.axis.client.ServiceFactory</value>
    </property>
    <property name="wsdlDocumentUrl">
    <value>http://localhost:8080/axis/services/HelloWorld?wsdl</value>
    </property>
    <property name="namespaceUri">
    <value>http://localhost:8080/axis/services/HelloWorld</value>
    </property>
    <property name="serviceName">
    <value>JaxRpcHelloWorldService</value>
    </property>
    <property name="portName">
    <value>HelloWorld</value>
    </property>
    <property name="portInterface">
    <value>com.apress.prospring.ch16.remoting.rmi.Remo teHelloWorld</value>
    </property>
    <property name="serviceInterface">
    <value>com.apress.prospring.ch16.remoting.HelloWor ld</value>
    </property>
    </bean>
    </beans>
    ---------------------------------------------------------------------------

  • #2
    You might want to change the use of the ContextLoaderServlet with a ContextLoaderListener, especially if your app server supports the Servlet 2.4 spec.

    Comment


    • #3
      Originally posted by Arjen Poutsma View Post
      You might want to change the use of the ContextLoaderServlet with a ContextLoaderListener, especially if your app server supports the Servlet 2.4 spec.
      thank you for your reply. i used the ContextLoaderListener but no success.

      Comment


      • #4
        Solution

        Step 1
        -------
        Configure context loader listener so that the parent web application context is loaded from /WEB-INF/applicationContext.xml in your web.xml


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


        Step 2
        -------
        Wire application business service beans in the root application context.



        <?xml version="1.0" encoding="UTF-8"?>
        <beans >


        <bean name="someBusinessService" class="org.spring.someapp.business.impl.SomeBusine ssServiceImpl" />

        </beans>

        Let me know if you found anything better.

        Comment


        • #5
          Wicket app samething

          Hello, this helped. I applied the listener xml elements and viola! it work!

          Comment

          Working...
          X