You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by prt <sh...@pelephone.co.il> on 2007/03/21 22:30:34 UTC

Problem in MySQL JNDI Resource..

Hi to all,

I have in webapps web application name "test1".

In server.xml i define Resource for MySQL db,

<Host name="localhost" appBase="webapps" ...>
<Context path="/test1" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
	removeAbandoned="true" removeAbandonedTimeout="30" 
	maxActive="100" maxIdle="30"  maxWait="10000" 	
	username="user" password="pass" driverClassName="com.mysql.jdbc.Driver"	
	url="jdbc:mysql://localhost/mydb"/>
</Context>
</host>

In test1/WEB-INF/web.xml i define,

<resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/mydb</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
</resource-ref>

I start my Apache tomcat 5 on port 80 and everything work good in
"http://localhost/test1".

Now i want to access test1 from this link "http://localhost/".
So i changed server.xml to,

<Host name="localhost" appBase="webapps" ...>
<Context path="/" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
	removeAbandoned="true" removeAbandonedTimeout="30" 
	maxActive="100" maxIdle="30"  maxWait="10000" 	
	username="user" password="pass" driverClassName="com.mysql.jdbc.Driver"	
	url="jdbc:mysql://localhost/mydb"/>
</Context>
</host>

I can access to "http://localhost/", but the JNDI Resource for MySQL is not
working and i get this error,
"org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver
of class '' for connect URL 'null'"

I try to put the mysql Connector jar in common/lib And server/lib And
shared/lib but still i get the same error.

I was googeling for hourse and found non.

So can any body help me here please ???

Thank you all.
(Sory about my English :) )
-- 
View this message in context: http://www.nabble.com/Problem-in-MySQL-JNDI-Resource..-tf3443968.html#a9603852
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Problem in MySQL JNDI Resource..

Posted by Rashmi Rubdi <ra...@gmail.com>.
The closing host tag's case doesn't match the opening Host tags case, I
don't know if it matters but just wanted to point it out.

It should be
<Host>
</Host>

and not
<Host>
</host>

-Rashmi

On 3/21/07, prt <sh...@pelephone.co.il> wrote:
>
>
> <Host name="localhost" appBase="webapps" ...>
> <Context path="/" debug="0" reloadable="true" crossContext="true">
> <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
>         removeAbandoned="true" removeAbandonedTimeout="30"
>         maxActive="100" maxIdle="30"  maxWait="10000"
>         username="user" password="pass" driverClassName="
> com.mysql.jdbc.Driver"
>         url="jdbc:mysql://localhost/mydb"/>
> </Context>
> </host>
>

RE: Problem in MySQL JNDI Resource..

Posted by prt <sh...@pelephone.co.il>.
Hi and thanks for replay,
The close Host tag is </Host>.

I try to put context.xml in "webapps/test1/META-INF"(removed from server.xml
+ removed the path=""),

<Context debug="0" reloadable="true" crossContext="true">
	<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
                ..........
                .........
                />
</Context>

Now when i try to access via this link "http://localhost" i get 404, is mapp
to "http://localhost/test1".
And when i try to access via this link "http://localhist/test1" I get,
"org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver
of class '' for connect URL 'null'"
 
Siil is not working, I try to add the path attribute and still is not work.
But to access via this slink "http://localhist/test1" is not my problem.
I have to access via this link "http://localhost" and i did it but the
problem now is that my MySQL JNDI Resource is not work ???









Caldarale, Charles R wrote:
> 
>> From: prt [mailto:shaharsa@pelephone.co.il] 
>> Subject: Problem in MySQL JNDI Resource..
>> 
>> <Host name="localhost" appBase="webapps" ...>
>> <Context path="/test1" debug="0" reloadable="true" 
> 
> The <Context> element should not be placed in server.xml, since changing
> it requires restarting Tomcat.  Put it in your webapp's
> META-INF/context.xml file instead, and remove the path attribute.
> 
>> </host>
> 
> I hope the above is really </Host>.
> 
>> I start my Apache tomcat 5 on port 80 and everything work good in
>> "http://localhost/test1".
> 
> Are you using 5.0 or 5.5?  The resource configuration is different for
> each.  Check the Tomcat docs for the appropriate level for details.
> 
>> Now i want to access test1 from this link "http://localhost/".
>> So i changed server.xml to,
>> 
>> <Context path="/" debug="0" reloadable="true" crossContext="true">
> 
> The path attribute should be "", not "/" - but then you shouldn't have
> the <Context> element there anyway.  To make an app the default app, its
> name must be ROOT, and it should be placed in [appBase]/ROOT (or
> [appBase]/ROOT.war).
> 
>> I try to put the mysql Connector jar in common/lib And server/lib And
>> shared/lib but still i get the same error.
> 
> Do not put the same jar in multiple places - that guarantees you will
> have problems.  Your JDBC driver jar of choice normally goes into
> common/lib or WEB-INF/lib only.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-in-MySQL-JNDI-Resource..-tf3443968.html#a9610024
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: Problem in MySQL JNDI Resource..

Posted by prt <sh...@pelephone.co.il>.
Hi and thanks for replay,
The close Host tag is </Host>.

I try to put context.xml in "webapps/test1/META-INF"(removed from server.xml
+ removed the path=""),

<Context debug="0" reloadable="true" crossContext="true">
	<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
                ..........
                .........
                />
</Context>

Now when i try to access via this link "http://localhost" i get 404, is not
mapp to "http://localhost/test1".
And when i try to access via this link "http://localhist/test1" I get,
"org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver
of class '' for connect URL 'null'"
 
Siil is not working, I try to add the path attribute and still is not work.
But to access via this slink "http://localhist/test1" is not my problem.
I have to access via this link "http://localhost" and i did it but the
problem now is that my MySQL JNDI Resource is not work ???









Caldarale, Charles R wrote:
> 
>> From: prt [mailto:shaharsa@pelephone.co.il] 
>> Subject: Problem in MySQL JNDI Resource..
>> 
>> <Host name="localhost" appBase="webapps" ...>
>> <Context path="/test1" debug="0" reloadable="true" 
> 
> The <Context> element should not be placed in server.xml, since changing
> it requires restarting Tomcat.  Put it in your webapp's
> META-INF/context.xml file instead, and remove the path attribute.
> 
>> </host>
> 
> I hope the above is really </Host>.
> 
>> I start my Apache tomcat 5 on port 80 and everything work good in
>> "http://localhost/test1".
> 
> Are you using 5.0 or 5.5?  The resource configuration is different for
> each.  Check the Tomcat docs for the appropriate level for details.
> 
>> Now i want to access test1 from this link "http://localhost/".
>> So i changed server.xml to,
>> 
>> <Context path="/" debug="0" reloadable="true" crossContext="true">
> 
> The path attribute should be "", not "/" - but then you shouldn't have
> the <Context> element there anyway.  To make an app the default app, its
> name must be ROOT, and it should be placed in [appBase]/ROOT (or
> [appBase]/ROOT.war).
> 
>> I try to put the mysql Connector jar in common/lib And server/lib And
>> shared/lib but still i get the same error.
> 
> Do not put the same jar in multiple places - that guarantees you will
> have problems.  Your JDBC driver jar of choice normally goes into
> common/lib or WEB-INF/lib only.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-in-MySQL-JNDI-Resource..-tf3443968.html#a9610024
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


RE: Problem in MySQL JNDI Resource..

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: prt [mailto:shaharsa@pelephone.co.il] 
> Subject: Problem in MySQL JNDI Resource..
> 
> <Host name="localhost" appBase="webapps" ...>
> <Context path="/test1" debug="0" reloadable="true" 

The <Context> element should not be placed in server.xml, since changing
it requires restarting Tomcat.  Put it in your webapp's
META-INF/context.xml file instead, and remove the path attribute.

> </host>

I hope the above is really </Host>.

> I start my Apache tomcat 5 on port 80 and everything work good in
> "http://localhost/test1".

Are you using 5.0 or 5.5?  The resource configuration is different for
each.  Check the Tomcat docs for the appropriate level for details.

> Now i want to access test1 from this link "http://localhost/".
> So i changed server.xml to,
> 
> <Context path="/" debug="0" reloadable="true" crossContext="true">

The path attribute should be "", not "/" - but then you shouldn't have
the <Context> element there anyway.  To make an app the default app, its
name must be ROOT, and it should be placed in [appBase]/ROOT (or
[appBase]/ROOT.war).

> I try to put the mysql Connector jar in common/lib And server/lib And
> shared/lib but still i get the same error.

Do not put the same jar in multiple places - that guarantees you will
have problems.  Your JDBC driver jar of choice normally goes into
common/lib or WEB-INF/lib only.

 - Chuck


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

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


Ok, I solved the problem...

Posted by prt <sh...@pelephone.co.il>.
Hi to all again,
I just changed the path attribute from path="/" to path="" in server.xml and
is work,

<Host name="localhost" appBase="webapps" ...> 
<Context path="" docBase="test1" debug="0" reloadable="true"
crossContext="true"> 
<Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
        removeAbandoned="true" removeAbandonedTimeout="30" 
        maxActive="100" maxIdle="30"  maxWait="10000" 
        username="user" password="pass"
driverClassName="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://localhost/mydb"/> 
</Context> 
</Host> 

Now i can access to "test1" via this link "http://localhost/" and JNDI work.

Thank you all for your help.




prt wrote:
> 
> Hi to all,
> 
> I have in webapps web application name "test1".
> 
> In server.xml i define Resource for MySQL db,
> 
> <Host name="localhost" appBase="webapps" ...>
> <Context path="/test1" docBase="test1" debug="0" reloadable="true"
> crossContext="true">
> <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
> 	removeAbandoned="true" removeAbandonedTimeout="30" 
> 	maxActive="100" maxIdle="30"  maxWait="10000" 	
> 	username="user" password="pass" driverClassName="com.mysql.jdbc.Driver"	
> 	url="jdbc:mysql://localhost/mydb"/>
> </Context>
> </host>
> 
> In test1/WEB-INF/web.xml i define,
> 
> <resource-ref>
>       <description>DB Connection</description>
>       <res-ref-name>jdbc/mydb</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
> </resource-ref>
> 
> I start my Apache tomcat 5 on port 80 and everything work good in
> "http://localhost/test1".
> 
> Now i want to access test1 from this link "http://localhost/".
> So i changed server.xml to,
> 
> <Host name="localhost" appBase="webapps" ...>
> <Context path="/" docBase="test1" debug="0" reloadable="true"
> crossContext="true">
> <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource" 
> 	removeAbandoned="true" removeAbandonedTimeout="30" 
> 	maxActive="100" maxIdle="30"  maxWait="10000" 	
> 	username="user" password="pass" driverClassName="com.mysql.jdbc.Driver"	
> 	url="jdbc:mysql://localhost/mydb"/>
> </Context>
> </host>
> 
> I can access to "http://localhost/", but the JNDI Resource for MySQL is
> not working and i get this error,
> "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver
> of class '' for connect URL 'null'"
> 
> I try to put the mysql Connector jar in common/lib And server/lib And
> shared/lib but still i get the same error.
> 
> I was googeling for hourse and found non.
> 
> So can any body help me here please ???
> 
> Thank you all.
> (Sory about my English :) )
> 

-- 
View this message in context: http://www.nabble.com/Problem-in-MySQL-JNDI-Resource..-tf3443968.html#a9610645
Sent from the Tomcat - User mailing list archive at Nabble.com.


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