Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-16 Thread Christopher Schultz
Kawthar,

In my web.xml:
...
jdbc/mySQLDatabase
Does this looks correct? From the exception message, which  class name
is it looking for?
It looks like I have the same stuff that you do. This is my entire 
 element in web.xml:


DataSource for [the] application
jdbc/[ref-name]
javax.sql.DataSource
Container

(Note that I'm using Tomcat 4.1.30)

-chris


signature.asc
Description: OpenPGP digital signature


RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Kawthar Bt M Sulaiman
OK.. now I got a different error message.

"org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver
of class ' ' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver

Is it referring to the url specified under ?
If so, I specified it under
"jdbc:mysql://localhost:3306/ecpa?autoReconnect=true".
where "ecpa" is the database name.

I'm using "mysql-connector-java-3.0.11-bin" jar file under common/lib
directory.
I'm using Tomcat v 4.1.30 and mysql v4.0.18.

Am I missing something else?

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 16/03/2004 01:39:08 PM >>>
Chris and Yiannis,

I've done the configuration as you mentioned, and I still receive the 
same exception... I've also changed the code to use one
context instead of two, still the same exception...

Here's what I have for my config file.

In my server.xml:


  
  
 factory
 org.apache.commons.dbcp.BasicDataSourceFactory
  
  
 driverClassName
 org.gjt.mm.mysql.Driver
  
  
 url

jdbc:mysql://localhost:3306/ecpa?autoReconnect=true
  
  more params
   






In my web.xml:
...
jdbc/mySQLDatabase

Does this looks correct? From the exception message, which  class name
is it looking for?

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 15/03/2004 05:46:33 PM >>>
I have to go by the assumption that everything else regarding the Data
Resource in your 
server.xml and web.xml is correct.
try {
Context ctx = new InitialContext();
dataSource = ( DataSource )
ctx.lookup("java:comp/env/jdbc/yourDB" );   
}
catch (NamingException e1) {
e1.printStackTrace();
}
This is what your code should be doing IMHO, and not creating 2
Context
objects.

Yiannis

-Original Message-----
From: Kawthar Bt M Sulaiman [mailto:[EMAIL PROTECTED] 
Sent: 15 March 2004 08:37
To: [EMAIL PROTECTED] 
Subject: Re: JNDI Datasource Reference in DD Not Necessary?


Hi Harry,

I've been trying to setup my mySQL connection to tomcat as well and
has
been reading a lot of documents on how to do this.  I think I'm
getting
more
confused.

I've setup my params as you suggested below.  When I ran my sample
app, I got the following exception:

javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resoure file: 
   java.naming.factory.initial
 at javax.naming.spi.NamingManager.getInitialContext
 at javax.naming.InitialContext.getDefaultInitCtx
 at javax.naming.InitialContext.getURLOrDefaultInitCtx
 at javax.naming.InitialContext.lookup
 at
com.maxis.app.ContentProcessor.main

Here's my code:
Context ctx = new InitialContext();
Context evtCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) evtCtx.lookup("jdbc/mySQLDatabase");
---> in my web.xml : jdbc/mySQLDatabase
---> in my server.xml: 

Any ideas???

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 10/03/2004 08:05:03 PM >>>
Hi Dave

Sorry for my long absence - I was away from my computer for while.

I think Doug's last message just about says it all in respect of
connection
pools. Follow his advice to use the Tomcat How-Tos exactly as they
are,
and
you should be okay.

I looked through your code - the stuff you originally posted following
my
suggestion to do so - and I did spot one crucial mistake.

This line in your test JSP:


DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/MyDS"
);


Should read:


DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/mysql" );


Spot the difference? :-)

The "jdbc/mysql" context refers to the name given to the resource in
the
context.xml:


Resource name="jdbc/mysql"
   type="com.mysql.jdbc.jdbc2..."
   auth="Container"/>


I would also urge you to go back to using the Commons DBCP resources,
and
specifying the "jdbc/mysql" resource as in the Tomcat How-To - namely,
this
definition:





Should read:





And this ResourceParams element:



factory

com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory




Should read:



factory

org.apache.commons.dbcp.BasicDataSourceFactory




Stick to the Tomcat How-Tos, using the Commons DBCP package, at least
until
you get the thing working, and then you can switch if you want.

Finally, just a suggestion, but I would specify the minimum possible
for the
'url' attribute:



url

jdbc:mysql://localhost:3306/DATABASE

   

RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Kawthar Bt M Sulaiman
Chris and Yiannis,

I've done the configuration as you mentioned, and I still receive the 
same exception... I've also changed the code to use one
context instead of two, still the same exception...

Here's what I have for my config file.

In my server.xml:


  
  
 factory
 org.apache.commons.dbcp.BasicDataSourceFactory
  
  
 driverClassName
 org.gjt.mm.mysql.Driver
  
  
 url

jdbc:mysql://localhost:3306/ecpa?autoReconnect=true
  
  more params
   






In my web.xml:
...
jdbc/mySQLDatabase

Does this looks correct? From the exception message, which  class name
is it looking for?

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 15/03/2004 05:46:33 PM >>>
I have to go by the assumption that everything else regarding the Data
Resource in your 
server.xml and web.xml is correct.
try {
Context ctx = new InitialContext();
dataSource = ( DataSource )
ctx.lookup("java:comp/env/jdbc/yourDB" );   
}
catch (NamingException e1) {
e1.printStackTrace();
}
This is what your code should be doing IMHO, and not creating 2
Context
objects.

Yiannis

-Original Message-
From: Kawthar Bt M Sulaiman [mailto:[EMAIL PROTECTED] 
Sent: 15 March 2004 08:37
To: [EMAIL PROTECTED] 
Subject: Re: JNDI Datasource Reference in DD Not Necessary?


Hi Harry,

I've been trying to setup my mySQL connection to tomcat as well and
has
been reading a lot of documents on how to do this.  I think I'm
getting
more
confused.

I've setup my params as you suggested below.  When I ran my sample
app, I got the following exception:

javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resoure file: 
   java.naming.factory.initial
 at javax.naming.spi.NamingManager.getInitialContext
 at javax.naming.InitialContext.getDefaultInitCtx
 at javax.naming.InitialContext.getURLOrDefaultInitCtx
 at javax.naming.InitialContext.lookup
 at
com.maxis.app.ContentProcessor.main

Here's my code:
Context ctx = new InitialContext();
Context evtCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) evtCtx.lookup("jdbc/mySQLDatabase");
---> in my web.xml : jdbc/mySQLDatabase
---> in my server.xml: 

Any ideas???

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 10/03/2004 08:05:03 PM >>>
Hi Dave

Sorry for my long absence - I was away from my computer for while.

I think Doug's last message just about says it all in respect of
connection
pools. Follow his advice to use the Tomcat How-Tos exactly as they
are,
and
you should be okay.

I looked through your code - the stuff you originally posted following
my
suggestion to do so - and I did spot one crucial mistake.

This line in your test JSP:


DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/MyDS"
);


Should read:


DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/mysql" );


Spot the difference? :-)

The "jdbc/mysql" context refers to the name given to the resource in
the
context.xml:


Resource name="jdbc/mysql"
   type="com.mysql.jdbc.jdbc2..."
   auth="Container"/>


I would also urge you to go back to using the Commons DBCP resources,
and
specifying the "jdbc/mysql" resource as in the Tomcat How-To - namely,
this
definition:





Should read:





And this ResourceParams element:



factory

com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory




Should read:



factory

org.apache.commons.dbcp.BasicDataSourceFactory




Stick to the Tomcat How-Tos, using the Commons DBCP package, at least
until
you get the thing working, and then you can switch if you want.

Finally, just a suggestion, but I would specify the minimum possible
for the
'url' attribute:



url

jdbc:mysql://localhost:3306/DATABASE




Keep it simple, to start with :-) because it could just be one of
those
non-essential parameters is causing the thing to break.

Good luck!

Harry



>> Despite my posting - and I really hope someone chips in concerning
the
>> question I raised about the  being redundant in the
deployment
>> descriptor (!) - the first thing to say is, have faith!
>> 
>> Connection pooling works, and it is actually quite simple, so do
not
give up
>> on it.
> 
> Cheers for the advice Harry... here's where I'm at
> 
> I have no choice on the giving up side of things, need to implement
it
> for some client code I'

Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Christopher Schultz
Kawthar,

I've been trying to setup my mySQL connection to tomcat as well and
has
been reading a lot of documents on how to do this.  I think I'm getting
more
confused.
Context evtCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) evtCtx.lookup("jdbc/mySQLDatabase");
---> in my web.xml : jdbc/mySQLDatabase
---> in my server.xml: 
If you have your data source defined in  then 
you'll need a  element in your  in order to use 
the DataSource.

Other than that, things look good.

-chris


signature.asc
Description: OpenPGP digital signature


Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Harry Mantheakis
Hi Chris

I am afraid I cannot answer most of your questions (!) but I am writing in
because a couple of my earlier postings did not make it through to this mail
list, and it looks like my original question remained unanswered.

The question was answered, and here it is again, for the record.

Basically, my initial concern on this thread was with the 'resource-ref'
element in the deployment descriptor.

As a reminder, this is what the resource-ref element looks like in the
deployment descriptor:



 My DB DataSource
 jdbc/postgres
 javax.sql.DataSource
 Container



My understanding is that Tomcat creates a 'data-source' object and somewhere
along the line wraps it up as a 'javax.sql.DataSource' object, so that when
I get an 'Object' reference to the data-source object I can safely cast it
to 'javax.sql.DataSource', like this:


return ( DataSource )new InitialContext().
lookup( "java:comp/env/jdbc/postgres" );


The suggestion is that another servlet container (Weblogic, etc.) would hand
over some *other* type of data-source object, unless I explicitly inform the
container that I need a 'javax.sql.DataSource' type by including the
'resource-ref' element in my deployment descriptor.

IOW, the 'resource-ref' element in the deployment descriptor is an insurance
policy - it is not, strictly speaking, needed with Tomcat version 5, but
that might not be true with future versions of Tomcat, and likely not to be
true with other servlet containers.

So the 'resource-ref' element is recommended for portability.

I hope that helps!

For the record, my thanks to Yoav Shapira for putting me straight on this.

Kind regards

Harry Mantheakis
London, UK




> All,
> 
> I was just about to ask a question like this thread's today... glad I
> read the archives. ;)
> 
> I have an intersting observation in Tomcat 4.1.29. I found that my
> resource-ref was misnamed in web.xml, so I decided to check it out. A
> long time ago, I wrote a quick-and-dirty JNDI browser to help me figure
> out these things.
> 
> Using my JNDI browser, and looking at the path "java:/comp/env/jdbc" I
> find the following entries:
> 
>*  DSMstandard, class = org.apache.naming.ResourceLinkRef
>* diagnosis, class = org.apache.commons.dbcp.BasicDataSource
> 
> (I have two DataSources configured -- I have to deal w/two DBs, so
> they're both there).
> 
> It's odd that one of them shows up as a ResourceLinkRef and the other as
> a BasicDataSource. (I have no resource-ref elements in my web.xml, for
> testing). They were defined the same way in server.xml:
> 
> 
> auth="Container"
> type="javax.sql.DataSource"/>
> auth="Container"
> type="javax.sql.DataSource"/>
> 
> (I'll spare you the details of the ResourceParams, but they are
> identical except for the name used).
> 
> 
> N.B.: I have my  declaration in 
> because I need to use it for my Realm. Apparently, Resources defined
> within a Context that will use it as a Realm don't work well -- at least
> this was my experience. I found that putting the resource in the global
> resources and then using a ResourceLink did the trick.
> 
> Then, later, within the  that will be using these, I had to add
> these:
> 
> global="jdbc/diagnosis"
>type="javax.sql.DataSource" />
> 
> global="jdbc/DSMstandard"
>type="javax.sql.DataSource" />
> 
> Why wouldn't I get both BasicDataSource objects, or both ResourceLinkRef
> objects?
> 
> I thought it may have to do with the fact that I have the same name for
> the global reference and the local reference, so I changed the global
> references to "jdbc/[dbname]-global" and re-started. I got the exact
> same stuff in that JNDI context.
> 
> Can anyone explain what's going on?
> 
> Logically, I would expect the following:
> 
> 1.  elements in the  would show up for
> all Contexts. If this is true, then why do I need  in my
> context?
> 
> 2.  elements in a  "grant" access to a
> globally-defined resource to that particular Context. Makes sense --
> maybe you have a global resource for convenience, but it's a security
> issue to grant that resource to *any* webapp running on the server. So,
> if this is true, why don't I get two objects of type ResourceLinkRef in
> my context's JNDI namespace? Instead, I get one DataSource and one
> ResourceLinkRef.
> 
> 3.  elements in web.xml should map the local name of a
> resource (the one you use from your webapp in JNDI lookups) to the
> resource mentioned in the Context's  element.
> 
> So, if all that's true, then here's what happens:
> 
>  defines the canonical name for the resource. 
> grants the resource to a particular webapp, possibly re-naming it in the
> process. (This should produce a ResourceLinkRef object in the JNDI
> namespace as seen by the webapp).  adds a 'local'
> reference name to a resource provided by the container. This should add
> another ResourceLinkRef (or something similar) to the JNDI namespace as
> seen by the weba

RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Yiannis Mavroukakis
I have to go by the assumption that everything else regarding the Data
Resource in your 
server.xml and web.xml is correct.
try {
Context ctx = new InitialContext();
dataSource = ( DataSource )
ctx.lookup("java:comp/env/jdbc/yourDB" );   
}
catch (NamingException e1) {
e1.printStackTrace();
}
This is what your code should be doing IMHO, and not creating 2 Context
objects.

Yiannis

-Original Message-
From: Kawthar Bt M Sulaiman [mailto:[EMAIL PROTECTED]
Sent: 15 March 2004 08:37
To: [EMAIL PROTECTED]
Subject: Re: JNDI Datasource Reference in DD Not Necessary?


Hi Harry,

I've been trying to setup my mySQL connection to tomcat as well and
has
been reading a lot of documents on how to do this.  I think I'm getting
more
confused.

I've setup my params as you suggested below.  When I ran my sample
app, I got the following exception:

javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resoure file: 
   java.naming.factory.initial
 at javax.naming.spi.NamingManager.getInitialContext
 at javax.naming.InitialContext.getDefaultInitCtx
 at javax.naming.InitialContext.getURLOrDefaultInitCtx
 at javax.naming.InitialContext.lookup
 at
com.maxis.app.ContentProcessor.main

Here's my code:
Context ctx = new InitialContext();
Context evtCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) evtCtx.lookup("jdbc/mySQLDatabase");
---> in my web.xml : jdbc/mySQLDatabase
---> in my server.xml: 

Any ideas???

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 10/03/2004 08:05:03 PM >>>
Hi Dave

Sorry for my long absence - I was away from my computer for while.

I think Doug's last message just about says it all in respect of
connection
pools. Follow his advice to use the Tomcat How-Tos exactly as they are,
and
you should be okay.

I looked through your code - the stuff you originally posted following
my
suggestion to do so - and I did spot one crucial mistake.

This line in your test JSP:


DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS"
);


Should read:


DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/mysql" );


Spot the difference? :-)

The "jdbc/mysql" context refers to the name given to the resource in
the
context.xml:


Resource name="jdbc/mysql"
   type="com.mysql.jdbc.jdbc2..."
   auth="Container"/>


I would also urge you to go back to using the Commons DBCP resources,
and
specifying the "jdbc/mysql" resource as in the Tomcat How-To - namely,
this
definition:





Should read:





And this ResourceParams element:



factory

com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory




Should read:



factory

org.apache.commons.dbcp.BasicDataSourceFactory




Stick to the Tomcat How-Tos, using the Commons DBCP package, at least
until
you get the thing working, and then you can switch if you want.

Finally, just a suggestion, but I would specify the minimum possible
for the
'url' attribute:



url

jdbc:mysql://localhost:3306/DATABASE




Keep it simple, to start with :-) because it could just be one of
those
non-essential parameters is causing the thing to break.

Good luck!

Harry



>> Despite my posting - and I really hope someone chips in concerning
the
>> question I raised about the  being redundant in the
deployment
>> descriptor (!) - the first thing to say is, have faith!
>> 
>> Connection pooling works, and it is actually quite simple, so do not
give up
>> on it.
> 
> Cheers for the advice Harry... here's where I'm at
> 
> I have no choice on the giving up side of things, need to implement
it
> for some client code I'm working on
> 
> ;-)
> 
> I've been doing a lot of googling to try and get answers so I may
have
> got crossed wires, I had a version working (or thinking it was
working)
> with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy
with
> this solution (preferring to have the connection defined in
> $JAKARTA_HOME/conf/Catalina/localhost/.xml for good
reasons...
> 
> so I'm basically restarting and I now have the following config
> 
> $JAKARTA_HOME/conf/Catalina/localhost/.xml
> 
> 
>  useNaming="false">
> 
>  name="jdbc/mysql"
> type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
> auth="Container"/>
> 
> 
> facto

Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-15 Thread Kawthar Bt M Sulaiman
Hi Harry,

I've been trying to setup my mySQL connection to tomcat as well and
has
been reading a lot of documents on how to do this.  I think I'm getting
more
confused.

I've setup my params as you suggested below.  When I ran my sample
app, I got the following exception:

javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resoure file: 
   java.naming.factory.initial
 at javax.naming.spi.NamingManager.getInitialContext
 at javax.naming.InitialContext.getDefaultInitCtx
 at javax.naming.InitialContext.getURLOrDefaultInitCtx
 at javax.naming.InitialContext.lookup
 at
com.maxis.app.ContentProcessor.main

Here's my code:
Context ctx = new InitialContext();
Context evtCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource) evtCtx.lookup("jdbc/mySQLDatabase");
---> in my web.xml : jdbc/mySQLDatabase
---> in my server.xml: 

Any ideas???

Thanks,
--Kawthar

>>> [EMAIL PROTECTED] 10/03/2004 08:05:03 PM >>>
Hi Dave

Sorry for my long absence - I was away from my computer for while.

I think Doug's last message just about says it all in respect of
connection
pools. Follow his advice to use the Tomcat How-Tos exactly as they are,
and
you should be okay.

I looked through your code - the stuff you originally posted following
my
suggestion to do so - and I did spot one crucial mistake.

This line in your test JSP:


DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS"
);


Should read:


DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/mysql" );


Spot the difference? :-)

The "jdbc/mysql" context refers to the name given to the resource in
the
context.xml:


Resource name="jdbc/mysql"
   type="com.mysql.jdbc.jdbc2..."
   auth="Container"/>


I would also urge you to go back to using the Commons DBCP resources,
and
specifying the "jdbc/mysql" resource as in the Tomcat How-To - namely,
this
definition:





Should read:





And this ResourceParams element:



factory

com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory




Should read:



factory

org.apache.commons.dbcp.BasicDataSourceFactory




Stick to the Tomcat How-Tos, using the Commons DBCP package, at least
until
you get the thing working, and then you can switch if you want.

Finally, just a suggestion, but I would specify the minimum possible
for the
'url' attribute:



url

jdbc:mysql://localhost:3306/DATABASE




Keep it simple, to start with :-) because it could just be one of
those
non-essential parameters is causing the thing to break.

Good luck!

Harry



>> Despite my posting - and I really hope someone chips in concerning
the
>> question I raised about the  being redundant in the
deployment
>> descriptor (!) - the first thing to say is, have faith!
>> 
>> Connection pooling works, and it is actually quite simple, so do not
give up
>> on it.
> 
> Cheers for the advice Harry... here's where I'm at
> 
> I have no choice on the giving up side of things, need to implement
it
> for some client code I'm working on
> 
> ;-)
> 
> I've been doing a lot of googling to try and get answers so I may
have
> got crossed wires, I had a version working (or thinking it was
working)
> with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy
with
> this solution (preferring to have the connection defined in
> $JAKARTA_HOME/conf/Catalina/localhost/.xml for good
reasons...
> 
> so I'm basically restarting and I now have the following config
> 
> $JAKARTA_HOME/conf/Catalina/localhost/.xml
> 
> 
>  useNaming="false">
> 
>  name="jdbc/mysql"
> type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
> auth="Container"/>
> 
> 
> factory
> com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
> 
> 
> port
> 3306
> 
> 
> user
> USERNAME
> 
> 
> password
> PASSWORD
> 
> 
> serverName
> localhost
> 
> 
> databaseName
> DATABASE
> 
> 
> explicitUrl
> true
> 
> 
> url
>
jdbc:mysql://localhost:3306/DATABASE?autoReconnect=true&useUnicode=
>
true&characterEncoding=UTF8&max-connections=50&min-connections=2&a
> mp;inactivity-timeout=30&wait-timeout=30
> 
> 
> 
> 
> The info for the above i gleaned from
> http://www.russellbeattie.com/notebook/1006529.html 
> 
> Then in /WEB-INF/web.xml I have
> 
> http://java.sun.com/xml/ns/j2ee";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4">
> 
> 
> DB connection
> jdbc/mysql
> javax.sql.DataSource
> Container
> 
> 
> 
> Then in my test JSP I have
> try {
> Context ctx = new InitialContext();
> DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS"
);
> Connection conn = ds.getConnection();
> ...
> 
> And the error I get is
> 
> javax.serv

Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-12 Thread Christopher Schultz
All,

I was just about to ask a question like this thread's today... glad I 
read the archives. ;)

I have an intersting observation in Tomcat 4.1.29. I found that my 
resource-ref was misnamed in web.xml, so I decided to check it out. A 
long time ago, I wrote a quick-and-dirty JNDI browser to help me figure 
out these things.

Using my JNDI browser, and looking at the path "java:/comp/env/jdbc" I 
find the following entries:

*  DSMstandard, class = org.apache.naming.ResourceLinkRef
* diagnosis, class = org.apache.commons.dbcp.BasicDataSource
(I have two DataSources configured -- I have to deal w/two DBs, so 
they're both there).

It's odd that one of them shows up as a ResourceLinkRef and the other as 
a BasicDataSource. (I have no resource-ref elements in my web.xml, for 
testing). They were defined the same way in server.xml:




(I'll spare you the details of the ResourceParams, but they are 
identical except for the name used).


N.B.: I have my  declaration in  
because I need to use it for my Realm. Apparently, Resources defined 
within a Context that will use it as a Realm don't work well -- at least 
this was my experience. I found that putting the resource in the global 
resources and then using a ResourceLink did the trick.

Then, later, within the  that will be using these, I had to add 
these:



Why wouldn't I get both BasicDataSource objects, or both ResourceLinkRef 
objects?

I thought it may have to do with the fact that I have the same name for 
the global reference and the local reference, so I changed the global 
references to "jdbc/[dbname]-global" and re-started. I got the exact 
same stuff in that JNDI context.

Can anyone explain what's going on?

Logically, I would expect the following:

1.  elements in the  would show up for 
all Contexts. If this is true, then why do I need  in my 
context?

2.  elements in a  "grant" access to a 
globally-defined resource to that particular Context. Makes sense -- 
maybe you have a global resource for convenience, but it's a security 
issue to grant that resource to *any* webapp running on the server. So, 
if this is true, why don't I get two objects of type ResourceLinkRef in 
my context's JNDI namespace? Instead, I get one DataSource and one 
ResourceLinkRef.

3.  elements in web.xml should map the local name of a 
resource (the one you use from your webapp in JNDI lookups) to the 
resource mentioned in the Context's  element.

So, if all that's true, then here's what happens:

 defines the canonical name for the resource.  
grants the resource to a particular webapp, possibly re-naming it in the 
process. (This should produce a ResourceLinkRef object in the JNDI 
namespace as seen by the webapp).  adds a 'local' 
reference name to a resource provided by the container. This should add 
another ResourceLinkRef (or something similar) to the JNDI namespace as 
seen by the webapp.

Can someone comment on my logic, and show me where I'm making incorrect 
assumptions or missing some crucial detail?

Thanks so much for helping me beat a dead horse. I really want to know 
what's going on. I'm *not* in a position where something's not working, 
so examples for getting things working aren't a ton of help (they pop up 
on the list often, and are in both Tomcat 4.x and 5.x JNDI HOWTOs).

Thanks,
-chris


signature.asc
Description: OpenPGP digital signature


Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-11 Thread Harry Mantheakis
Hi Yoav

I am on a 24 hour response cycle at the moment, because my ISP is saving up
all the Tomcat-User emails and giving them to me once a day somewhere
between the time I go to bed and the time I get up!

This morning I had about 160 'new' messages :-)


> It allows the container to map your portable descriptor in web.xml to
> its specific instance in the container (which is defined in server.xml).
> So resource-ref is the same for your app in your dev, test, and
> production environments, on tomcat, weblogic, websphere, etc.  But the
> container-specific configuration elements change.  It's a way to map
> container-specific resources in a portable and consistent manner.  See
> also env-entry-ref...


Thank you for that explanation. (I always value your time.)

I read it a couple of times, and pondered it for a while, and in the end I
think I understood it (!)

Bearing in mind this is what the resource-ref element looks like in the
deployment descriptor:



 My DB DataSource
 jdbc/postgres
 javax.sql.DataSource
 Container



My understanding of it is that, even though I can get away without declaring
that element in my Tomcat deployment, I would need to restore it if I was to
deploy my application to (say) Weblogic, Websphere, etc.

That implies that the 'container-specific configuration' in Tomcat is to
actually use 'javax.sql.DataSource' as the resource type. IOW, the Tomcat
container creates a 'data-source' object and somewhere along the line it
wraps it up as a 'javax.sql.DataSource' object, so that when I get an
'Object' reference to it I can safely cast it to 'javax.sql.DataSource'.

That is what happens when I call:


return ( DataSource )new InitialContext().
lookup( "java:comp/env/jdbc/postgres" );


The suggestion is that on another container (Weblogic, etc.) would handed
some *other* type of data-source object, unless I informed the container
that I need a 'javax.sql.DataSource' type by including the resource-ref
element in my deployment descriptor.

If that 'understanding' is correct, Yoav, just say 'yes' or 'yep' or
something simple like that :-)

Kind regards

Harry Mantheakis
London, UK



















-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread Shapira, Yoav

Hi,

>What I cannot figure out is: what does the 'resource-ref' element in
the
>deployment descriptor *actually* do?

It allows the container to map your portable descriptor in web.xml to
its specific instance in the container (which is defined in server.xml).
So resource-ref is the same for your app in your dev, test, and
production environments, on tomcat, weblogic, websphere, etc.  But the
container-specific configuration elements change.  It's a way to map
container-specific resources in a portable and consistent manner.  See
also env-entry-ref...

Yoav Shapira




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread Harry Mantheakis
Hi Yoav


> I'm fairly sure you'd understand them just fine ;)


Well, I read both specs, the J2EE section 5.4 being the relevant one here,
and I am sorry to say but I think I am a little more confused now than
before!

It was good to see this bit of succinct code being sanctioned:


javax.sql.DataSource ds = (javax.sql.DataSource)
initCtx.lookup("java:comp/env/jdbc/EmployeeAppDB");


I actually arrived at that on my own, so I guess my Java instincts are not
so bad after all.

What I cannot figure out is: what does the 'resource-ref' element in the
deployment descriptor *actually* do?

What is its function, and am I breaking something by not having it there at
all?

You wrote:


> Even though in tomcat's current implementation resource-ref might not be
> strictly required under certain conditions, you should include it as the
> tomcat documentation suggestions, for completeness, portability, and
> spec compliance.


Which suggests that *perhaps* for a stand-alone Tomcat server this element
is not needed.

I guess I might (time permitting) post a question on Server-Side and see if
one of the J2EE boffins can shed any light on this.

Please do not get me wrong about this: I am just trying to understand what
the code I am using in my application is doing - or not doing :-)

Many thanks, and kind regards

BTW - the Ant 'filtering' trick you put me onto works a treat. Fantastic.
Ant should be mandatory learning!

Harry Mantheakis
London, UK


> Hi,
> 
>> I use Tomcat as a stand-alone server, but in the back of my mind I know
>> there are J2EE specifications that Tomcat is adhering to which I am
> likely
>> not to understand.
> 
> I'm fairly sure you'd understand them just fine ;)  It's SRV.9.11 in the
> Servlet Specification 2.4 and J2EE.5 in the J2EE Specification v1.4.
> Even though in tomcat's current implementation resource-ref might not be
> strictly required under certain conditions, you should include it as the
> tomcat documentation suggestions, for completeness, portability, and
> spec compliance.
> 
> Yoav Shapira
> 
> 
> 
> This e-mail, including any attachments, is a confidential business
> communication, and may contain information that is confidential, proprietary
> and/or privileged.  This e-mail is intended only for the individual(s) to whom
> it is addressed, and may not be saved, copied, printed, disclosed or used by
> anyone else.  If you are not the(an) intended recipient, please immediately
> delete this e-mail from your computer system and notify the sender.  Thank
> you.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread David Smith
> Sorry for my long absence - I was away from my computer for while.

No worries in that time I managed to get the test one working and also
the one that I need for my app (and posted my solution to the process in
detail as a semi-definitive way of making it work in TC 5)

The problem was I'd got some stuff from a book, some from links etc.
however i worked through the how-to this morning and got it working
(although as far as i'm concerned the doco could do with an update
regarding the use of server.xml and Catalina/localhost/.xml

Cheers for the help
-- 
David Smith <[EMAIL PROTECTED]>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread Harry Mantheakis
Hi Yoav

Thanks for your message.


> I'm fairly sure you'd understand them just fine ;)  It's SRV.9.11 in the
> Servlet Specification 2.4 and J2EE.5 in the J2EE Specification v1.4.


Okay, I shall look at those and see what happens :-)


> Even though in tomcat's current implementation resource-ref might not be
> strictly required under certain conditions, you should include it as the
> tomcat documentation suggestions, for completeness, portability, and
> spec compliance.


Yes, point taken. I was really trying to figure out what resource-ref is
meant for - hopefully the specs will sort me out.

I shall post a follow up in due course.

Kind regards

Harry


> Hi,
> 
>> I use Tomcat as a stand-alone server, but in the back of my mind I know
>> there are J2EE specifications that Tomcat is adhering to which I am
> likely
>> not to understand.
> 
> I'm fairly sure you'd understand them just fine ;)  It's SRV.9.11 in the
> Servlet Specification 2.4 and J2EE.5 in the J2EE Specification v1.4.
> Even though in tomcat's current implementation resource-ref might not be
> strictly required under certain conditions, you should include it as the
> tomcat documentation suggestions, for completeness, portability, and
> spec compliance.
> 
> Yoav Shapira
> 
> 
> 
> This e-mail, including any attachments, is a confidential business
> communication, and may contain information that is confidential, proprietary
> and/or privileged.  This e-mail is intended only for the individual(s) to whom
> it is addressed, and may not be saved, copied, printed, disclosed or used by
> anyone else.  If you are not the(an) intended recipient, please immediately
> delete this e-mail from your computer system and notify the sender.  Thank
> you.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread Harry Mantheakis
Hi Dave

Sorry for my long absence - I was away from my computer for while.

I think Doug's last message just about says it all in respect of connection
pools. Follow his advice to use the Tomcat How-Tos exactly as they are, and
you should be okay.

I looked through your code - the stuff you originally posted following my
suggestion to do so - and I did spot one crucial mistake.

This line in your test JSP:


DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS" );


Should read:


DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/mysql" );


Spot the difference? :-)

The "jdbc/mysql" context refers to the name given to the resource in the
context.xml:


Resource name="jdbc/mysql"
   type="com.mysql.jdbc.jdbc2..."
   auth="Container"/>


I would also urge you to go back to using the Commons DBCP resources, and
specifying the "jdbc/mysql" resource as in the Tomcat How-To - namely, this
definition:





Should read:





And this ResourceParams element:



factory

com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory




Should read:



factory

org.apache.commons.dbcp.BasicDataSourceFactory




Stick to the Tomcat How-Tos, using the Commons DBCP package, at least until
you get the thing working, and then you can switch if you want.

Finally, just a suggestion, but I would specify the minimum possible for the
'url' attribute:



url

jdbc:mysql://localhost:3306/DATABASE




Keep it simple, to start with :-) because it could just be one of those
non-essential parameters is causing the thing to break.

Good luck!

Harry



>> Despite my posting - and I really hope someone chips in concerning the
>> question I raised about the  being redundant in the deployment
>> descriptor (!) - the first thing to say is, have faith!
>> 
>> Connection pooling works, and it is actually quite simple, so do not give up
>> on it.
> 
> Cheers for the advice Harry... here's where I'm at
> 
> I have no choice on the giving up side of things, need to implement it
> for some client code I'm working on
> 
> ;-)
> 
> I've been doing a lot of googling to try and get answers so I may have
> got crossed wires, I had a version working (or thinking it was working)
> with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy with
> this solution (preferring to have the connection defined in
> $JAKARTA_HOME/conf/Catalina/localhost/.xml for good reasons...
> 
> so I'm basically restarting and I now have the following config
> 
> $JAKARTA_HOME/conf/Catalina/localhost/.xml
> 
> 
>  useNaming="false">
> 
>  name="jdbc/mysql"
> type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
> auth="Container"/>
> 
> 
> factory
> com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
> 
> 
> port
> 3306
> 
> 
> user
> USERNAME
> 
> 
> password
> PASSWORD
> 
> 
> serverName
> localhost
> 
> 
> databaseName
> DATABASE
> 
> 
> explicitUrl
> true
> 
> 
> url
> jdbc:mysql://localhost:3306/DATABASE?autoReconnect=true&useUnicode=
> true&characterEncoding=UTF8&max-connections=50&min-connections=2&a
> mp;inactivity-timeout=30&wait-timeout=30
> 
> 
> 
> 
> The info for the above i gleaned from
> http://www.russellbeattie.com/notebook/1006529.html
> 
> Then in /WEB-INF/web.xml I have
> 
> http://java.sun.com/xml/ns/j2ee";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4">
> 
> 
> DB connection
> jdbc/mysql
> javax.sql.DataSource
> Container
> 
> 
> 
> Then in my test JSP I have
> try {
> Context ctx = new InitialContext();
> DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS" );
> Connection conn = ds.getConnection();
> ...
> 
> And the error I get is
> 
> javax.servlet.ServletException: Name java:comp is not bound in this
> Context
> 
> Which is an error I've managed to hit several times, I know the whole
> connection pooling is the right way to go about this, just surprised at
> how long it is taking me to get going (I dread to think what it will be
> like installing this live with the client, but I'll save that happy
> thought for later)
> 
> As ever any help much appreciated... (and if the person who helps me to
> get this working is ever in London I'll stand them a beer or 3)
> 
> ;-)
> 
> TIA
> Dave


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread David Smith
Ok for completeness...

This morning with a fresh start I managed to get the connection
working... this is my solution (hope it is of use to someone) thanks for
all the help and tips people gave me.

Environment :
Fedora Core 1
Tomcat 5.0.19
Apache 2.x
Java 1.4.2_03

Without using the admin tool in tomcat (as I'm not convinced about it) I
created the following, this is based on the example DBTest from
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html 
$CATALINA_HOME/webapps/DBTest/test.jsp


  
DB Test
  
  
 
  <%
foo.DBTest tst = new foo.DBTest();
tst.init();
  %>
 
  Results
Foo <%= tst.getFoo() %>
Bar <%= tst.getBar() %>
 
  


$CATALINA_HOME/webapps/DBTest/WEB-INF/classes/foo/DBTest.java

package foo;
 
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
 
public class DBTest {

  String foo = "Not Connected";
  int bar = -1;

  public void init() {
try{
  Context ctx = new InitialContext();
  if ( ctx == null ) {
throw new Exception( "Boom - No Context" );
  }

  DataSource ds = ( DataSource )ctx.lookup(
"java:comp/env/jdbc/TestDB" );
 
  if (ds != null) {
Connection conn = ds.getConnection();
 
if(conn != null)  {
  foo = "Got Connection "+conn.toString();
  Statement stmt = conn.createStatement();
  ResultSet rst = stmt.executeQuery( "SELECT id, foo, bar  FROM
testdata" );
  if ( rst.next() ) {
foo=rst.getString(2);
bar=rst.getInt(3);
  }
  conn.close();
}
  }
} catch( Exception e ) {
  e.printStackTrace();
}
  }
 
  public String getFoo() { return foo; }
  public int getBar() { return bar;}
}

$CATALINA_HOME/webapps/DBTest/WEB-INF/web.xml


http://java.sun.com/dtd/web-app_2_3.dtd";>

  MySQL Test App
  
  DB Connection
  jdbc/TestDB
  javax.sql.DataSource
  Container
  


$CATALINA_HOME/conf/Catalina/localhost/DBTest.xml


  
  
  
  
  

  factory
  org.apache.commons.dbcp.BasicDataSourceFactory

  


  maxActive
  100

  


  maxIdle
  30

  


  maxWait
  1

  


 username
 javauser


 password
 javadude

  


   driverClassName
   com.mysql.jdbc.Driver

  


  url
 
jdbc:mysql://localhost:3306/javatest?autoReconnect=true

  
  


I compiled DBTest.java started up tomcat and went to
localhost:8080/DBTest/test.jsp initially I had an error but that was due
to the privileges being wrong for the MySQL user (the connection was
using the server domain name rather than localhost) once that was sorted
out (MySQL privileges change in this case) the example then worked.

Anyway, as I said at the top thanks to anyone that passed on some tips.

;-)

Off to do the rest of the code I need for this app now

Regards
Dave

-- 
David Smith <[EMAIL PROTECTED]>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-10 Thread David Smith
> i assume you have tomcat 5 and apache 2 linked together, right? If so, what
> connector did you use to link Apache 2 and Tomcat 5?

mod_jk2 but in this instance, i'm not using Apache and i'm calling my
test code via localhost:8080
-- 
David Smith <[EMAIL PROTECTED]>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Parsons Technical Services
> Well in the localhost directory I have an .xml for each Web App
in
> the system, it contains a context tag (going from memory at the moment as
> I'm not in front of the server)
>

This is a new feature in TC5

> > i defined the resource in server.xml.
>
> Guess that will be something for me to try tomorrow.
>

If you do you will have to restart Tomcat before it will work.

If you place it inside the GlobalNamingResource tag you will need to add the
following to the context tag:




Otherwise place it in the context tag you create for your application.
Remember if you define it here you don't need the .xml.

Just some hints:

Watch your case and spelling.

Try a direct connection without the connection pool to test the rest of the
setup(name, password, drivers, etc).

Set things up exactly as the example says. Only change what you absolutely
must, which should be nothing. Once you are running you can then make
changes to suit. This caused me a lot of grief.

DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/mysql" );
must match
jdbc/mysql in web.xml
must match
name="jdbc/mysql" in server or .xml

Same goes for your type tags as well. Your original post of your config
files didn't match in type or name.

If you use the latest stable MySQL jdbc drivers, the type is
"javax.sql.DataSource"

Use this as a guide:
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html

Good Luck

Doug

www.parsonstechnical.com







-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Paul
i assume you have tomcat 5 and apache 2 linked together, right? If so, what
connector did you use to link Apache 2 and Tomcat 5?
-paul

- Original Message - 
From: "David Smith" <[EMAIL PROTECTED]>
To: "'Paul'" <[EMAIL PROTECTED]>; "'Tomcat Users List'"
<[EMAIL PROTECTED]>
Sent: Tuesday, March 09, 2004 3:31 PM
Subject: RE: JNDI Datasource Reference in DD Not Necessary?


> > i have never heard of this config file:
> > $CATALINA_HOME/conf/Catalina/localhost/.xml
>
> Well in the localhost directory I have an .xml for each Web App
in
> the system, it contains a context tag (going from memory at the moment as
> I'm not in front of the server)
>
> > i defined the resource in server.xml.
>
> Guess that will be something for me to try tomorrow.
>
> > i use Tomcat 4 myself.  Did you post your server.xml and
> > web.xml files?
>
> This is Tomcat 5
>
> I'm going to try using server.xml tomorrow, I'll post up my results
>
> Regards
> Dave
>
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread David Smith
> i have never heard of this config file:
> $CATALINA_HOME/conf/Catalina/localhost/.xml

Well in the localhost directory I have an .xml for each Web App in
the system, it contains a context tag (going from memory at the moment as
I'm not in front of the server)

> i defined the resource in server.xml.

Guess that will be something for me to try tomorrow.

> i use Tomcat 4 myself.  Did you post your server.xml and 
> web.xml files?

This is Tomcat 5

I'm going to try using server.xml tomorrow, I'll post up my results

Regards
Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Paul
i have never heard of this config file:
$CATALINA_HOME/conf/Catalina/localhost/.xml

i defined the resource in server.xml.
i use Tomcat 4 myself.  Did you post your server.xml and web.xml files?
-paul.


- Original Message - 
From: "David Smith" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, March 09, 2004 1:52 PM
Subject: Re: JNDI Datasource Reference in DD Not Necessary?


> > that error looks like a name is specified incorrectly in web.xml file,
> > either the global name of the datasource or the local name of that
> > connection to the global data source more likely.
> > 
> > the local instance of the global data source name should be specified
> > explicity in a server.xml context and explicity in the web.xml file.
> 
> Checked that (several times) and all names tie in
> 
> is there a difference in having the connection defined in
> $CATALINA_HOME/conf/server.xml or in
> $CATALINA_HOME/conf/Catalina/localhost/.xml
> 
> (I'm using Tomcat 5.0.19)
> 
> My app context and connection is currently defined in .xml
> 
> Have to say I don't feel i'm getting any closer with this at the
> moment...
> 
> I may start the whole thing again tomorrow morning and just build the
> example to see if i can get it working...
> 
> any other suggestions ?
> 
> (Cheers for all the help so far)
> -- 
> David Smith <[EMAIL PROTECTED]>
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread David Smith
> that error looks like a name is specified incorrectly in web.xml file,
> either the global name of the datasource or the local name of that
> connection to the global data source more likely.
> 
> the local instance of the global data source name should be specified
> explicity in a server.xml context and explicity in the web.xml file.

Checked that (several times) and all names tie in

is there a difference in having the connection defined in
$CATALINA_HOME/conf/server.xml or in
$CATALINA_HOME/conf/Catalina/localhost/.xml

(I'm using Tomcat 5.0.19)

My app context and connection is currently defined in .xml

Have to say I don't feel i'm getting any closer with this at the
moment...

I may start the whole thing again tomorrow morning and just build the
example to see if i can get it working...

any other suggestions ?

(Cheers for all the help so far)
-- 
David Smith <[EMAIL PROTECTED]>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Paul
that error looks like a name is specified incorrectly in web.xml file,
either the global name of the datasource or the local name of that
connection to the global data source more likely.

the local instance of the global data source name should be specified
explicity in a server.xml context and explicity in the web.xml file.
-paul.

- Original Message - 
From: "David Smith" <[EMAIL PROTECTED]>
To: "Mark Matthews" <[EMAIL PROTECTED]>
Cc: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, March 09, 2004 1:26 PM
Subject: Re: JNDI Datasource Reference in DD Not Necessary?


> > You don't want to do this, as Tomcat's DBCP doesn't wrap connection pool
> > data sources currently (or if they do, I can't find it documented
anywhere).
> >
> > If you follow the example given in the Tomcat documentation
> > _to_the_letter_ things work out fine. Once you have _that_ working, then
> > start tweaking from there. I've found that trying to plug the right
> > magic values from scratch into server.xml never works as you'd expect.
>
> Ok i've tried following the example
>
> http://200.10.10.14:8080/tomcat-docs/jndi-datasource-examples-howto.html
>
> using the 3.1.x alpha MySQL / JDBC connector and I've tried with the 2.x
> version of the MySQL / JDBC connector and I'm still getting no dice, the
> error is
>
> javax.naming.NameNotFoundException: Name java:comp is not bound in this
> Context
>
> and the only thing changed from the example in the DOCs for the MySQL
> DBCP Example is change the DB name.
>
> I've got the server.xml config (from the example) in the
> $CATALINA_HOME/conf/Catalina/localhost/app_name.xml file instead as it
> seems the most logical place for it (no contexts in the server.xml in TC
> 5 it would seem)
>
> I'm clearly missing something simple here...
>
> TIA for any help
> -- 
> David Smith <[EMAIL PROTECTED]>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread David Smith
> You don't want to do this, as Tomcat's DBCP doesn't wrap connection pool
> data sources currently (or if they do, I can't find it documented anywhere).
> 
> If you follow the example given in the Tomcat documentation
> _to_the_letter_ things work out fine. Once you have _that_ working, then
> start tweaking from there. I've found that trying to plug the right
> magic values from scratch into server.xml never works as you'd expect.

Ok i've tried following the example

http://200.10.10.14:8080/tomcat-docs/jndi-datasource-examples-howto.html

using the 3.1.x alpha MySQL / JDBC connector and I've tried with the 2.x
version of the MySQL / JDBC connector and I'm still getting no dice, the
error is

javax.naming.NameNotFoundException: Name java:comp is not bound in this
Context

and the only thing changed from the example in the DOCs for the MySQL
DBCP Example is change the DB name.

I've got the server.xml config (from the example) in the
$CATALINA_HOME/conf/Catalina/localhost/app_name.xml file instead as it
seems the most logical place for it (no contexts in the server.xml in TC
5 it would seem)

I'm clearly missing something simple here...

TIA for any help
-- 
David Smith <[EMAIL PROTECTED]>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Shapira, Yoav

Hi,

>I use Tomcat as a stand-alone server, but in the back of my mind I know
>there are J2EE specifications that Tomcat is adhering to which I am
likely
>not to understand.

I'm fairly sure you'd understand them just fine ;)  It's SRV.9.11 in the
Servlet Specification 2.4 and J2EE.5 in the J2EE Specification v1.4.
Even though in tomcat's current implementation resource-ref might not be
strictly required under certain conditions, you should include it as the
tomcat documentation suggestions, for completeness, portability, and
spec compliance.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Mark Matthews
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

David Smith wrote:
>>Despite my posting - and I really hope someone chips in concerning the
>>question I raised about the  being redundant in the
deployment
>>descriptor (!) - the first thing to say is, have faith!
>>
>>Connection pooling works, and it is actually quite simple, so do not
give up
>>on it.
>
>
> Cheers for the advice Harry... here's where I'm at
>
> I have no choice on the giving up side of things, need to implement it
> for some client code I'm working on
>
> ;-)
>
> I've been doing a lot of googling to try and get answers so I may have
> got crossed wires, I had a version working (or thinking it was working)
> with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy with
> this solution (preferring to have the connection defined in
> $JAKARTA_HOME/conf/Catalina/localhost/.xml for good reasons...
>
> so I'm basically restarting and I now have the following config
>
> $JAKARTA_HOME/conf/Catalina/localhost/.xml
>
> 
>  useNaming="false">
>
>name="jdbc/mysql"
>   type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
>   auth="Container"/>

Dave,

You don't want to do this, as Tomcat's DBCP doesn't wrap connection pool
data sources currently (or if they do, I can't find it documented anywhere).

If you follow the example given in the Tomcat documentation
_to_the_letter_ things work out fine. Once you have _that_ working, then
start tweaking from there. I've found that trying to plug the right
magic values from scratch into server.xml never works as you'd expect.

Regards,

-Mark
- --
Mr. Mark Matthews
MySQL AB, Software Development Manager, J2EE and Windows Platforms
Office: +1 708 332 0507
www.mysql.com

Meet the MySQL Team! April 14-16, 2004 http://www.mysql.com/uc2004/
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFATfR1tvXNTca6JD8RAmfvAJ9dkmmyQmwAht6DmAsB/OrZPiiKVgCePuVs
Zqkj0tMidrTKUMuAX5b3ekA=
=Q5rH
-END PGP SIGNATURE-

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Shapira, Yoav

Hi,
Here's a thought: since you're already declining to use tomcat's
built-in DBCP support, why not go really portable and do the pooling
yourself in your own app?  (This would necessitate zero or little code
writing on your behalf).

Yes, you'd have environment-specific WAR files, but the overall
development, deployment, and configuration is much simpler and easier to
debug.  And you'd be server-agnostic!

Just a thought...

Yoav Shapira
Millennium ChemInformatics


>-Original Message-
>From: David Smith [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, March 09, 2004 11:25 AM
>To: Tomcat Users List
>Subject: Re: JNDI Datasource Reference in DD Not Necessary?
>
>> Despite my posting - and I really hope someone chips in concerning
the
>> question I raised about the  being redundant in the
>deployment
>> descriptor (!) - the first thing to say is, have faith!
>>
>> Connection pooling works, and it is actually quite simple, so do not
give
>up
>> on it.
>
>Cheers for the advice Harry... here's where I'm at
>
>I have no choice on the giving up side of things, need to implement it
>for some client code I'm working on
>
>;-)
>
>I've been doing a lot of googling to try and get answers so I may have
>got crossed wires, I had a version working (or thinking it was working)
>with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy with
>this solution (preferring to have the connection defined in
>$JAKARTA_HOME/conf/Catalina/localhost/.xml for good
reasons...
>
>so I'm basically restarting and I now have the following config
>
>$JAKARTA_HOME/conf/Catalina/localhost/.xml
>
>
>useNaming="false">
>
>   name="jdbc/mysql"
>
type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
>   auth="Container"/>
>   
>   
>   factory
>
>
com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory
>   
>   
>   port
>   3306
>   
>   
>   user
>   USERNAME
>   
>   
>   password
>   PASSWORD
>   
>   
>   serverName
>   localhost
>   
>   
>   databaseName
>   DATABASE
>   
>   
>   explicitUrl
>   true
>   
>   
>   url
>
>
jdbc:mysql://localhost:3306/DATABASE?autoReconnect=true&us
>eUnicode=true&characterEncoding=UTF8&max-connections=50&min
-
>connections=2&inactivity-timeout=30&wait-timeout=30
>   
>   
>
>
>The info for the above i gleaned from
>http://www.russellbeattie.com/notebook/1006529.html
>
>Then in /WEB-INF/web.xml I have
>
>http://java.sun.com/xml/ns/j2ee";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4">
>
>   
>   DB connection
>   jdbc/mysql
>   javax.sql.DataSource
>   Container
>   
>
>
>Then in my test JSP I have
>try {
>   Context ctx = new InitialContext();
>   DataSource ds = ( DataSource )
ctx.lookup("java:comp/env/jdbc/MyDS"
>);
>   Connection conn = ds.getConnection();
>...
>
>And the error I get is
>
>javax.servlet.ServletException: Name java:comp is not bound in this
>Context
>
>Which is an error I've managed to hit several times, I know the whole
>connection pooling is the right way to go about this, just surprised at
>how long it is taking me to get going (I dread to think what it will be
>like installing this live with the client, but I'll save that happy
>thought for later)
>
>As ever any help much appreciated... (and if the person who helps me to
>get this working is ever in London I'll stand them a beer or 3)
>
>;-)
>
>TIA
>Dave
>--
>David Smith <[EMAIL PROTECTED]>
>
>-
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Harry Mantheakis
Hi Yoav

> The documentation is updated, but of course no documentation set is ever
> perfect.  If you have documentation patches, please suggest them in the
> usual format (http://jakarta.apache.org/site/source.html#Patches) as all
> our docs are in CVS
> (http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-catalina/webapps/docs/
> ).  Thanks,
> 
> Yoav Shapira

I'd be happy to help with the documentation, except I want to make sure I am
not overlooking something - possibly something vital!

I use Tomcat as a stand-alone server, but in the back of my mind I know
there are J2EE specifications that Tomcat is adhering to which I am likely
not to understand.

My initial question concerned the  element in the deployment
descriptor being redundant, at least with Tomcat set up as a stand alone
server.

Is it redundant, or am I missing something?

If it is redundant, I shall happy to write some amended documentation and
offer it up.

Many thanks, and kind regards

Harry Mantheakis
London, UK



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread David Smith
> Despite my posting - and I really hope someone chips in concerning the
> question I raised about the  being redundant in the deployment
> descriptor (!) - the first thing to say is, have faith!
> 
> Connection pooling works, and it is actually quite simple, so do not give up
> on it.

Cheers for the advice Harry... here's where I'm at

I have no choice on the giving up side of things, need to implement it
for some client code I'm working on

;-)

I've been doing a lot of googling to try and get answers so I may have
got crossed wires, I had a version working (or thinking it was working)
with the info in $JAKARTA_HOME/conf/server.xml but I wasn't happy with
this solution (preferring to have the connection defined in
$JAKARTA_HOME/conf/Catalina/localhost/.xml for good reasons...

so I'm basically restarting and I now have the following config

$JAKARTA_HOME/conf/Catalina/localhost/.xml







factory

com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory


port
3306


user
USERNAME


password
PASSWORD


serverName
localhost


databaseName
DATABASE


explicitUrl
true


url

jdbc:mysql://localhost:3306/DATABASE?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&max-connections=50&min-connections=2&inactivity-timeout=30&wait-timeout=30




The info for the above i gleaned from
http://www.russellbeattie.com/notebook/1006529.html

Then in /WEB-INF/web.xml I have

http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; version="2.4">


DB connection
jdbc/mysql
javax.sql.DataSource
Container



Then in my test JSP I have
try {
Context ctx = new InitialContext();
DataSource ds = ( DataSource ) ctx.lookup("java:comp/env/jdbc/MyDS" );
Connection conn = ds.getConnection();
...

And the error I get is

javax.servlet.ServletException: Name java:comp is not bound in this
Context

Which is an error I've managed to hit several times, I know the whole
connection pooling is the right way to go about this, just surprised at
how long it is taking me to get going (I dread to think what it will be
like installing this live with the client, but I'll save that happy
thought for later)

As ever any help much appreciated... (and if the person who helps me to
get this working is ever in London I'll stand them a beer or 3)

;-)

TIA
Dave
-- 
David Smith <[EMAIL PROTECTED]>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Harry Mantheakis
Hi Dave

Despite my posting - and I really hope someone chips in concerning the
question I raised about the  being redundant in the deployment
descriptor (!) - the first thing to say is, have faith!

Connection pooling works, and it is actually quite simple, so do not give up
on it.

> I've tried having the connection defined in
> $JAKARTA_HOME/conf/server.xml and in
> $JAKARTA_HOME/Catalina/localhost/.xml

Stick to the app-name.xml - do not put anything in the server.xml.

You need to tell us what errors you are getting.

It will also help if you copy and paste the *exact code* elements from the
app-name.xml, and the method that is trying to look up the DataSource.

The context fragment bit should look like this:





...



The deployment descriptor bit should look like this:



DB Connection
jdbc/postgres
javax.sql.DataSource
Container



And then the JNDI lookup method should look like this:


public DataSource getDataSource() {
try {
return ( DataSource )new InitialContext().
lookup( "java:comp/env/jdbc/postgres" );
} catch ( ... ) {
...
}
}


The above can be written in a more long-winded way, but that one line does
the job.

Harry


> I have to say I'm having a large number of issues with JNDI and MySQL
> 
> I'm using TC 5 on Fedora Core 1 with the JDBC / MySQL 3.1.1 Alpha
> Connector (after I had no luck getting the 3.0.11 Stable connector
> working either)
> 
> I've been looking at various how-to's and other doco on the whole thing
> but don't seem to be getting very far with the whole thing.
> 
> I've tried having the connection defined in
> $JAKARTA_HOME/conf/server.xml and in
> $JAKARTA_HOME/Catalina/localhost/.xml
> 
> I have resource-ref defined in the /WEB-INF/web.xml but in
> spite of all this I seem to be getting nowhere... (which is a pain) I've
> managed to create a straight JDBC connection though so I know that the
> DB is accepting connections on the relevant user.
> 
> TIA


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Hofmann, Benjamin
Thanks.  I do have some suggestions for the JNDI Datasource How-to page.  As
I was working through the issues and checking the message boards, there
seems to be a lot of confusion.  The application contexts are handled
differently in Tomcat 5 and people are missing essential xml tags.  Also,
the deprecated abandoned handlers should be removed or at least tagged as
deprecated.

I'll think about it and submit a thought out suggestion.

-Original Message-
From: Shapira, Yoav [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 09, 2004 8:34 AM
To: Tomcat Users List
Subject: RE: JNDI Datasource Reference in DD Not Necessary?


Hi,

>I've spent the last couple of days familiarizing myself with the new
>5.0.19,
>especially the JNDI connection pooling.  I tried, unsuccessfully, to
use
>the
>admin console to set up JDNI datasources as well as editing the xml
files
>directly following the instructions in the documentation.  The only way
I
>was able to get the connection pooling to work was to manually create a
>context in the server.xml and add the resources there.  This worked
great.
>The documentation for Tomcat 5 looks suspiciously like the Tomcat 4 so
I
>think it is not updated yet.

The documentation is updated, but of course no documentation set is ever
perfect.  If you have documentation patches, please suggest them in the
usual format (http://jakarta.apache.org/site/source.html#Patches) as all
our docs are in CVS
(http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-catalina/webapps/docs/
).  Thanks,

Yoav Shapira



This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Shapira, Yoav

Hi,

>I've spent the last couple of days familiarizing myself with the new
>5.0.19,
>especially the JNDI connection pooling.  I tried, unsuccessfully, to
use
>the
>admin console to set up JDNI datasources as well as editing the xml
files
>directly following the instructions in the documentation.  The only way
I
>was able to get the connection pooling to work was to manually create a
>context in the server.xml and add the resources there.  This worked
great.
>The documentation for Tomcat 5 looks suspiciously like the Tomcat 4 so
I
>think it is not updated yet.

The documentation is updated, but of course no documentation set is ever
perfect.  If you have documentation patches, please suggest them in the
usual format (http://jakarta.apache.org/site/source.html#Patches) as all
our docs are in CVS
(http://cvs.apache.org/viewcvs.cgi/jakarta-tomcat-catalina/webapps/docs/
).  Thanks,

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread Hofmann, Benjamin
I've spent the last couple of days familiarizing myself with the new 5.0.19,
especially the JNDI connection pooling.  I tried, unsuccessfully, to use the
admin console to set up JDNI datasources as well as editing the xml files
directly following the instructions in the documentation.  The only way I
was able to get the connection pooling to work was to manually create a
context in the server.xml and add the resources there.  This worked great.
The documentation for Tomcat 5 looks suspiciously like the Tomcat 4 so I
think it is not updated yet.  

Ben

-Original Message-
From: Daniel Savard [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 08, 2004 9:53 PM
To: Tomcat Users List
Subject: Re: JNDI Datasource Reference in DD Not Necessary?

Doug,

I really hope someone will shed some light on this, because I struggle
to make my JNDI DataSource definition working properly with 5.0.19. And
it seems the Resources still need to be defined in the server.xml even
if the documentation for 5.0.19 is saying you should no longer put your
Context definitions in the server.xml, but rather in the context.xml in
the META-INF directory packaged with your application. It is supposed to
make possible changes in the context without having to restart Tomcat.

But, I was not able to make this working as documented... ;-( Since I am
a newbie, I sticked as much as possible on the instructions. But, it
seems not to work as documented.


Le lun 08/03/2004 à 22:21, Parsons Technical Services a écrit :
> Harry,
> 
> Take a look at this page:
>
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/globalresources.html
> 
> As noted on the page:
> "This is equivalent to the inclusion of the following element in the web
> application deployment descriptor (/WEB-INF/web.xml): "
> 
> The question is: Is the fragment below inside a context for your
application
> or is in the GlobalNamingResources section?
> 
> I just swapped mine to Global and dropped the segment in the web.xml. I
> didn't try it while I had it in the context of the app.
> 
> Doug
> www.parsonstechnical.com
> 
> 
> - Original Message - 
> From: "Harry Mantheakis" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Monday, March 08, 2004 3:37 PM
> Subject: JNDI Datasource Reference in DD Not Necessary?
> 
> 
> > Hello
> >
> > For some time now I have implemented the Tomcat 'JNDI DataSource' How-To
> on
> > connection pooling, and everything has been fine.
> >
> > I define a resource in the context fragment:
> >
> >
> >  >   auth="Container"
> >   type="javax.sql.DataSource"/>
> >
> > 
> > ...
> > 
> >
> >
> > And a resource reference to it in the deployment descriptor:
> >
> >
> > 
> > DB Connection
> > jdbc/postgres
> > javax.sql.DataSource
> > Container
> > 
> >
> >
> > And then do a JNDI lookup at runtime:
> >
> >
> > return ( DataSource )new InitialContext().
> > lookup( "java:comp/env/jdbc/postgres" );
> >
> >
> > Magic.
> >
> > The other day I noticed that the resource reference in my deployment
> > descriptor was actually broken - the name did not match that defined in
> the
> > context - and yet my application was still working - perfectly.
> >
> > When I thought about it, it occurred to me that the resource reference
in
> > the deployment descriptor may not actually be necessary.
> >
> > So I deleted the resource reference from the web.xml file, and
everything
> > still works as expected.
> >
> > Can anyone enlighten me?
> >
> > Many thanks in anticipation.
> >
> > Harry Mantheakis
> > London, UK
> >
> >
> >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
-- 

===
Daniel Savard
Consultation Informatique Daniel Savard

===



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-09 Thread David Smith
I have to say I'm having a large number of issues with JNDI and MySQL

I'm using TC 5 on Fedora Core 1 with the JDBC / MySQL 3.1.1 Alpha
Connector (after I had no luck getting the 3.0.11 Stable connector
working either)

I've been looking at various how-to's and other doco on the whole thing
but don't seem to be getting very far with the whole thing.

I've tried having the connection defined in
$JAKARTA_HOME/conf/server.xml and in
$JAKARTA_HOME/Catalina/localhost/.xml

I have resource-ref defined in the /WEB-INF/web.xml but in
spite of all this I seem to be getting nowhere... (which is a pain) I've
managed to create a straight JDBC connection though so I know that the
DB is accepting connections on the relevant user.

TIA
-- 
Regards
David Smith
---
"A monkey in every office"


signature.asc
Description: This is a digitally signed message part


Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-08 Thread Daniel Savard
Doug,

I really hope someone will shed some light on this, because I struggle
to make my JNDI DataSource definition working properly with 5.0.19. And
it seems the Resources still need to be defined in the server.xml even
if the documentation for 5.0.19 is saying you should no longer put your
Context definitions in the server.xml, but rather in the context.xml in
the META-INF directory packaged with your application. It is supposed to
make possible changes in the context without having to restart Tomcat.

But, I was not able to make this working as documented... ;-( Since I am
a newbie, I sticked as much as possible on the instructions. But, it
seems not to work as documented.


Le lun 08/03/2004 à 22:21, Parsons Technical Services a écrit :
> Harry,
> 
> Take a look at this page:
> http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/globalresources.html
> 
> As noted on the page:
> "This is equivalent to the inclusion of the following element in the web
> application deployment descriptor (/WEB-INF/web.xml): "
> 
> The question is: Is the fragment below inside a context for your application
> or is in the GlobalNamingResources section?
> 
> I just swapped mine to Global and dropped the segment in the web.xml. I
> didn't try it while I had it in the context of the app.
> 
> Doug
> www.parsonstechnical.com
> 
> 
> - Original Message - 
> From: "Harry Mantheakis" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <[EMAIL PROTECTED]>
> Sent: Monday, March 08, 2004 3:37 PM
> Subject: JNDI Datasource Reference in DD Not Necessary?
> 
> 
> > Hello
> >
> > For some time now I have implemented the Tomcat 'JNDI DataSource' How-To
> on
> > connection pooling, and everything has been fine.
> >
> > I define a resource in the context fragment:
> >
> >
> >  >   auth="Container"
> >   type="javax.sql.DataSource"/>
> >
> > 
> > ...
> > 
> >
> >
> > And a resource reference to it in the deployment descriptor:
> >
> >
> > 
> > DB Connection
> > jdbc/postgres
> > javax.sql.DataSource
> > Container
> > 
> >
> >
> > And then do a JNDI lookup at runtime:
> >
> >
> > return ( DataSource )new InitialContext().
> > lookup( "java:comp/env/jdbc/postgres" );
> >
> >
> > Magic.
> >
> > The other day I noticed that the resource reference in my deployment
> > descriptor was actually broken - the name did not match that defined in
> the
> > context - and yet my application was still working - perfectly.
> >
> > When I thought about it, it occurred to me that the resource reference in
> > the deployment descriptor may not actually be necessary.
> >
> > So I deleted the resource reference from the web.xml file, and everything
> > still works as expected.
> >
> > Can anyone enlighten me?
> >
> > Many thanks in anticipation.
> >
> > Harry Mantheakis
> > London, UK
> >
> >
> >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
-- 

===
Daniel Savard
Consultation Informatique Daniel Savard

===



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: JNDI Datasource Reference in DD Not Necessary?

2004-03-08 Thread Parsons Technical Services
Harry,

Take a look at this page:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/globalresources.html

As noted on the page:
"This is equivalent to the inclusion of the following element in the web
application deployment descriptor (/WEB-INF/web.xml): "

The question is: Is the fragment below inside a context for your application
or is in the GlobalNamingResources section?

I just swapped mine to Global and dropped the segment in the web.xml. I
didn't try it while I had it in the context of the app.

Doug
www.parsonstechnical.com


- Original Message - 
From: "Harry Mantheakis" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Monday, March 08, 2004 3:37 PM
Subject: JNDI Datasource Reference in DD Not Necessary?


> Hello
>
> For some time now I have implemented the Tomcat 'JNDI DataSource' How-To
on
> connection pooling, and everything has been fine.
>
> I define a resource in the context fragment:
>
>
>auth="Container"
>   type="javax.sql.DataSource"/>
>
> 
> ...
> 
>
>
> And a resource reference to it in the deployment descriptor:
>
>
> 
> DB Connection
> jdbc/postgres
> javax.sql.DataSource
> Container
> 
>
>
> And then do a JNDI lookup at runtime:
>
>
> return ( DataSource )new InitialContext().
> lookup( "java:comp/env/jdbc/postgres" );
>
>
> Magic.
>
> The other day I noticed that the resource reference in my deployment
> descriptor was actually broken - the name did not match that defined in
the
> context - and yet my application was still working - perfectly.
>
> When I thought about it, it occurred to me that the resource reference in
> the deployment descriptor may not actually be necessary.
>
> So I deleted the resource reference from the web.xml file, and everything
> still works as expected.
>
> Can anyone enlighten me?
>
> Many thanks in anticipation.
>
> Harry Mantheakis
> London, UK
>
>
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]