You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ray Madigan <ra...@madigans.org> on 2007/01/16 21:18:39 UTC

Cannot create JDBC driver

I have beat my head against this one long enough.  I am hoping someone can
help.

I cant get past the error message
SQLException: Cannot create JDBC driver of class ' ' for connect url 'null'

I am using tomcat 5.5.17 and I am attempting to get a JDBC connection in a
servlet using the instructions in the tomcat documentation pages.

My configuration is as follows:

$CATALINA_HOME/conf/server.xml - No changes

$CATALINA_BASE/webapps/Library/WEB-INF/web.xml
<resource-ref>
  <res-ref-name>jdbc/library</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

Between the <welcome... tag and the <taglib tag

$CATALINA_BASE/webapps/Library/META-INF/context.xml
<Context path="/Library" docBase="Library"
         crossContext="true" reloadable="true" debug="1">

  <Resource name="jdbc/library"
            auth="Container"
            type="javax.sql.DataSource"
            driverClassName="org.postgresql.Driver"
            url="jdbc:postgresql://192.xxx.xxx.xx/library"
            username="..."
            password="...."/>
</Context>

Note:  I was under the impression that Tomcat copied this to the
$CATALINA_HOME/conf/Catalina/localhost/Library.xml but it isn't being
copied?


The postgresql JDBC driver and commons-{pool,jdbc,collection}.jar are in
$CATALINA_HOME/common/lib


My servlet source is straight forward

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




---------------------------------------------------------------------
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: Cannot create JDBC driver

Posted by David Smith <dn...@cornell.edu>.
Ok ... I'll bite.  What's a realm got to do with the original post?  The
OP is just trying to setup a database pool via tomcat's built-in JNDI.

OP -- Your code didn't match completely with the example code on the
tomcat website.  Here it is matched up with what's in the docs:

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

The only two real changes here are 1) a missing / mark in between java:
and comp and 2) the return of new InitialContext() is of type
InitialContext.  The second difference is probably not affecting your
situation.  Everything else looked really good.

--David

Martin Gainty wrote:

>Ray-
>
>You will need to supply JDBC parameters as in this example Realm specification in server.xml
>
>      <Realm  className="org.apache.catalina.realm.JDBCRealm"
>             driverName="org.gjt.mm.mysql.Driver"
>          connectionURL="jdbc:mysql://localhost/authority"
>         connectionName="D" connectionPassword="******"
>              userTable="users" userNameCol="user_name" userCredCol="user_pass"
>          userRoleTable="user_roles" roleNameCol="role_name" />
>
>M-
>--------------------------------------------------------------------------- 
>This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
>--------------------------------------------------------------------------- 
>Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
>----- Original Message ----- 
>From: "Ray Madigan" <ra...@madigans.org>
>To: "Tomcat Users List" <us...@tomcat.apache.org>
>Sent: Tuesday, January 16, 2007 7:02 PM
>Subject: RE: Cannot create JDBC driver
>
>
>  
>
>>Well,
>>
>>I have to apologize, I was unsure of how much information on the setup
>>environment was needed?
>>
>>I deploy the application from a war file.  When I delete the war file from
>>the webapps directory and leave only the previously extracted directory the
>>servlet can create the DataSource.  If I leave the war file in place the
>>servlet cannot create the DataSource.
>>
>>Thanks
>>
>>-----Original Message-----
>>From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
>>Sent: Tuesday, January 16, 2007 2:00 PM
>>To: Tomcat Users List
>>Subject: RE: Cannot create JDBC driver
>>
>>
>>    
>>
>>>From: Ray Madigan [mailto:ray@madigans.org]
>>>Subject: RE: Cannot create JDBC driver
>>>
>>>An interesting twist to the situation is that if I delete
>>>the war file in webapps the Exception does not occur and
>>>the application works.
>>>      
>>>
>>What war file?  You did not mention any in the first message.
>>
>>    
>>
>>>Also, the context.xml is not copied, so I suspect it doesn't
>>>need to be.
>>>      
>>>
>>The context.xml file is only copied when a .war is expanded; if you have
>>both [appname].war and an [appname] directory, things might be a bit
>>confused.
>>
>>    
>>
>>>What causes the application to operate differently when the
>>>war file is present then when it isn't?
>>>      
>>>
>>Sounds like you had both the .war and the expanded app under your
>>appBase directory.  If they weren't identical, there may have been some
>>kind of conflict between them.
>>
>>    
>>
>>><Context path="/Library" docBase="Library"
>>>      
>>>
>>It's an error to specifiy the path or docBase attributes when your
>><Context> element is in META-INF/context.xml; doing so has been known to
>>result in erratic behavior in some levels of Tomcat.
>>
>>- 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
>>
>>    
>>
>>
>


---------------------------------------------------------------------
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: Cannot create JDBC driver

Posted by Martin Gainty <mg...@hotmail.com>.
Ray-

You will need to supply JDBC parameters as in this example Realm specification in server.xml

      <Realm  className="org.apache.catalina.realm.JDBCRealm"
             driverName="org.gjt.mm.mysql.Driver"
          connectionURL="jdbc:mysql://localhost/authority"
         connectionName="D" connectionPassword="******"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />

M-
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
--------------------------------------------------------------------------- 
Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
----- Original Message ----- 
From: "Ray Madigan" <ra...@madigans.org>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Tuesday, January 16, 2007 7:02 PM
Subject: RE: Cannot create JDBC driver


> Well,
> 
> I have to apologize, I was unsure of how much information on the setup
> environment was needed?
> 
> I deploy the application from a war file.  When I delete the war file from
> the webapps directory and leave only the previously extracted directory the
> servlet can create the DataSource.  If I leave the war file in place the
> servlet cannot create the DataSource.
> 
> Thanks
> 
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Sent: Tuesday, January 16, 2007 2:00 PM
> To: Tomcat Users List
> Subject: RE: Cannot create JDBC driver
> 
> 
>> From: Ray Madigan [mailto:ray@madigans.org]
>> Subject: RE: Cannot create JDBC driver
>>
>> An interesting twist to the situation is that if I delete
>> the war file in webapps the Exception does not occur and
>> the application works.
> 
> What war file?  You did not mention any in the first message.
> 
>> Also, the context.xml is not copied, so I suspect it doesn't
>> need to be.
> 
> The context.xml file is only copied when a .war is expanded; if you have
> both [appname].war and an [appname] directory, things might be a bit
> confused.
> 
>> What causes the application to operate differently when the
>> war file is present then when it isn't?
> 
> Sounds like you had both the .war and the expanded app under your
> appBase directory.  If they weren't identical, there may have been some
> kind of conflict between them.
> 
>> <Context path="/Library" docBase="Library"
> 
> It's an error to specifiy the path or docBase attributes when your
> <Context> element is in META-INF/context.xml; doing so has been known to
> result in erratic behavior in some levels of Tomcat.
> 
> - 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: Cannot create JDBC driver

Posted by Ray Madigan <ra...@madigans.org>.
Well,

I have to apologize, I was unsure of how much information on the setup
environment was needed?

I deploy the application from a war file.  When I delete the war file from
the webapps directory and leave only the previously extracted directory the
servlet can create the DataSource.  If I leave the war file in place the
servlet cannot create the DataSource.

Thanks

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Tuesday, January 16, 2007 2:00 PM
To: Tomcat Users List
Subject: RE: Cannot create JDBC driver


> From: Ray Madigan [mailto:ray@madigans.org]
> Subject: RE: Cannot create JDBC driver
>
> An interesting twist to the situation is that if I delete
> the war file in webapps the Exception does not occur and
> the application works.

What war file?  You did not mention any in the first message.

> Also, the context.xml is not copied, so I suspect it doesn't
> need to be.

The context.xml file is only copied when a .war is expanded; if you have
both [appname].war and an [appname] directory, things might be a bit
confused.

> What causes the application to operate differently when the
> war file is present then when it isn't?

Sounds like you had both the .war and the expanded app under your
appBase directory.  If they weren't identical, there may have been some
kind of conflict between them.

> <Context path="/Library" docBase="Library"

It's an error to specifiy the path or docBase attributes when your
<Context> element is in META-INF/context.xml; doing so has been known to
result in erratic behavior in some levels of Tomcat.

 - 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: Cannot create JDBC driver

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Ray Madigan [mailto:ray@madigans.org] 
> Subject: RE: Cannot create JDBC driver
> 
> An interesting twist to the situation is that if I delete
> the war file in webapps the Exception does not occur and
> the application works.

What war file?  You did not mention any in the first message.

> Also, the context.xml is not copied, so I suspect it doesn't
> need to be.

The context.xml file is only copied when a .war is expanded; if you have
both [appname].war and an [appname] directory, things might be a bit
confused.

> What causes the application to operate differently when the 
> war file is present then when it isn't?

Sounds like you had both the .war and the expanded app under your
appBase directory.  If they weren't identical, there may have been some
kind of conflict between them.

> <Context path="/Library" docBase="Library"

It's an error to specifiy the path or docBase attributes when your
<Context> element is in META-INF/context.xml; doing so has been known to
result in erratic behavior in some levels of Tomcat.

 - 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: Cannot create JDBC driver

Posted by Ray Madigan <ra...@madigans.org>.
An interesting twist to the situation is that if I delete the war file in
webapps the Exception does not occur and the application works.  Also, the
context.xml is not copied, so I suspect it doesn't need to be.

What causes the application to operate differently when the war file is
present then when it isn't?

Thanks

-----Original Message-----
From: Ray Madigan [mailto:ray@madigans.org]
Sent: Tuesday, January 16, 2007 12:19 PM
To: Tomcat Users List
Subject: Cannot create JDBC driver


I have beat my head against this one long enough.  I am hoping someone can
help.

I cant get past the error message
SQLException: Cannot create JDBC driver of class ' ' for connect url 'null'

I am using tomcat 5.5.17 and I am attempting to get a JDBC connection in a
servlet using the instructions in the tomcat documentation pages.

My configuration is as follows:

$CATALINA_HOME/conf/server.xml - No changes

$CATALINA_BASE/webapps/Library/WEB-INF/web.xml
<resource-ref>
  <res-ref-name>jdbc/library</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

Between the <welcome... tag and the <taglib tag

$CATALINA_BASE/webapps/Library/META-INF/context.xml
<Context path="/Library" docBase="Library"
         crossContext="true" reloadable="true" debug="1">

  <Resource name="jdbc/library"
            auth="Container"
            type="javax.sql.DataSource"
            driverClassName="org.postgresql.Driver"
            url="jdbc:postgresql://192.xxx.xxx.xx/library"
            username="..."
            password="...."/>
</Context>

Note:  I was under the impression that Tomcat copied this to the
$CATALINA_HOME/conf/Catalina/localhost/Library.xml but it isn't being
copied?


The postgresql JDBC driver and commons-{pool,jdbc,collection}.jar are in
$CATALINA_HOME/common/lib


My servlet source is straight forward

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




---------------------------------------------------------------------
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