Announcement Announcement Module
Collapse
No announcement yet.
Tomcat, problem with org.springframework.jndi.JndiObjectFact Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tomcat, problem with org.springframework.jndi.JndiObjectFact

    Hi all,

    In my application Context, I have a datasource which is defined like this :
    Code:
    <bean id="dataSource" 
    	class="org.springframework.jndi.JndiObjectFactoryBean">
    	<property name="jndiName">
    	<value>java&#58;comp/env/OracleProdDS</value>
    	</property>
    </bean>
    This work well when I work on JBOSS (version 3.2.5).

    I tried to make my web app work on TOMCAT (version 5.0.28 ).
    So in my tomcat conf file (server.xml) I have added this :
    Code:
    <Resource name="OracleProdDS" auth="Container" 
    		type="javax.sql.DataSource"/>
    	<ResourceParams name="OracleProdDS">
        <parameter>
    		<name>username</name>
    		<value>USER</value>
        </parameter>
        <parameter>
          <name>password</name>
          <value>PASS</value>
        </parameter>
        <parameter>
          <name>driverClassName</name>
          <value>oracle.jdbc.driver.OracleDriver</value>
        </parameter>
        <parameter>
          <name>url</name><value>URL</value>
        </parameter>
        <parameter>
          <name>maxActive</name>
          <value>8</value>
        </parameter>
        <parameter>
          <name>maxIdle</name>
          <value>4</value>
        </parameter>
      </ResourceParams>
    and in my my web app, I added in my web.xml :
    Code:
    <resource-ref>
    	<res-ref-name>OracleProdDS</res-ref-name>
    	<res-type>javax.sql.DataSource</res-type>
    	<res-auth>Container</res-auth>
    </resource-ref>
    When I deploy my web app, everything is OK :
    Code:
    Nov 19, 2004 2&#58;37&#58;24 PM org.springframework.jndi.JndiLocatorSupport lookup
    INFO&#58; Located object with JNDI name &#91;java&#58;comp/env/OracleProdDS&#93;&#58; value=&#91;org.apache.commons.dbcp.BasicDataSource@952905&#93;
    but when I want to display the page whch access to the database, I have the following error :
    Code:
    Nov 19, 2004 2&#58;39&#58;29 PM org.springframework.web.servlet.FrameworkServlet serviceWrapper
    SEVERE&#58; Could not complete request
    org.springframework.jdbc.CannotGetJdbcConnectionException&#58; Could not get JDBC connection; nested exception is org.apache.commons.dbcp.SQLNestedException&#58; Cannot create JDBC driver of class '' for connect URL 'null'
    org.apache.commons.dbcp.SQLNestedException&#58; Cannot create JDBC driver of class '' for connect URL 'null'
    	at org.apache.commons.dbcp.BasicDataSource.createDataSource&#40;BasicDataSource.java&#58;780&#41;
    	at org.apache.commons.dbcp.BasicDataSource.getConnection&#40;BasicDataSource.java&#58;540&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection&#40;DataSourceUtils.java&#58;177&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;152&#41;
    	at org.springframework.jdbc.datasource.DataSourceUtils.getConnection&#40;DataSourceUtils.java&#58;128&#41;
    	at org.springframework.jdbc.core.JdbcTemplate.execute&#40;JdbcTemplate.java&#58;194&#41;
    	at org.springframework.jdbc.core.JdbcTemplate.query&#40;JdbcTemplate.java&#58;271&#41;
    	at org.springframework.jdbc.core.JdbcTemplate.queryForList&#40;JdbcTemplate.java&#58;283&#41;
    	at bean.iidx.StatisticsIidxDAOImpl.getRegionalDelegationList&#40;StatisticsIidxDAOImpl.java&#58;24&#41;
    	at bean.iidx.StatisticsIidxImpl.getRegionalDelegationList&#40;StatisticsIidxImpl.java&#58;31&#41;
    	at controller.iidx.IidxController.referenceData&#40;IidxController.java&#58;26&#41;
    	at org.springframework.web.servlet.mvc.SimpleFormController.referenceData&#40;SimpleFormController.java&#58;164&#41;
    	at org.springframework.web.servlet.mvc.AbstractFormController.showForm&#40;AbstractFormController.java&#58;365&#41;
    	at org.springframework.web.servlet.mvc.AbstractFormController.showForm&#40;AbstractFormController.java&#58;342&#41;
    	at org.springframework.web.servlet.mvc.SimpleFormController.showForm&#40;SimpleFormController.java&#58;190&#41;
    	at org.springframework.web.servlet.mvc.AbstractFormController.showNewForm&#40;AbstractFormController.java&#58;284&#41;
    	at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal&#40;AbstractFormController.java&#58;240&#41;
    	at org.springframework.web.servlet.mvc.AbstractController.handleRequest&#40;AbstractController.java&#58;128&#41;
    	at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle&#40;SimpleControllerHandlerAdapter.java&#58;44&#41;
    	at org.springframework.web.servlet.DispatcherServlet.doService&#40;DispatcherServlet.java&#58;532&#41;
    	at org.springframework.web.servlet.FrameworkServlet.serviceWrapper&#40;FrameworkServlet.java&#58;366&#41;
    	at org.springframework.web.servlet.FrameworkServlet.doGet&#40;FrameworkServlet.java&#58;317&#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.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;
    Caused by&#58; java.sql.SQLException&#58; No suitable driver
    	at java.sql.DriverManager.getDriver&#40;DriverManager.java&#58;243&#41;
    	at org.apache.commons.dbcp.BasicDataSource.createDataSource&#40;BasicDataSource.java&#58;773&#41;
    	... 47 more
    :shock:

    Can someone tell me where the problem could be?

    thx in advance

    khem

  • #2
    From your stacktrace it can be seen that the JNDI lookup works fine.
    It rather looks like the jar with the database driver is not in your classpath.

    Regards,
    Andreas

    Comment


    • #3
      Hi,

      I ve put my classes12.jar in my tomcat "C:\Tomcat 5.0\common\lib" directory and in my "WEB-INF/lib" directory too.
      So I don t think that it is a classpath problem.
      For the moment, I use a DriverManagerDataSource and it works... But it is just for test, I want to use the jndilookup :?

      bye

      Comment


      • #4
        This is not a classpath problem as no ClassNotFoundException is thrown.
        Generaly, it is a good practice to put resource factory configuration inside the application config file (located in $CATALINA_HOME/conf/Catalina/localhost/myapp.xml) instead of server.xml.

        Comment


        • #5
          Ok

          Hi,

          I made it work.
          In fact, in server.xml, I ve defined my ressource in the <GlobalNamingResources> element but this ressource must be defined in the <Context> element of the web app instead. :oops:

          thx you all for your answers

          bye

          Comment

          Working...
          X