Sv: JNDI DataSource GlobalResources problem

2004-10-26 Thread Roland Carlsson
Hello!

Thanks for your answer. I have no ResourceLink in my configuration. I
understand that I should put it a Context-tag but not where.

How does this affect the configuration I already have done? Is the use of
resource-ref and Resource correct?

Thanks in advance
Roland Carlsson


Den 04-10-26 11.25, skrev Shinobu Kawai [EMAIL PROTECTED]:

 
 Hi Roland,
 
 I'm trying to use the JNDI DataSource to administer my database-connections.
 But it seems like the DataSource doesn't get the properties I set. I get the
 following error:
 
 org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
 class '' for connect URL 'null' (Full stacktrace below)
 
 I have checked that the driver is there and I have re-read the configuration
 and documentation many times now but doesn't find anything wrong. What am I
 missing?
 
  from GlobalNamingResources element in server.xml 
 snip /
 
 - from web-app element in web.xml 
 snip /
 
 -- Full stacktrace of the exception -
 snip /
 
 Have you set the ResourceLink?
 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html
 
 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html
 
 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html#Resource%2
 0Links
 
 Best regards,
 -- Shinobu Kawai
 
 --
 Shinobu Kawai [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]



Sv: JNDI DataSource GlobalResources problem

2004-10-26 Thread Roland Carlsson
Hi Steve! 

X:s and y:s are to hide a few details of our setup, perhaps a little
paranoid :-)

I can connect to the database with user and password at that url.

My driver is in common/lib, I also check the other libs.

Regards
Roland Carlsson


Den 04-10-26 12.27, skrev Steve Kirk [EMAIL PROTECTED]:

 This type of bug crops up a lot on this list.  The best answer seems to be
 to make sure you follow the instructions on this page _exactly_:
 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-how
 to.html
 
 I assume that where you have x/y in your config file this is to hide values
 before posting here rather than your actual config  - worth checking!!
 
 It might help if you post a snippet of your Java source
 
 Can you connect to the database called login on the IP and port in your
 urlvalue tag with the username xxx and password yyy using the mysql
 command line client?  If not, then you probably have a mysql account or
 security issue that's blocking access to the database.  It might be that you
 have only created an account [EMAIL PROTECTED], which will deny access from any
 other IP apart from the 192.168.x.x address of the server.
 
 Where is your driver file?  It should be in the common\lib folder e.g. on my
 machine it is 
 
 C:\jakarta-tomcat-5.0.27\common\lib\mysql-connector-java-3.0.14-production-b
 in.jar
 
 PS even if quotes are allowed in ResourceLinkdescription (which I'm not
 sure about), it's the sort of thing I'd avoid, especially when trying to
 debug a problem like this. It's an extra unknown you'd be better off
 without.
 
 -Original Message-
 From: Roland Carlsson [mailto:[EMAIL PROTECTED]
 Sent: Tuesday 26 October 2004 10:13
 To: TomcatUsers
 Subject: JNDI DataSource GlobalResources problem
 
 
 Hi!
 
 I'm trying to use the JNDI DataSource to administer my
 database-connections.
 But it seems like the DataSource doesn't get the properties I
 set. I get the
 following error:
 
 org.apache.commons.dbcp.SQLNestedException: Cannot create
 JDBC driver of
 class '' for connect URL 'null' (Full stacktrace below)
 
 I have checked that the driver is there and I have re-read
 the configuration
 and documentation many times now but doesn't find anything
 wrong. What am I
 missing?
 
 Thanks in advance
 Roland Carlsson
 
 
  from GlobalNamingResources element in server.xml
 
 
 Resource name=jdbc/loginDB
auth=Container
type=javax.sql.DataSource/
 
   ResourceParams name=login/myDB
 parameter
   namefactory/name
   valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
 /parameter
 
 !-- Maximum number of dB connections in pool. Make sure you
  configure your mysqld max_connections large enough to handle
  all of your db connections. Set to 0 for no limit.
  --
 parameter
   namemaxActive/name
   value100/value
 /parameter
 
 !-- Maximum number of idle dB connections to retain in pool.
  Set to -1 for no limit.  See also the DBCP
 documentation on this
  and the minEvictableIdleTimeMillis configuration parameter.
  --
 parameter
   namemaxIdle/name
   value2/value
 /parameter
 
 !-- Maximum time to wait for a dB connection to become available
  in ms, in this example 10 seconds. An Exception is thrown if
  this timeout is exceeded.  Set to -1 to wait indefinitely.
  --
 parameter
   namemaxWait/name
   value1/value
 /parameter
 
 !-- MySQL dB username and password for dB connections  --
 parameter
  nameusername/name
  valuexxx/value
 /parameter
 parameter
  namepassword/name
  valueyyy/value
 /parameter
 
 !-- Class name for the official MySQL Connector/J driver --
 parameter
namedriverClassName/name
valuecom.mysql.jdbc.Driver/value
 /parameter
 
 !-- The JDBC connection url for connecting to your MySQL dB.
  The autoReconnect=true argument to the url makes
 sure that the
  mm.mysql JDBC Driver will automatically reconnect if mysqld
  closed the connection.  mysqld by default closes idle connections
  after 8 hours.
  --
 parameter
   nameurl/name
   
 valuejdbc:mysql://192.168.x.x:/login?autoReconnect=true/value
 /parameter
   /ResourceParams
 
 
 - from web-app element in web.xml 
 
 
 resource-ref
   descriptionMysql database login/description
   res-ref-namejdbc/loginDB/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
 
 -- Full stacktrace of the exception -
 org.apache.commons.dbcp.SQLNestedException: Cannot create
 JDBC driver of
 class '' for connect URL 'null'
 at 
 org.apache.commons.dbcp.BasicDataSource.createDataSource(Basic
 DataSource.jav
 a:780)
 at 
 

Re: Sv: JNDI DataSource GlobalResources problem

2004-10-26 Thread David Smith
Any place within the Context.../Context tags for your webapp is 
fine.  I don't believe these are validated against a DTD, so order isn't 
an issue.  The rest of your config looks good and should work.  Oh yeah 
-- and name your resources consistently.  If your name attribute in 
Resource is jdbc/loginDb, then it should be the same (case as well as 
spelling) in Resource-Params, ResourceLink, and resource-ref.

--David
Roland Carlsson wrote:
Hello!
Thanks for your answer. I have no ResourceLink in my configuration. I
understand that I should put it a Context-tag but not where.
How does this affect the configuration I already have done? Is the use of
resource-ref and Resource correct?
Thanks in advance
Roland Carlsson
Den 04-10-26 11.25, skrev Shinobu Kawai [EMAIL PROTECTED]:
 

Hi Roland,
   

I'm trying to use the JNDI DataSource to administer my database-connections.
But it seems like the DataSource doesn't get the properties I set. I get the
following error:
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
class '' for connect URL 'null' (Full stacktrace below)
I have checked that the driver is there and I have re-read the configuration
and documentation many times now but doesn't find anything wrong. What am I
missing?
 

 from GlobalNamingResources element in server.xml 
 

snip /
   

- from web-app element in web.xml 
 

snip /
   

-- Full stacktrace of the exception -
 

snip /
Have you set the ResourceLink?
   http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html
   
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html
   
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html#Resource%2
0Links

Best regards,
-- Shinobu Kawai
--
Shinobu Kawai [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]
 

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


Sv: Sv: JNDI DataSource GlobalResources problem

2004-10-26 Thread Roland Carlsson
Hi!

It took a while before i found a way to put the ResourceLink in a context
where I felt it would be appropiate (using autoinstall so i don't have them
in my conf-files). In server.xml I created a default-context and viola! It
worked! :-)

Thanks for your help!

Regards
Roland


Den 04-10-26 13.39, skrev David Smith [EMAIL PROTECTED]:

 Any place within the Context.../Context tags for your webapp is
 fine.  I don't believe these are validated against a DTD, so order isn't
 an issue.  The rest of your config looks good and should work.  Oh yeah
 -- and name your resources consistently.  If your name attribute in
 Resource is jdbc/loginDb, then it should be the same (case as well as
 spelling) in Resource-Params, ResourceLink, and resource-ref.
 
 --David
 
 Roland Carlsson wrote:
 
 Hello!
 
 Thanks for your answer. I have no ResourceLink in my configuration. I
 understand that I should put it a Context-tag but not where.
 
 How does this affect the configuration I already have done? Is the use of
 resource-ref and Resource correct?
 
 Thanks in advance
 Roland Carlsson
 
 
 Den 04-10-26 11.25, skrev Shinobu Kawai [EMAIL PROTECTED]:
 
  
 
 Hi Roland,
 

 
 I'm trying to use the JNDI DataSource to administer my
 database-connections.
 But it seems like the DataSource doesn't get the properties I set. I get
 the
 following error:
 
 org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
 class '' for connect URL 'null' (Full stacktrace below)
 
 I have checked that the driver is there and I have re-read the
 configuration
 and documentation many times now but doesn't find anything wrong. What am I
 missing?
  
 
  from GlobalNamingResources element in server.xml 
  
 
 snip /
 

 
 - from web-app element in web.xml 
  
 
 snip /
 

 
 -- Full stacktrace of the exception -
  
 
 snip /
 
 Have you set the ResourceLink?
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html

 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/globalresources.html

 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html#Resource
 %2
 0Links
 
 Best regards,
 -- Shinobu Kawai
 
 --
 Shinobu Kawai [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]
 
  
 
 
 -
 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: Sv: JNDI DataSource GlobalResources problem

2004-10-26 Thread Shapira, Yoav

Hi,

In server.xml I created a default-context and viola! It
worked! :-)

Ahh, I'd stay on tiptoes if I were you.  DefaultContext has a couple of
subtle bugs that affect a small subset of applications which rely on
binding order.

It's worth your time to dump DefaultContext and declare the resources in
your actual Context, with a ResourceLink if you're using
GlobalNamingResources as others have pointed out.  Either of those
options is superior to DefaultContext (which by the way is more or less
gone in Tomcat 5.5).

Yoav



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]



Sv: JNDI DataSource GlobalResources problem

2004-10-26 Thread Roland Carlsson
Thank you very much for your help. I appreciate it very much.

I feel that the GlobalNamingResources is the place to put my
DataSource-definition since there I can do it one time for all web-apps that
are going to come and go. If there are any change is our databases it is one
place to change. Thats why I ran for that alternative.

I'm looking forward to see the new documentation about DBCP in Tomcat.

Regards
Roland Carlsson


Den 04-10-26 14.58, skrev Steve Kirk [EMAIL PROTECTED]:

 
 This question illustrates (IMHO) probably the biggest issue of confusion
 with regard to DBCP - that is, there are several XML elements that you can
 potentially use, and several places that you can potentially put them.
 Specifically, the Resource, ResourceParams and ResourceLink elements
 can go in server.xml or your webapp's context config file, and
 resource-ref can go in your web.xml file.  Most people that have DBCP
 problems seem to have trouble working out elements to use, and where to put
 them.  A quick search on the web shows that this issue is widely
 misunderstood, and there is lots of misinformation out there.
 
 There are actually several possibilities that work.  I have not chosen the
 same possibility as you Roland, but hope I can help.  The how-to pages
 linked earlier by Shinobu and me are also good points of reference, and if
 you follow them _exactly_ it will work.  I belive that the simplest and
 clearest page to follow is this one:
 http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html -
 I think the JDBC page contains at least one slightly misleading instruction.
 
 To answer your question, yes you have used resource-ref correctly and your
 Resource and ResourceParams elements seem OK.
 
 However, note that you have not followed the recommended approach in the
 how-to docs ;) because your Resource and ResourceParams are under
 GlobalNamingResources rather than your webapp's Context tag.  However
 that does not make it completely wrong.  Because they are under
 GlobalNamingResources at the moment, they are not visible to your webapp.
 To fix this, either they need to be moved under Context as recommended in
 the how-to, or you need to add a ResourceLink under your webapp's
 Context that refers to them.
 
 The Context that I am referring to should be either under Host in
 server.xml as described in the how-to docs, or in your webapp's context
 config file (see my example below).
 
 Strictly speaking, according to the JNDI how-to docs, I think your
 Resource tag is not needed because you have a resource-ref, which is
 equivalent, and you do not need both.  Having said that, I have tried it
 both with and without the Resource tag, and both approaches work as long
 as resource-ref is in web.xml.
 
 For what it's worth, (but not wanting to confuse you!) below is the approach
 that I have working.  I'm including this to illustrate that there is more
 than one way to configure DBCP.  Note that this is a different approach to
 yours, and also different to that described in the how-to docs on the TC
 site.  I took this approach via trial and error because I did not find the
 how-to docs until after I'd got pooling working.
 
 1. I have a resource-ref like yours in my
 CATALINA_HOME\webapps\webapp\WEB-INF\web.xml
 
 2. I created a context config file at
 CATALINA_HOME\conf\Catalina\localhost\mywebapp.xml, where mywebapp is the
 name of the webapp, which contains just my webapp's  Context element,
 which in turn contains Resource and ResourceParams very similar to
 yours.  That this Context tag is more usually included in server.xml,
 under the default localhost Host tag.  (By default your server.xml will
 not include a Context tag for your webapp, you have to add it inside the
 Context element for your webapp, or inside a DefaultContext element for the
 surrounding Host or Engine element, as described in the JNDI how-to
 page. The entire contents of my context config file are below:
 
 ?xml version='1.0' encoding='utf-8'?
 Context docBase=C:\jakarta-tomcat-5.0.27\webapps\mywebapp
 path=/mywebapp reloadable=true
 ResourceParams name=jdbc/mywebapp
 parameter
 namefactory/name
 
 valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
 /parameter
 ... more parameters like yours ...
 /ResourceParams
 /Context
 
 3. I have no ResourceLink anywhere - I don't need it because I have not
 used GlobalNamingResources
 
 I know that this is a long-winded reply, but this is a tricky area and easy
 to get confused.  I've also been meaning to post this to the list for a few
 months, having spent days learning it.  Hope this helps you and others :)
 
 -Original Message-
 From: Roland Carlsson [mailto:[EMAIL PROTECTED]
 Sent: Tuesday 26 October 2004 12:09
 To: TomcatUsers
 Subject: Sv: JNDI DataSource GlobalResources problem
 
 
 Hello!
 
 Thanks for your answer. I have no ResourceLink in my configuration. I
 understand that I should put it a Context-tag but not where.
 
 How does this affect