You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by Brian Levine <le...@hotmail.com> on 2009/10/16 02:50:59 UTC

DB connection pooling


I'm trying to setup DB Connection pooling with roller, but I'm having trouble.

I'm using tomcat 5.5 and mysql 5.x.

I've placed a context.xml file in the META_INF directory that looks like this:

<Context debug="0">

  <Resource name="jdbc/rollerdb" auth="Container" type="javax.sql.DataSource"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/rollerblog?autoReconnect=true"
    username="blevine"
    password=xxxxxx
    maxActive="20" maxIdle="3" removeAbandoned="true" maxWait="3000" />

  <Resource name="mail/Session" auth="Container" type="javax.mail.Session"
     mail.smtp.host="smtp-server.example.com" />

</Context>

And then created the WAR and deployed it.

When I load up roller in my browser (firefox) I get this error:

A database error occurred, probably because your database connection
is misconfigured. You will have to fix this problem and then restart or
redeploy Roller before you can proceed. Here's what happened when
Roller tried to establish a connection:

SUCCESS: Got parameters. Using configuration type JNDI_NAME-- Using JNDI datasource name: java:comp/env/jdbc/rollerdbSUCCESS: located JNDI DataSource [java:comp/env/jdbc/rollerdb]ERROR: unable to obtain database connection. Likely problem: bad connection parameters or database unavailable.
 [org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
	at org.apache.roller.weblogger.business.DatabaseProvider.getConnection(DatabaseProvider.java:179)
	at org.apache.roller.weblogger.business.DatabaseProvider.<init>(DatabaseProvider.java:141)
	at org.apache.roller.weblogger.business.startup.WebloggerStartup.prepare(WebloggerStartup.java:171)
	at org.apache.roller.weblogger.ui.core.RollerContext.contextInitialized(RollerContext.java:138)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
	at org.apache.catalina.core.StandardService.start(StandardService.java:448)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
	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:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
	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:597)
	at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
Caused by: java.lang.NullPointerException
	at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
	at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
	at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
	at java.sql.DriverManager.getDriver(DriverManager.java:253)
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
	... 33 more]
I removed the "docBase" and "path" attributes from the "Context" element because I saw something in the tomcat docs that says leaving those in will mess up the deployment.  I tried it with those in and got the same errors.

I copied over the url, username, password, and driverClassName from roller-custom.properties so I'm pretty sure those were right.

Anyone have any suggestions?

Thanks!
/Brian

 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/

RE: DB connection pooling

Posted by Brian Levine <le...@hotmail.com>.

It worked!  Thanks so much for your help!
/Brian

> Date: Thu, 15 Oct 2009 19:14:14 -0700
> Subject: Re: DB connection pooling
> From: hassan.schroeder@gmail.com
> To: user@roller.apache.org
> 
> On Thu, Oct 15, 2009 at 6:59 PM, Brian Levine <le...@hotmail.com> wrote:
> 
> > I just checked and the driver is only in common/lib
> 
> Good.
> 
> > I also checked to see if the context.xml file was being picked up, but I don't see it anywhere.  It's getting moved out of META_INF and from what I understand it gets renamed to "war's name.xml".  I checked that file, but my stuff isn't in there.
> 
> I'd suggest you stop Tomcat, remove the (old) copied version at e.g.
>   $CATALINA_HOME/conf/Catalina/localhost/wars_name.xml
> and restart Tomcat.
> 
> This sounds like a Tomcat config rather than Roller issue, so if the
> above doesn't fix it, let me know off-list, or post your issue to the
> users@tomcat.apache.org list.
> 
> H*
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> twitter: @hassan
 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/

Re: DB connection pooling

Posted by Hassan Schroeder <ha...@gmail.com>.
On Thu, Oct 15, 2009 at 6:59 PM, Brian Levine <le...@hotmail.com> wrote:

> I just checked and the driver is only in common/lib

Good.

> I also checked to see if the context.xml file was being picked up, but I don't see it anywhere.  It's getting moved out of META_INF and from what I understand it gets renamed to "war's name.xml".  I checked that file, but my stuff isn't in there.

I'd suggest you stop Tomcat, remove the (old) copied version at e.g.
  $CATALINA_HOME/conf/Catalina/localhost/wars_name.xml
and restart Tomcat.

This sounds like a Tomcat config rather than Roller issue, so if the
above doesn't fix it, let me know off-list, or post your issue to the
users@tomcat.apache.org list.

H*
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

RE: DB connection pooling

Posted by Brian Levine <le...@hotmail.com>.


Thanks for the quick reply!

I just checked and the driver is only in common/lib

I also checked to see if the context.xml file was being picked up, but I don't see it anywhere.  It's getting moved out of META_INF and from what I understand it gets renamed to "war's name.xml".  I checked that file, but my stuff isn't in there.

I then grep'd the entire tomcat directory for values I put in context.xml, but didn't find them.  Am I missing something?

> Date: Thu, 15 Oct 2009 18:08:43 -0700
> Subject: Re: DB connection pooling
> From: hassan.schroeder@gmail.com
> To: user@roller.apache.org
> 
> On Thu, Oct 15, 2009 at 5:50 PM, Brian Levine <le...@hotmail.com> wrote:
> 
> > I'm using tomcat 5.5 and mysql 5.x.
> 
> >  [org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
> 
> MySQL driver jar file should be in $CATALINA_HOME/common/lib
> and ONLY there, not in your webapp's lib directory -- confirmed?
> 
> > I removed the "docBase" and "path" attributes from the "Context" element because I saw something in the tomcat docs that says leaving those in will mess up the deployment.
> 
> No, they're just ignored if they're in a META-INF/context.xml file. But
> good to get them out of there. :-)
> 
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> twitter: @hassan
 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/

Re: DB connection pooling

Posted by Hassan Schroeder <ha...@gmail.com>.
On Thu, Oct 15, 2009 at 5:50 PM, Brian Levine <le...@hotmail.com> wrote:

> I'm using tomcat 5.5 and mysql 5.x.

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

MySQL driver jar file should be in $CATALINA_HOME/common/lib
and ONLY there, not in your webapp's lib directory -- confirmed?

> I removed the "docBase" and "path" attributes from the "Context" element because I saw something in the tomcat docs that says leaving those in will mess up the deployment.

No, they're just ignored if they're in a META-INF/context.xml file. But
good to get them out of there. :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan