Results 1 to 5 of 5

Thread: No WebApplicationContext found

  1. #1

    Default 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. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    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?

  3. #3

    Default

    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>

  4. #4

    Default

    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

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

  5. #5

    Default

    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

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  5. Replies: 1
    Last Post: Apr 13th, 2005, 10:08 PM

Posting Permissions

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