Results 1 to 7 of 7

Thread: applicationContext is null

  1. #1
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default applicationContext is null

    hi,

    I'm working with OpenAMF/spring/hibernate, using SpringBeanInvoker from the openAMF jar.
    when the SpringBeanInvoker tries to get the applicationContext it gets null.
    I'm wondering why, I mean, what I need to configure?


    Code:
    private WebApplicationContext context;
    context = WebApplicationContextUtils.getWebApplicationContext(
    				this.getServletContext());

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Can you post your web.xml configuration?

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  3. #3
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default

    this is my web.xml:

    Code:
    <web-app>
    	<display-name>SISTEMA VIRTUSCollege</display-name>
    	<description>SISTEMA VIRTUSCollege</description> 
    <servlet>
    		<servlet-name>DefaultGateway</servlet-name>
    		<display-name>DefaultGateway</display-name>
    		<description>DefaultGateway</description>
    		<servlet-class>org.openamf.DefaultGateway</servlet-class>
    		<init-param>
    			<param-name>OPENAMF_CONFIG</param-name>
    			<param-value>/WEB-INF/openamf-config.xml</param-value>
    			<description>Location of the OpenAMF config file.</description>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet>
    		<servlet-name>AdvancedGateway</servlet-name>
    		<display-name>AdvancedGateway</display-name>
    		<description>AdvancedGateway</description>
    		<servlet-class>org.openamf.AdvancedGateway</servlet-class>
    		<init-param>
    			<param-name>OPENAMF_CONFIG</param-name>
    			<param-value>/WEB-INF/openamf-config.xml</param-value>
    			<description>Location of the OpenAMF config file.</description>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
      <servlet>
        <servlet-name>ServletRedirector</servlet-name>
        <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
      </servlet>
    	<servlet-mapping>
    		<servlet-name>DefaultGateway</servlet-name>
    		<url-pattern>/gateway2</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>AdvancedGateway</servlet-name>
    		<url-pattern>/gateway</url-pattern>
    	</servlet-mapping>
      <servlet-mapping>
        <servlet-name>ServletRedirector</servlet-name>
        <url-pattern>/ServletRedirector</url-pattern>
      </servlet-mapping>
    
    <servlet>
        <servlet-name>conset</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
     </servlet>
    
       <servlet-mapping>
        <servlet-name>conset</servlet-name>
        <url-pattern>*.html</url-pattern>
      </servlet-mapping> 
      <welcome-file-list>
        <welcome-file>
          index.jsp
        </welcome-file>
      </welcome-file-list>
    
    <taglib>
        <taglib-uri>/spring</taglib-uri>
        <taglib-location>/WEB-INF/spring.tld</taglib-location>
      </taglib>
    
      <security-constraint>
    		<display-name>Regras de Seguranca</display-name>
    		<web-resource-collection>
    			<web-resource-name>Area protegida</web-resource-name>
    			<url-pattern>*.htm</url-pattern>
    			<url-pattern>*.html</url-pattern>
    			<url-pattern>*.jsp</url-pattern>
    					
    		</web-resource-collection>
    
    		<auth-constraint>
    			xxxxxxxxxxxxxxxxxxxxxxxxx
    		</auth-constraint>
    	</security-constraint> 
    	
    	<login-config>
    		<auth-method>FORM</auth-method>
    		<form-login-config>
    			<form-login-page>/WEB-INF/login.jsp</form-login-page>
    			<form-error-page>/WEB-INF/loginInvalido.jsp</form-error-page>
    		</form-login-config>
    	</login-config>
    	
    	<session-config>
            <session-timeout>30</session-timeout>
        </session-config>	
    	
    	<security-role>
    		xxxxxxxxxxxxxx
    	</security-role>
    
    </web-app>
    thanks

  4. #4
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    I would guess that OpenAMF is starting up before Spring. You need to configure the servlet startup order using the <load-on-startup> tags such that DispatcherServlet loads first.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  5. #5
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default

    I put a listener-class ContextLoaderListener in my web.xml, and the application worked, but I did not understand why yet. could explain?

  6. #6
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    The ContextLoaderListener class is going to load an ApplicationContext and mount it in the ServletContext. This is the AC that is accessed when using WebApplicationContextUtils.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

  7. #7
    Join Date
    Apr 2005
    Location
    Brazil
    Posts
    66

    Default

    the ApplicationContext that I can access from one of my beans of my dispatcherServlet does it not the same that is accessed from WebApplicationContextUtils ?

Similar Threads

  1. Replies: 2
    Last Post: Oct 17th, 2005, 08:41 PM
  2. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  3. Replies: 4
    Last Post: Sep 27th, 2005, 11:31 PM
  4. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  5. Strange Data Access Error
    By webifyit in forum Data
    Replies: 2
    Last Post: Dec 28th, 2004, 11:06 AM

Posting Permissions

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