File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat Connection Pool Configuration Problem (Cannot Establish the Connection) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Connection Pool Configuration Problem (Cannot Establish the Connection)" Watch "Tomcat Connection Pool Configuration Problem (Cannot Establish the Connection)" New topic
Author

Tomcat Connection Pool Configuration Problem (Cannot Establish the Connection)

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Sorry about my previous posting. Now, I have got better trace of my JDBC connection problem.

I am using the Tomcat 5.0.27, j2sdk1.4.2, Oracle 10i, Windows XP.

The error message is:

root cause

org.dhsinfo.content.exceptions.PageDAOSysException: SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
org.dhsinfo.content.dao.OraclePageDAO.findPages(OraclePageDAO.java:51)
org.dhsinfo.content.PageService.getPages(PageService.java:18)
org.dhsinfo.content.SelectPage.execute(SelectPage.java:29)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

When I configured the Tomcat 5.0.27, I did put the driver and URL in the C:\jakarta-tomcat-5.0.27\conf\server.xml file (The location is below the <Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="localhost_log." suffix=".txt" timestamp="true"/> and before the closing </Host> tag). Please help me to see the problem:
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

for container-managed resources, you need the driver files in common/lib. Is that where they are ?
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Relate link

http://www.coderanch.com/t/84137/Tomcat/Tomcat-Works-connection-pooling-tomcat


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Mike Curwen:
for container-managed resources, you need the driver files in common/lib. Is that where they are ?


JiaPei Jen,
I agree with Mike Curwen... You might forget to put classes12.zip or related driver files into the common/lib of Tomcat... Could you check that again?

Hope it helps...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
See the other posting of mine regarding the steps that I have taken to configure the Tomcat connection pool. I followed the JDBC datasource how-to.

I think that we may need an expert to look into the problem.

A couple of more people reported exactly the same difficulty with the Tomcat 5.0.27 at the http://java.sun.com --> forums --> JDBC.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

JiaPei,

When you say "we may need an expert", it kinda implies that the helpers so far have been less than that. Let's not invoke the experts just yet. There are plenty of things us ordinary folks can still help you with.

Your problem does not require 'expert' help. It is a common problem. Just because lots of people have the same problem, doesn't mean there's anything wrong with Tomcat. It simply means that this particular aspect of configuring Tomcat gives people trouble.

I can't help but fail to notice that you also haven't clearly responded to my question on this forum, and to another person's question on tomcat-user. Do you have the driver in common/lib and is it's extension .jar ?

Don't *just* tell us you've followed the DataSource How-To. Confirm for us that this *very common cause of your problem* is in fact, not the cause of your problem.

Also, where is the code that accesses the DataSource ? Your classes in the stacktrace
org.dhsinfo.content.dao.OraclePageDAO.findPages(OraclePageDAO.java:51)
org.dhsinfo.content.PageService.getPages(PageService.java:18)
org.dhsinfo.content.SelectPage.execute(SelectPage.java:29)

Where is the jar file containing those?
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
Thank Mike for being willing to help. I think it is just I have not had anybody to really take a look at the problem for about a week. And I posted my configuration again and again.

The steps that I have taken for configuring the Tomcat 5.0.27 is shown below:

Tomcat 5.0.27, j2sdk1.4.2, Oracle 9i, and Windows XP

Step 1.

Jakarta-Commons componenets:

Jakarta-Commons DBCP 1.2.1
Jakarta-Commons Collections 2.1.1
Jakarta-Commons Pool 1.2

These jar files are installed in the $CATALINA_HOME/common/lib.

Step 2.
download classes12.zip rename it to classes12.jar and place it in
$CATALINA_HOME\common\lib

Step 3. C:\jakarta-tomcat-5.0.27\conf\server.xml configuration
Note: I added the following code in the <Host> element just before the closing </Host> tag.

Step 4. web.xml Configuration (the one in MyApp/WEB-INF directory)

add these lines after the <taglib> element



First: I have the read and execute permission to the classes12.jar file. I right clicked on the classes12.jar --> properties --> under the Security
tab, I see the permission for both users and my name specifically for accessing this file.

Second: I have tried (downloaded from the Oracle website today) the classes12.zip (renamed it to classes12.jar) that is compatible with the Oracle 9i 9.2.0.5, which is the database I am connecting to. I have also tried the ojdbc14.jar, which is compatible with JDK 1.4 and the Oracle 9i 9.2.0.5. I still get the same error message: Cannot create JDBC driver of
class '' for connect URL 'null'

Third: I used to have a DBConnection.java to get a Connection object from the connection pool (it has been working well with the Tomct 4.1.18 and MySQL). Because this conn = 'null' problem occurred with the Oracle connection, I followed the advice of another person and changed the code in the DBConnection.java to get a better trace of the error message. I am
posting my code (looking up and getting the datasource) below. The code compiled OKay.

Fourth: There is another exception in the Tomcat logs:
'java.sql.SQLException: open: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver'

This is a rather weird message. I am not using the MySQL driver. Why the Tomcat is looking for the MySQL driver? Maybe it is where my problem stems from? Maybe I have very bad eyes. I do not see that my configuration asks for the MySQL driver.

DBConnection.java code:

OraclePageDAO.java code:


PageService.java code:

SelectPage.java code:


Tomcat Logs file:

2004-09-14 16:27:33 StandardContext[/balancer]org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
2004-09-14 16:27:35 StandardContext[/artimus_1_0_b4]action: Loading application resources from resource resources.application
2004-09-14 16:27:35 StandardContext[/artimus_1_0_b4]action: Initializing configuration from resource path /WEB-INF/struts-config.xml
2004-09-14 16:27:36 StandardContext[/artimus_1_0_b4]action: Initializing application data source org.apache.struts.action.DATA_SOURCE
2004-09-14 16:27:36 StandardContext[/artimus_1_0_b4]action: Exception initializing application data source org.apache.struts.action.DATA_SOURCE
java.sql.SQLException: open: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at org.apache.struts.util.GenericDataSource.open(GenericDataSource.java:662)
at org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.java:1078)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at org.apache.struts.tiles.ActionComponentServlet.init(ActionComponentServlet.java:52)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:617)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

2004-09-14 16:27:36 StandardContext[/artimus_1_0_b4]Servlet /artimus_1_0_b4 threw load() exception
javax.servlet.ServletException: Exception initializing application data source org.apache.struts.action.DATA_SOURCE
at org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.java:1081)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at org.apache.struts.tiles.ActionComponentServlet.init(ActionComponentServlet.java:52)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:617)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
----- Root Cause -----
java.sql.SQLException: open: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
at org.apache.struts.util.GenericDataSource.open(GenericDataSource.java:662)
at org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.java:1078)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at org.apache.struts.tiles.ActionComponentServlet.init(ActionComponentServlet.java:52)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1029)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:862)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4013)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4357)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:277)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:617)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:431)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:349)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:480)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2313)
at org.apache.catalina.startup.Catalina.start(Catalina.java:556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:284)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)

2004-09-14 16:27:36 StandardContext[/artimus_1_0_b4]validator: Loading validation file from '/WEB-INF/validation.xml'
2004-09-14 16:27:37 StandardContext[/logon]action: Loading application resources from resource resources.application
2004-09-14 16:27:37 StandardContext[/logon]action: Initializing configuration from resource path /WEB-INF/struts-config.xml
2004-09-14 16:27:37 StandardContext[/logon]action: Process servletName=action, urlPattern=*.do
2004-09-14 16:27:37 StandardContext[/logon]action: Mapping for servlet 'action' = '*.do'
2004-09-14 16:27:39 StandardContext[/jsp-examples]ContextListener: contextInitialized()
2004-09-14 16:27:39 StandardContext[/jsp-examples]SessionListener: contextInitialized()
2004-09-14 16:27:40 StandardContext[/servlets-examples]ContextListener: contextInitialized()
2004-09-14 16:27:40 StandardContext[/servlets-examples]SessionListener: contextInitialized()
2004-09-14 16:27:58 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
org.dhsinfo.content.exceptions.PageDAOSysException: SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.dhsinfo.content.dao.OraclePageDAO.findPages(OraclePageDAO.java:51)
at org.dhsinfo.content.PageService.getPages(PageService.java:18)
at org.dhsinfo.content.SelectPage.execute(SelectPage.java:29)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

2004-09-14 17:02:59 StandardContext[/jsp-examples]SessionListener: contextDestroyed()
2004-09-14 17:02:59 StandardContext[/jsp-examples]ContextListener: contextDestroyed()
2004-09-14 17:03:00 StandardContext[/servlets-examples]SessionListener: contextDestroyed()
2004-09-14 17:03:00 StandardContext[/servlets-examples]ContextListener: contextDestroyed()
2004-09-14 17:03:00 StandardContext[/logon]action: Finalizing this controller servlet
2004-09-14 17:03:01 StandardContext[/artimus_1_0_b4]validator: Destroying ValidatorServlet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat Connection Pool Configuration Problem (Cannot Establish the Connection)
 
Similar Threads
Configuring a MySQL DataSource in Tomcat5
DBCP Null pointer exception
Cannot create JDBC driver of class '' for connect URL 'null'
Is this true: JNDI equals Connection Pooling
Have Been Struggling for More Than a Week. Tomcat Connection Pool Configuration Prob