wood burning stoves 2.0*
The moose likes Tomcat and the fly likes DBCP Null pointer exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "DBCP Null pointer exception" Watch "DBCP Null pointer exception" New topic
Author

DBCP Null pointer exception

Rajnikant Prabhu
Greenhorn

Joined: Mar 11, 2004
Posts: 3
I am trying to use dbcp of tomcat 5.0.19 My database is sybase
I followed the example of Mysql when i try to load the test.jsp specified in example i get following error

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '
' for connect URL 'null', cause:
java.lang.NullPointerException
at com.sybase.jdbc2.jdbc.SybDriver.acceptsURL(SybDriver.java:201)
at java.sql.DriverManager.getDriver(DriverManager.java:232)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:743)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:518)
at foo.DBTest.init(DBTest.java:23)
at org.apache.jsp.foo_jsp._jspService(foo_jsp.java:51)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:311)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
01)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:509)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:688)
at java.lang.Thread.run(Thread.java:534)

My server.xml is
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>

</GlobalNamingResources>
<Service name="Catalina">
<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="80" redirectPort="8443">
</Connector>
<Connector acceptCount="100" disableUploadTimeout="true" enableLookups="true" keystoreFile="C:\jakarta-tomcat-5.0.19\jakarta-tomcat-5.0.19\.keystore" keystorePass="changeit" maxProcessors="75" port="8443" scheme="https" secure="true" sslProtocol="TLS">
<Factory className="org.apache.coyote.tomcat5.CoyoteServerSocketFactory" keystoreFile="C:\jakarta-tomcat-5.0.19\jakarta-tomcat-5.0.19\.keystore"/>
</Connector>
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>

<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.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>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</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>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name>username</name>
<value>aa</value>
</parameter>
<parameter>
<name>password</name>
<value>aa</value>
</parameter>
<!-- Class name for mm.mysql JDBC driver -->
<parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</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>
<name>url</name>
<value>jdbc:sybase:Tds://localhost:5000/javatest</value>
</parameter>
</ResourceParams>
</Context>
</Host>
<Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
<Realm className="org.apache.catalina.realm.JDBCRealm" connectionName="aa" connectionPassword="aa" connectionURL="jdbc:sybase:Tds:localhost:5000" debug="99" driverName="com.sybase.jdbc2.jdbc.SybDriver" roleNameCol="RoleName" userCredCol="Password" userNameCol="UserName" userRoleTable="user_roles" userTable="users"/>
</Engine>
</Service>
</Server>

My web.xml for DBTest is
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>

My jar files in coomon directory are
03/02/2004 11:14 AM <DIR> ..
02/14/2004 11:21 AM 952,104 ant.jar
02/14/2004 11:21 AM 165,119 commons-collections.jar
02/14/2004 11:21 AM 100,776 commons-dbcp-1.1.jar
02/14/2004 11:21 AM 112,341 commons-el.jar
02/14/2004 11:21 AM 39,523 commons-pool-1.1.jar
02/14/2004 11:21 AM 344,741 jasper-compiler.jar
02/14/2004 11:21 AM 106,156 jasper-runtime.jar
02/14/2004 11:21 AM 365,858 jmx.jar
02/14/2004 11:21 AM 48,725 jsp-api.jar
02/14/2004 11:21 AM 28,032 naming-common.jar
02/14/2004 11:21 AM 14,862 naming-factory.jar
02/14/2004 11:21 AM 2,068 naming-java.jar
02/14/2004 11:21 AM 42,346 naming-resources.jar
02/14/2004 11:21 AM 91,627 servlet-api.jar
08/28/2002 08:41 AM 910,038 jconn2.jar
08/28/2002 08:42 AM 148,870 jTDS2.jar
Please help me
Rajnikant Prabhu
Greenhorn

Joined: Mar 11, 2004
Posts: 3
Problem solved hadnt put jconn2.jar in \DBTest\Web-inf\lib.
Sorry to bother you guys
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DBCP Null pointer exception
 
Similar Threads
Problem wid javamail.address.map
using flush in custom tags
Problem in connecting Oracle thru Java
A following eror occured while running an application in Tomcat
Exception thrown while working with Struts 1.3.8