Results 1 to 3 of 3

Thread: ContextLoaderListener failed while deploying

  1. #1
    Join Date
    Oct 2004
    Posts
    10

    Default ContextLoaderListener failed while deploying

    Hi,

    While I tried to deploy a simple application with Spring, hibernate, JbuilderX and Weblogic, the following error shows up at the server console after deployment:


    <User defined listener org.springframework.web.context.ContextLoaderListe ner failed: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is net.sf.hibernate.MappingException: invalid mapping.>
    Although the deployment is shown as succesful in the 'Weblogic Palform Server console'. This is not to mention that I run weblogic from within JbuilderX.

    Below I'm just copy-pasting the contents of my applicationContext.xml and web.xml file.

    applicationContext.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
        "http&#58;//www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>
    
    
    
    <!--    Connection for oracle-->
    
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
            <property name="url"><value>jdbc&#58;oracle&#58;thin&#58;@bddh01-s0002&#58;1521&#58;odt01</value></property>
            <property name="username"><value>spring</value></property>
            <property name="password"><value>spring</value></property>
        </bean>
    
    
    
        <!-- Hibernate SessionFactory -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
            <property name="dataSource"><ref local="dataSource"/></property>
            <property name="mappingResources">
                <list>
                <value>bd/usermgt/model/UserLogin.hbm.xml</value>
                <value>bd/usermgt/model/UserInfo.hbm.xml</value>
                <value>bd/usermgt/model/UserGroup.hbm.xml</value>
                </list>
            </property>
            <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">net.sf.hibernate.dialect.Oracle9Dialect</prop>
            </props>
            </property>
        </bean>
    
        <!-- Transaction manager for a single Hibernate SessionFactory &#40;alternative to JTA&#41; -->
        <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
    
        <!-- Add DAOs here -->
        <bean id="userDAO" class="bd.usermgt.dao.hibernate.UserDAOHibernate">
            <property name="sessionFactory">
                <ref local="sessionFactory"/>
            </property>
        </bean>
    
    </beans>

    web.xml file:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>
      <display-name>usrmgtweb</display-name>
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <init-param>
          <param-name>debug</param-name>
          <param-value>2</param-value>
        </init-param>
        <init-param>
          <param-name>application</param-name>
          <param-value>ApplicationResources</param-value>
        </init-param>
        <load-on-startup>2</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      <taglib>
        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-template.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
      </taglib>
    </web-app>
    Any suggestion plz?

    Thanks,
    ... Chisty

  2. #2

    Default

    In the documentation of org.springframework.web.context.ContextLoaderServl et I red that:

    Bootstrap servlet to start up Spring's root WebApplicationContext. Simply delegates to ContextLoader.

    This servlet should have a lower load-on-startup value in web.xml than any servlets that access the root web application context.

    Note that this class has been deprecated for containers implementing Servlet API 2.4 or higher in favour of ContextLoaderListener.
    According to Servlet 2.4, listeners must be initialized before load-on-startup servlets. Many Servlet 2.3 containers already enforce this behavior. If you use such a container, this servlet can be replaced with ContextLoaderListener. Else or if working with a Servlet 2.2 container, stick with this servlet.

    Servlet 2.3 containers known to work with bootstrap listeners are:

    Apache Tomcat 4.x
    Jetty 4.x
    Resin 2.1.8+
    Orion 2.0.2+
    For working with any of them, ContextLoaderListener is recommended.
    Servlet 2.3 containers known not to work with bootstrap listeners are:

    BEA WebLogic up to 8.1
    IBM WebSphere 5.x
    Oracle OC4J 9.0.3

    If you happen to work with such a server, this servlet has to be used.
    So unfortunately, the only context initialization option that is compatible with all Servlet 2.3 containers is this servlet.

    Note that a startup failure of this servlet will not stop the rest of the web application from starting, in contrast to a listener failure. This can lead to peculiar side effects if other servlets get started that depend on initialization of the root web application context.

  3. #3
    Join Date
    Oct 2004
    Posts
    10

    Default

    Hi,

    Thanks for the guideline. I also managed to take a look at the documentation as you mentioned. This had been a good help. So, I modified my web.xml file i.e. I replaced the "ContextLoaderListener" with "ContextLoaderServlet" as follows (hence keeping it very simple):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>
      <display-name>usrmgtweb</display-name>
    
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
      </context-param>
    
      <servlet>
        <servlet-name>context</servlet-name>
        <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <taglib>
        <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-template.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
      </taglib>
    </web-app>

    Now, a new error shows up during deployment, which is as follows:

    Code:
    <Nov 24, 2004 2&#58;39&#58;45 PM BDT> <Error> <HTTP> <BEA-101216> <Servlet&#58; "context" failed to preload on startup in Web application&#58; "usrmgtweb".
    javax.servlet.ServletException&#58; Error creating bean with name 'sessionFactory' defined in ServletContext resource &#91;/WEB-INF/applicationContext.xml&#93;&#58; Initialization of bean failed; nested exception is net.sf.hibernate.MappingException&#58; invalid mapping
    	at weblogic.servlet.internal.ServletStubImpl.createServlet&#40;ServletStubImpl.java&#58;884&#41;
    .......
    .....
    ....
    
    ... etc
    >
    [I did not put the whole error stack trace here.]

    Could you suggest anything on this? My applicationContext.xml file is kept unchanged.


    With Thanks,
    ... Chisty

Similar Threads

  1. Error deploying SLSB+Spring on JBoss
    By guila in forum EJB
    Replies: 3
    Last Post: Feb 7th, 2006, 08:11 PM
  2. Context initialization failed
    By kanonmicke in forum Container
    Replies: 7
    Last Post: Sep 29th, 2005, 12:35 AM
  3. Replies: 2
    Last Post: Aug 17th, 2005, 05:27 AM
  4. Replies: 3
    Last Post: Mar 4th, 2005, 04:50 AM
  5. Replies: 2
    Last Post: Mar 3rd, 2005, 06:41 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
  •