You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by red phoenix <ro...@gmail.com> on 2006/09/29 17:34:30 UTC

Tomcat5.5.17 JNDI configure error

I use JDK1.6 and Tomcat5.5.17,I want to use JNDI in tomcat,so I do like
follows:
Tomcat/conf/context.xml
<Context>
<Resource name="jdbc/test"
  type="javax.sql.DataSource" auth="Container"
  driverClassName="ooracle.jdbc.driver.OracleDriver" maxActive="100"
  maxIdle="30" maxWait="10000"
  url="jdbc:oracle:thin:@localhost:1521:EDWARD"
  username="scott" password="tiger" />
   <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
 </Context>

Tomcat/conf/server.xml
......
<!-- Global JNDI resources -->
  <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
......

Tomcat/webapps/myweb/WEB-INF/web.xml
......
<resource-ref>
   <description>Oracle Datasource example</description>
  <res-ref-name>jdbc/test</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
 </resource-ref>
 </web-app>

  I call JNDI in my code,like follows:

  Context initContext = new InitialContext();
   Context envContext  = (Context)initContext.lookup("java:/comp/env");
   DataSource ds = (DataSource)envContext.lookup("jdbc/test");
   Connection conn = ds.getConnection();

 But when I run it,it raise following errors:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver
class 'oracle.jdbc.driver.OracleDriver'
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(
BasicDataSource.java:766)
        at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(
BasicDataSource.java:540)
        at SKY.manage.loginAction.execute(test.java:35)
        at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(Execute
Action.java:53)
        at org.apache.struts.chain.commands.AbstractExecuteAction.execute(
AbstractExecuteAction.java:64)
        at org.apache.struts.chain.commands.ActionCommandBase.execute(
ActionCommandBase.java:48)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java
:190)
        at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand
java:304)
        at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java
:190)

Why raise above error? Please help.

Thanks

Re: Tomcat5.5.17 JNDI configure error

Posted by Len Popp <le...@gmail.com>.
The JDBC driver must be in common/lib so that it is accessible to both
Tomcat and your app.
See http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html
and http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
-- 
Len

On 9/29/06, red phoenix <ro...@gmail.com> wrote:
> I use Oracle9i,so I put oracle\ora90\jdbc\lib\classes12.jar file into
> tomcat\webapp\myweb\WEB-INF\lib,I don't where I did wrong,I am puzzled with
> it
>
> On 9/30/06, Caldarale, Charles R <Ch...@unisys.com> wrote:
> >
> > > From: red phoenix [mailto:rodphoenix@gmail.com]
> > > Subject: Tomcat5.5.17 JNDI configure error
> > >
> > >  But when I run it,it raise following errors:
> > >
> > > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load
> > > JDBC driver class 'oracle.jdbc.driver.OracleDriver'
> >
> > Where did you put the jar containing the Oracle driver?
> >
> > - Chuck
> >
> >
> > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> > MATERIAL and is thus for use only by the intended recipient. If you
> > received this in error, please contact the sender and delete the e-mail
> > and its attachments from all computers.
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat5.5.17 JNDI configure error

Posted by red phoenix <ro...@gmail.com>.
I use Oracle9i,so I put oracle\ora90\jdbc\lib\classes12.jar file into
tomcat\webapp\myweb\WEB-INF\lib,I don't where I did wrong,I am puzzled with
it

On 9/30/06, Caldarale, Charles R <Ch...@unisys.com> wrote:
>
> > From: red phoenix [mailto:rodphoenix@gmail.com]
> > Subject: Tomcat5.5.17 JNDI configure error
> >
> >  But when I run it,it raise following errors:
> >
> > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load
> > JDBC driver class 'oracle.jdbc.driver.OracleDriver'
>
> Where did you put the jar containing the Oracle driver?
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Tomcat5.5.17 JNDI configure error

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: red phoenix [mailto:rodphoenix@gmail.com] 
> Subject: Tomcat5.5.17 JNDI configure error
> 
>  But when I run it,it raise following errors:
> 
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load 
> JDBC driver class 'oracle.jdbc.driver.OracleDriver'

Where did you put the jar containing the Oracle driver?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org