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

  • No WebApplicationContext found

    Hi all.

    Im developing a web app with spring + acegi security.
    When i try to start the app it cant because this error:

    Code:
    java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at ....
    at net.sf.acegisecurity.ui.session.HttpSessionEventPublisher.contextInitialized
    The web.xml is:

    Code:
    <web-app>
    
    <display-name>La Trastienda</display-name>
    <description>Herramienta de desarrollo colaborativo</description>
    
    <servlet>
    <servlet-name>latrastienda</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
    <servlet-name>latrastienda</servlet-name>
    <url-pattern>*.html</url-pattern>
    </servlet-mapping>
    
    <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>
    org.springframework.web.context.ContextLoaderServlet
    </servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationContext-security.xml
    </param-value>
    </context-param>
    
    <filter>
    <filter-name>Acegi Filter Chain Proxy</filter-name>
    <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
    <init-param>
    <param-name>targetClass</param-name>
    <param-value>net.sf.acegisecurity.util.FilterChainProxy</param-value>
    </init-param>
    </filter>
    
    <filter-mapping>
    <filter-name>Acegi Filter Chain Proxy</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <listener>
    <listener-class>
    net.sf.acegisecurity.ui.session.HttpSessionEventPublisher
    </listener-class>
    </listener>
    
    <session-config>
    <session-timeout>30</session-timeout>
    </session-config>
    
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    
    </web-app>
    I have test it with different ordering and load-on-startup values but nothing...

    Any ideas?

    thx

  • #2
    Try moving this to the top of your web.xml

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/applicationContext-security.xml
    </param-value>
    </context-param>


    And

    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>


    below it.

    The web.xml is very sensitive with the order of the declarations. Please check some tutorial because your order isn`t correct.

    [edit]
    Are you using Tomcat?

    Comment


    • #3
      Thx, it didnt work but i have found something interesting:

      after give the "No WebApplicationContext found" error, Tomcat loads the context:

      Code:
      2005-10-07 15&#58;40&#58;18 StandardContext&#91;/manager&#93;Manager&#58; start&#58; Starting web application at '/latrastienda'
      2005-10-07 15&#58;40&#58;19 StandardContext&#91;/latrastienda&#93;Exception sending context initialized event to listener instance of class net.sf.acegisecurity.ui.session.HttpSessionEventPublisher
      java.lang.IllegalStateException&#58; No WebApplicationContext found&#58; no ContextLoaderListener registered?
      	at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext&#40;WebApplicationContextUtils.java&#58;83&#41;
      	at net.sf.acegisecurity.ui.session.HttpSessionEventPublisher.contextInitialized&#40;HttpSessionEventPublisher.java&#58;73&#41;
      	at org.apache.catalina.core.StandardContext.listenerStart&#40;StandardContext.java&#58;3827&#41;
      	at org.apache.catalina.core.StandardContext.start&#40;StandardContext.java&#58;4343&#41;
      	at org.apache.catalina.core.StandardHostDeployer.start&#40;StandardHostDeployer.java&#58;830&#41;
      	at org.apache.catalina.core.StandardHost.start&#40;StandardHost.java&#58;991&#41;
      	at org.apache.catalina.manager.ManagerServlet.start&#40;ManagerServlet.java&#58;1322&#41;
      	at org.apache.catalina.manager.ManagerServlet.doGet&#40;ManagerServlet.java&#58;345&#41;
      	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;689&#41;
      	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;802&#41;
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;237&#41;
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;157&#41;
      	at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;214&#41;
      	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
      	at org.apache.catalina.core.StandardContextValve.invokeInternal&#40;StandardContextValve.java&#58;198&#41;
      	at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;152&#41;
      	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke&#40;AuthenticatorBase.java&#58;540&#41;
      	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;102&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
      	at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;137&#41;
      	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
      	at org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;118&#41;
      	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;102&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
      	at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;109&#41;
      	at org.apache.catalina.core.StandardValveContext.invokeNext&#40;StandardValveContext.java&#58;104&#41;
      	at org.apache.catalina.core.StandardPipeline.invoke&#40;StandardPipeline.java&#58;520&#41;
      	at org.apache.catalina.core.ContainerBase.invoke&#40;ContainerBase.java&#58;929&#41;
      	at org.apache.coyote.tomcat5.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;160&#41;
      	at org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;799&#41;
      	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection&#40;Http11Protocol.java&#58;705&#41;
      	at org.apache.tomcat.util.net.TcpWorkerThread.runIt&#40;PoolTcpEndpoint.java&#58;577&#41;
      	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run&#40;ThreadPool.java&#58;683&#41;
      	at java.lang.Thread.run&#40;Thread.java&#58;534&#41;
      
      2005-10-07 15&#58;40&#58;19 StandardContext&#91;/latrastienda&#93;Loading Spring root WebApplicationContext
      2005-10-07 15&#58;40&#58;19 StandardContext&#91;/latrastienda&#93;Set web app root system property&#58; 'webapp.root' = &#91;/usr/local/share/jakarta-tomcat-5.0.28/webapps/latrastienda/&#93;
      2005-10-07 15&#58;40&#58;19 StandardContext&#91;/latrastienda&#93;Shutting down Log4J
      2005-10-07 15&#58;40&#58;19 StandardContext&#91;/latrastienda&#93;Closing Spring root WebApplicationContext
      This is the current web.xml after some modifications:

      Code:
      <?xml version="1.0" encoding="ISO-8859-1"?>
      <!DOCTYPE web-app PUBLIC 
      '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 
      'http&#58;//java.sun.com/dtd/web-app_2_3.dtd'>
      
      <web-app>
      
      	<!-- Context -->
      	<context-param>
      		<param-name>contextConfigLocation</param-name>
      		<param-value>
      			/WEB-INF/applicationContext-security.xml
      		</param-value>
      	</context-param>
      
      	<!-- Context loader -->
      	<listener>
      		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      	</listener>	
      
      	<!-- Datos de la aplicación -->
      	<display-name>La Trastienda</display-name>
      	<description>Herramienta de desarrollo colaborativo</description>
      	
      	<!-- Authentication processing filter -->
      	<filter>
          	<filter-name>Acegi Filter Chain Proxy</filter-name>
              <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
              <init-param>
                  <param-name>targetClass</param-name>
                  <param-value>net.sf.acegisecurity.util.FilterChainProxy</param-value>
              </init-param>
         	</filter>
          <filter-mapping>
          	<filter-name>Acegi Filter Chain Proxy</filter-name>
            	<url-pattern>/*</url-pattern>
          </filter-mapping>
      
          <!-- Para evitar a un mismo usuario identificarse dos veces simultáneamente --> 	
          <listener>
              <listener-class>net.sf.acegisecurity.ui.session.HttpSessionEventPublisher</listener-class>
          </listener>
          
       	<session-config>
       		<session-timeout>30</session-timeout>
       	</session-config>
      
      	<!-- servlets -->
      	<servlet>
          	<servlet-name>latrastienda</servlet-name>
          	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          	<load-on-startup>1</load-on-startup>
        	</servlet>
      
      	<servlet-mapping>
          	<servlet-name>latrastienda</servlet-name>
          	<url-pattern>*.html</url-pattern>
        	</servlet-mapping>
        	
      	<!-- Página de entrada -->
        	<welcome-file-list>
          	<welcome-file>index.jsp</welcome-file>
      	</welcome-file-list>
      	
       </web-app>

      Comment


      • #4
        Something else in the ContextLoaderListener javadoc:

        For Servlet 2.2 containers and Servlet 2.3 ones that do not initalize listeners before servlets, use ContextLoaderServlet. See the latter's Javadoc for details.
        I changed to ContextLoaderServlet but its the same. Dosnt work.

        Im using Jakarta-Tomcat 5.0.28

        ?????????????

        Comment


        • #5
          Solved: it was not the web.xml file. There was deployed the acegi-sample-app and tomcat has problems to manage two apps using the acegi stuff.

          I undeployed the acegi-sample-app and now it works..

          Thx

          Comment

          Working...
          X