Announcement Announcement Module
Collapse
No announcement yet.
Tomcat deployOnStartup=true causes spurious error message Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tomcat deployOnStartup=true causes spurious error message

    I am using Spring 1.2.1, Hibernate 3.0.5, and Tomcat 5.0.28 with a jndi datasource that is defined in a context.xml file. It works; however, when I set deployOnStartup=true in the Tomcat Host directive, I see the following error in my cross context log file:

    ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

    If I set deployOnStartup=false, the error message does not appear. Again, in both cases, the datasource works. However, with deployOnStartup=true, I get the spurious (I'm guessing, since everything works) error message.

    Has anyone else seen this behavior? How are you handling it? Is it a bug? I do not want to set deployOnStartup=false because then wars will not be auto expanded when Tomcat restarts.

    Relevant configs as follows (w/ private info xxx'd out):

    Host directive in server.xml:
    <Host
    name="localhost"
    appBase="/home/tomcat/app"
    autoDeploy="false"
    deployOnStartup="true"
    unpackWARs="true"
    deployXML="true"
    debug="0" />

    app.xml context xml file:
    <Context path="" docBase="app" debug="0" reloadable="true">

    <!-- Database connection pool -->
    <Resource name="jdbc/app" scope="Shareable"
    type="javax.sql.DataSource" />
    <ResourceParams name="jdbc/app">
    <parameter>
    <name>factory</name>
    <value>
    org.apache.commons.dbcp.BasicDataSourceFactory
    </value>
    </parameter>

    <!-- DBCP database connection settings -->
    <parameter>
    <name>url</name>
    <value>
    jdbc:oracle:thin:@xxx:1521:xxx
    </value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>xxx</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>xxx</value>
    </parameter>

    <!-- DBCP connection pooling options -->
    <parameter>
    <name>initialSize</name>
    <value>0</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>8</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>8</value>
    </parameter>
    <parameter>
    <name>minIdle</name>
    <value>0</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>3000</value>
    </parameter>
    </ResourceParams>

    </Context>

    Datasource definition:
    <bean id="dataSource"
    class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>java:comp/env/jdbc/app</value>
    </property>
    </bean>
Working...
X