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

  • 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
    Can you post your web.xml configuration?

    Rob

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


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

          Comment


          • #6
            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

            Comment


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

              Comment

              Working...
              X