• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat 5.0.27 Connection Pooling

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

I started using tomcat recently and started with version 6 and able develop application . But when I try to deploy it on godaddy shared linux hosting environment ,it has version 5.0.27. Moreover we don't have permission to change server.xml file to implement connection pooling . Could some body please help me in creating connection pooling for MYSQL server on tomcat server 5.0.27 where we don't have access to modify server.xml file( Not sure we can create context.xml on tomcat version 5.0.27 , even we have I think I can not even use context.html on godaddy shared linux hosting environment)

Thanks a lot for your help
Kiran
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would check with GoDaddy about recommended approach. Please check Apache Tomcat Configuration Reference http://tomcat.apache.org/tomcat-5.5-doc/config/context.html about where could you define Context elements

For Tomcat 5, unlike Tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes modifying the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.

Context elements may be explicitly defined: ...

 
Kiran Kumar Vasireddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response . Unfortunately Godaddy is not talking about the connection pooling and they are blindly connecting to the database directly
Please check the their example http://help.godaddy.com/article/3351
I called them several times and but no use.



Regards
Kiran
 
Misha Ver
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this case check the URL that I posted above
 
Kiran Kumar Vasireddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once again thanks for your response . I used context.xml in version 6 and it worked great , But it is not working for version 5.0 . I think it works only from version 5.5 .Correct me If I am wrong . Moreover in version 6 if I create context.xml file it gets copied automatically to <tomcat home>\conf\Catalina\localhost directory , this is not happening in version 5.0 .

Again godaddy environment context.xml file will not be copied to <tomcat home>\conf\Catalina\localhost even if 5.0 supports because of security reasons.

Regards
Kiran
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kiran Kumar Vasireddy wrote:Once again thanks for your response . I used context.xml in version 6 and it worked great , But it is not working for version 5.0 . I think it works only from version 5.5 .Correct me If I am wrong .
Regards
Kiran



You're wrong. The context xml file has been the recommended thing to use (instead of mods to server.xml) since Tomcat 4. I've been using it for years.

Unless someone has done some really bizarre stuff, the same context.xml should work for both Tomcat5 and Tomcat6, and I'm not sure about anything copying it to conf/Catalina/localhost. But then, when I deploy, I normally copy it there myself.

You can also construct a file whose actual name is context.xml and place it in your WAR (check the docs, but I think it goes the the WAR's /META-INF directory). Unless overridden, that context.xml will be used when the app is deployed and you can also define the database connection pool in that file just as in any other context xml file.

Since the conf/Catalina/localhost is a directory that can contain multiple contexts, obviously only one of them could actually be give a name of "context.xml", but in practice, Tomcat just scans for all ".xml" files in that directory and deploys all of them and doesn't care what their actual names are. Perversely, it will also erase files in certain cases when a deployment fails.

In Tomcat4 and (I think) Tomcat5, the context.xml file could also be written to the webapps folder. A problem with that, however, is that if a WAR file and a context file were both copied to that folder, the folder was scanned in alphabetical order, so the war file was seen and processed before (and in place of) the context XML file.

Finally, when doing major redeployments, it's wise to remove all lint. Delete all war files, context files, and exploded war directories related to the app being redeployed from the webapps directory. Especially the exploded WARs, since they'll override unexploded WAR files, even if they're older. Also delete the appropriate directory subtree from the work/Catalina/localhost directory. It's not a bad idea to just delete everything from under the temp directory.
 
Kiran Kumar Vasireddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim for your time and for the detailed explanation
I am clear now about context.xml file and trying to use it for the application deployed under root.
I copied context.xml file under ROOT\META-INF and trying to access the application and got the following error

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

I copied the required Driver Jar in all the places ( all the lib folders to make sure for testing) . Could you please let me know what went wrong?

Regards
Kiran

Contents of context.xml file

<Context path="/ROOT" docBase="ROOT" debug="1" reloadable="true">
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/TestDB">
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/test</value>
</parameter>
</ResourceParams>
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That one always annoys me. I think it means you need to copy a mysql driver jar into your Tomcat lib directory. In Tomcat 5, I think it's the shared/lib directory.

Why the classname shows as '' I've never figured out.
 
Kiran Kumar Vasireddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I copied the required Jar in all the LIB folders but still gave the same error . But at last by setting the context path to "" it worked. I mean the first line I changed to

<Context path=""

But this worked only for me when I copied manually context.xml file under conf\Catalina\localhost directory . I am going to create a war file and try to deploy and see what happens .

But again godaddy environment settings are different , not sure what what context I have to give and document root I have to give.

Regards
Kiran
 
Kiran Kumar Vasireddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am able to deploy with war file in my local environment .
But again on Godaddy environment I am getting the same error.
I am going crazy for last 15 days , but not found a solution . I called godaddy people , but no perfect answer .

I am able to connect to database directly through my JSP or servlet and able to get the result on Godaddy hosting environment. I mean if I hard code the database connection string,userid and password . But if I use context.xml I am getting null pointer exception on the screen . As per the tomcat configuration install doc if you copy context.xml under META-INF/context.xml It will be picked by tomcat and writes it under conf\Catalina\localhost directory with your jar file name . In shared environment I am not getting a away to check this ..

Is there any way to check the file copied properly or not to conf\Catalina\localhost directory?
Or if it doesn't there any other way to implement connection pooling in Godaddy environment?
and surprisingly the logs what they are asking me to check are under stats directory with error_logs directory . But that doesn't contain much information.Are there any other error logs I can check?

Regards
Kiran
 
I knew that guy would be trouble! Thanks tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic