You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Fredrik Larsson <fr...@it-huset.se> on 2003/03/11 14:39:29 UTC
Global DataSource
Hi all.
I'm trying to set up a global DataSource on my Tomcat 4.1.18 standalone to
be available to all of my applications installed on the server.
But... I just can't get this to work. I've been following the instructions
in the tomcat documentation but it doesn't help.
I can start the server without any problems and view the global datasource
in the Administration Tool but as soon as I'm trying to access the
datasource from a servlet i get the following exception:
java.sql.SQLException: Cannot load JDBC driver class 'null'.
I've tried to set up the datasource for just one application context and
that works... but that's not what I want.
Another thing is that when I'm trying to view the datasources for one
specific application-context that should use this global datasource I get
this exception:
org.apache.jasper.JasperException: Exception retrieving attribute
'driverClassName'
Has anyone got a clue?
Thanks!
/Fredrik
This is what my conf-files look like:
SERVER.XML
<GlobalNamingResources>
<Resource name="jdbc/MyDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/MyDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>myusername</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/mydb</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
WEB.XML
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/MyDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
SV: Global DataSource
Posted by Fredrik Larsson <fr...@it-huset.se>.
Hi Pratt.
No, I'm doing the look-up from a utility class used by my Action class
(org.apache.struts.action.Action)
/Fredrik
-----Ursprungligt meddelande-----
Från: Tomcat-RND [mailto:tomcatrnd@hotmail.com]
Skickat: den 11 mars 2003 17:55
Till: Tomcat Users List
Ämne: Re: Global DataSource
Hi,
Are looking up the data source in a load-on-startup servlet?
Regards,
Pratt.
----- Original Message -----
From: "Fredrik Larsson" <fr...@it-huset.se>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, March 11, 2003 9:46 PM
Subject: SV: Global DataSource
> I just tried to install the 4.1.21 beta but it didn't help.
>
> Thanks anyway.
>
> /Fredrik
>
> -----Ursprungligt meddelande-----
> Från: Klaasjan Brand [mailto:klaasjan.brand@topicus.nl]
> Skickat: den 11 mars 2003 16:26
> Till: Tomcat Users List
> Ämne: Re: Global DataSource
>
>
> On Tue, 2003-03-11 at 14:39, Fredrik Larsson wrote:
> > Hi all.
> > I can start the server without any problems and view the global
datasource
> > in the Administration Tool but as soon as I'm trying to access the
> > datasource from a servlet i get the following exception:
> > java.sql.SQLException: Cannot load JDBC driver class 'null'.
> >
> > I've tried to set up the datasource for just one application context and
> > that works... but that's not what I want.
>
> I had lots of trouble with JNDI datasources too; it seems there's been
> done some work on this:
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16316
>
> I'd try the 4.1.21 beta to see if it still gives trouble...
>
> Klaasjan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Global DataSource
Posted by Tomcat-RND <to...@hotmail.com>.
Hi,
Are looking up the data source in a load-on-startup servlet?
Regards,
Pratt.
----- Original Message -----
From: "Fredrik Larsson" <fr...@it-huset.se>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, March 11, 2003 9:46 PM
Subject: SV: Global DataSource
> I just tried to install the 4.1.21 beta but it didn't help.
>
> Thanks anyway.
>
> /Fredrik
>
> -----Ursprungligt meddelande-----
> Från: Klaasjan Brand [mailto:klaasjan.brand@topicus.nl]
> Skickat: den 11 mars 2003 16:26
> Till: Tomcat Users List
> Ämne: Re: Global DataSource
>
>
> On Tue, 2003-03-11 at 14:39, Fredrik Larsson wrote:
> > Hi all.
> > I can start the server without any problems and view the global
datasource
> > in the Administration Tool but as soon as I'm trying to access the
> > datasource from a servlet i get the following exception:
> > java.sql.SQLException: Cannot load JDBC driver class 'null'.
> >
> > I've tried to set up the datasource for just one application context and
> > that works... but that's not what I want.
>
> I had lots of trouble with JNDI datasources too; it seems there's been
> done some work on this:
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16316
>
> I'd try the 4.1.21 beta to see if it still gives trouble...
>
> Klaasjan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
SV: Global DataSource
Posted by Fredrik Larsson <fr...@it-huset.se>.
I just tried to install the 4.1.21 beta but it didn't help.
Thanks anyway.
/Fredrik
-----Ursprungligt meddelande-----
Från: Klaasjan Brand [mailto:klaasjan.brand@topicus.nl]
Skickat: den 11 mars 2003 16:26
Till: Tomcat Users List
Ämne: Re: Global DataSource
On Tue, 2003-03-11 at 14:39, Fredrik Larsson wrote:
> Hi all.
> I can start the server without any problems and view the global datasource
> in the Administration Tool but as soon as I'm trying to access the
> datasource from a servlet i get the following exception:
> java.sql.SQLException: Cannot load JDBC driver class 'null'.
>
> I've tried to set up the datasource for just one application context and
> that works... but that's not what I want.
I had lots of trouble with JNDI datasources too; it seems there's been
done some work on this:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16316
I'd try the 4.1.21 beta to see if it still gives trouble...
Klaasjan
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Global DataSource
Posted by Klaasjan Brand <kl...@topicus.nl>.
On Tue, 2003-03-11 at 14:39, Fredrik Larsson wrote:
> Hi all.
> I can start the server without any problems and view the global datasource
> in the Administration Tool but as soon as I'm trying to access the
> datasource from a servlet i get the following exception:
> java.sql.SQLException: Cannot load JDBC driver class 'null'.
>
> I've tried to set up the datasource for just one application context and
> that works... but that's not what I want.
I had lots of trouble with JNDI datasources too; it seems there's been
done some work on this:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16316
I'd try the 4.1.21 beta to see if it still gives trouble...
Klaasjan
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Global DataSource
Posted by Jon Archer <jo...@perceptive.com>.
I have got this working recently with an Oracle database.
Here's what I have in server.xml:
...
<GlobalNamingResources>
<Resource name="my-database" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="my-database">
<parameter>
<name>validationQuery</name>
<value>select sysdate from dual</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>oracle-password</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@server:1521:sid</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>oracle-user</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
...
I then deploy my web app ensuring it has a META-INF/context.xml file as
follows:
<Context path="/demo" debug="0" privileged="true">
<ResourceLink name="jdbc/mydatabase" global="my-database"
type="javax.sql.DataSource"/>
</Context>
My web app can then use the data source with a JNDI name of
"jdbc/mydatabase".
I deploy my web app through via Ant (using the deploy task found in
catalina-ant.jar). I don't think the context.xml gets picked up if you
were to just drop the WAR file in webapps.
Cheers,
Jon
On Tue, 2003-03-11 at 06:39, Fredrik Larsson wrote:
> Hi all.
>
> I'm trying to set up a global DataSource on my Tomcat 4.1.18 standalone to
> be available to all of my applications installed on the server.
>
> But... I just can't get this to work. I've been following the instructions
> in the tomcat documentation but it doesn't help.
>
> I can start the server without any problems and view the global datasource
> in the Administration Tool but as soon as I'm trying to access the
> datasource from a servlet i get the following exception:
> java.sql.SQLException: Cannot load JDBC driver class 'null'.
>
> I've tried to set up the datasource for just one application context and
> that works... but that's not what I want.
>
> Another thing is that when I'm trying to view the datasources for one
> specific application-context that should use this global datasource I get
> this exception:
> org.apache.jasper.JasperException: Exception retrieving attribute
> 'driverClassName'
>
> Has anyone got a clue?
>
> Thanks!
> /Fredrik
>
>
> This is what my conf-files look like:
>
> SERVER.XML
> <GlobalNamingResources>
>
> <Resource name="jdbc/MyDB"
> auth="Container"
> type="javax.sql.DataSource"/>
>
> <ResourceParams name="jdbc/MyDB">
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
>
> <parameter>
> <name>maxActive</name>
> <value>100</value>
> </parameter>
>
> <parameter>
> <name>maxIdle</name>
> <value>30</value>
> </parameter>
>
> <parameter>
> <name>maxWait</name>
> <value>10000</value>
> </parameter>
>
> <parameter>
> <name>username</name>
> <value>myusername</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value></value>
> </parameter>
>
> <parameter>
> <name>driverClassName</name>
> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
>
> <parameter>
> <name>url</name>
> <value>jdbc:mysql://localhost:3306/mydb</value>
> </parameter>
> </ResourceParams>
>
> </GlobalNamingResources>
>
> WEB.XML
> <resource-ref>
> <description>DB Connection</description>
> <res-ref-name>jdbc/MyDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
SV: Global DataSource
Posted by Fredrik Larsson <fr...@it-huset.se>.
Hi again.
I just solved my problem with global datasources in Tomcat.
Instead of putting my <Resource name=....> and <ResourceParams....> in
<GlobalNamingResources></GlobalNamingResources> (which gave me lot's of
trouble and exceptions) I put it in the <DefaultContext></DefaultContext>
and removed <resource-ref> from my web.xml.
I don't know if this is a neat solution but hey, it works. :-)
/Fredrik
-----Ursprungligt meddelande-----
Från: Fredrik Larsson [mailto:fredrik.larsson@it-huset.se]
Skickat: den 11 mars 2003 14:39
Till: tomcat-user@jakarta.apache.org
Ämne: Global DataSource
Hi all.
I'm trying to set up a global DataSource on my Tomcat 4.1.18 standalone to
be available to all of my applications installed on the server.
But... I just can't get this to work. I've been following the instructions
in the tomcat documentation but it doesn't help.
I can start the server without any problems and view the global datasource
in the Administration Tool but as soon as I'm trying to access the
datasource from a servlet i get the following exception:
java.sql.SQLException: Cannot load JDBC driver class 'null'.
I've tried to set up the datasource for just one application context and
that works... but that's not what I want.
Another thing is that when I'm trying to view the datasources for one
specific application-context that should use this global datasource I get
this exception:
org.apache.jasper.JasperException: Exception retrieving attribute
'driverClassName'
Has anyone got a clue?
Thanks!
/Fredrik
This is what my conf-files look like:
SERVER.XML
<GlobalNamingResources>
<Resource name="jdbc/MyDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/MyDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>myusername</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/mydb</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
WEB.XML
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/MyDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org