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

  • Help me resolve -No WebApplicationContext found: no ContextLoaderListener registered?

    Hi,

    I have a very simple web application and in the servlet init method below is my code

    public void init(ServletConfig config) throws ServletException {
    super.init(config);

    WebApplicationContext applicationContext =
    WebApplicationContextUtils.getRequiredWebApplicati onContext( config.getServletContext() );

    WebApplicationContext applicationContext =
    WebApplicationContextUtils.getWebApplicationContex t( config.getServletContext());
    DelegationPageBean.setApplicationContext(applicati onContext);
    }


    and below is code for web.xml

    <web-app id="WebApp_ID">
    <display-name>DelegateProtoTypeWeb</display-name>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>>classpath*:/com/pnc/delegate/persistence/config/testingDataSourceApplicationContext.xml, classpath*:/com/pnc/delegate/persistence/config/persistenceApplicationContext.xml</param-value>
    </context-param>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>TestServlet3</servlet-name>
    <servlet-class>com.pnc.delegation.servlet.TestServlet3</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestServlet3</servlet-name>
    <url-pattern>/TestServlet3</url-pattern>
    </servlet-mapping>
    </web-app>


    I keep getting the below error when i try to run the servlet

    [Servlet Error]-[TestServlet3]: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
    at java.lang.Throwable.<init>(Throwable.java)
    at java.lang.Throwable.<init>(Throwable.java)
    at org.springframework.web.context.support.WebApplica tionContextUtils.getRequiredWebApplicationContext( WebApplicationContextUtils.java:86)
    at com.pnc.delegation.servlet.TestServlet3.doPost(Tes tServlet3.java:49)
    at com.pnc.delegation.servlet.TestServlet3.doGet(Test Servlet3.java:35)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)

    Can some one help me resolve thsi issue?

    Thank you

  • #2
    do you have
    Code:
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    in your web.xml file?

    Comment


    • #3
      Thank you for the reply,

      yes I do have this in web.xml, but I still I get the error

      Comment


      • #4
        I was able to figure out the problem, I was using Servlet Container version 2.3 and this requires ContextLoaderServlet and not ContextLoaderListener.

        Hope this helps anyone going thorugh this error.

        Comment

        Working...
        X