You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Aleksanyan <al...@gmail.com> on 2012/02/21 07:10:39 UTC
DB Pool Setup Tomcat 7.0.12 for Derby DB
I have been struggling with a DB Pool setup for DerbyDB 10.8.2.2 on Tomcat
7.0.12 looks like no matter what I do I cannot get things going.
So far I've done the following:
Edit context xml According to JNDI-HOW-TO
-------------------------------------------------------------------------
context.xml
...
<Context>
<Resource name="jdbc/DerbyDB" auth="Container"
type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="15000"
username="sa" password="test"
driverClassName="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/C:\shelf\development\db-derby-10.8.2.2-bin\
bin\TestDB1"/>
<!-- Default set of monitored resources -->
...
-------------------------------------------------------------------------
I also have this in the web.xml (in Eclipse, I'm deploying from eclipse)
-------------------------------------------------------------------------
web.xml
...
<resource-ref>
<description>DerbyDataSource</description>
<res-ref-name>jdbc/DerbyDB</res-ref-name>
<res-type>java.sql.DatSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
-------------------------------------------------------------------------
derbyDB is running and I can connect to it from eclipse db console.
the derby client jar file is in the Tomcat/lib
-------------------------------------------------------------------------
jsp code is the following:
....
<%
Context initContext;
try {
initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource datasource = (DataSource) envContext.lookup("jdbc/DerbyDB");
Connection con = datasource.getConnection();
} catch (NamingException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
%>
...
------------------------------------------------------------
Whenever I try to load the page after I deploy from Eclipse I get the
following
-----------------------------------------------------------------
...
INFO: Server startup in 306 ms
javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.
java:146)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.jsp.SampleForm_jsp._jspService(SampleForm_jsp.java:104)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:4
19)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:304)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:210)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:240)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:164)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:462)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100
)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:118)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:188)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
11Protocol.java:166)
at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:
302)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:11
10)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:6
03)
at java.lang.Thread.run(Thread.java:722)
-----------------------------------------------------------------
Thank you,
David Aleksanyan
RE: DB Pool Setup Tomcat 7.0.12 for Derby DB
Posted by David Aleksanyan <al...@gmail.com>.
Thank you,
I can't believe I missed that one.
There was also another issue related to deployment from Eclipse a
context.xml has to be put into the meta-inf directory (in Eclipse project)
for it to be visible.
After the changes everything is working fine.
David
-----Original Message-----
From: Casper Wandahl Schmidt [mailto:kalle.privat@gmail.com]
Sent: Tuesday, February 21, 2012 3:52 AM
To: users@tomcat.apache.org
Subject: Re: DB Pool Setup Tomcat 7.0.12 for Derby DB
Den 21-02-2012 07:10, David Aleksanyan skrev:
> I have been struggling with a DB Pool setup for DerbyDB 10.8.2.2 on
> Tomcat
> 7.0.12 looks like no matter what I do I cannot get things going.
>
> So far I've done the following:
>
> Edit context xml According to JNDI-HOW-TO
>
> ----------------------------------------------------------------------
> ---
>
> context.xml
> ...
> <Context>
> <Resource name="jdbc/DerbyDB" auth="Container"
> type="javax.sql.DataSource"
> maxActive="100" maxIdle="30" maxWait="15000"
> username="sa" password="test"
> driverClassName="org.apache.derby.jdbc.ClientDriver"
>
> url="jdbc:derby://localhost:1527/C:\shelf\development\db-derby-10.8.2.
> 2-bin\
> bin\TestDB1"/>
> <!-- Default set of monitored resources --> ...
>
> ----------------------------------------------------------------------
> ---
>
>
>
>
> I also have this in the web.xml (in Eclipse, I'm deploying from
> eclipse)
>
>
>
>
>
> ----------------------------------------------------------------------
> ---
>
> web.xml
> ...
> <resource-ref>
> <description>DerbyDataSource</description>
> <res-ref-name>jdbc/DerbyDB</res-ref-name>
> <res-type>java.sql.DatSource</res-type>
I suppose the line above should read java.sql.DataSource (note the extra a
:) )
-Casper
> <res-auth>Container</res-auth>
> </resource-ref>
> ...
>
> ----------------------------------------------------------------------
> ---
>
> derbyDB is running and I can connect to it from eclipse db console.
>
> the derby client jar file is in the Tomcat/lib
>
> ----------------------------------------------------------------------
> ---
>
> jsp code is the following:
> ....
>
> <%
> Context initContext;
> try {
> initContext = new InitialContext();
>
> Context envContext = (Context) initContext.lookup("java:/comp/env");
> DataSource datasource = (DataSource)
> envContext.lookup("jdbc/DerbyDB");
> Connection con = datasource.getConnection(); } catch (NamingException
> e) {
> e.printStackTrace();
> } catch (SQLException e) {
> e.printStackTrace();
> }
> %>
>
> ...
>
> ------------------------------------------------------------
>
>
>
>
>
> Whenever I try to load the page after I deploy from Eclipse I get the
> following
>
>
>
> -----------------------------------------------------------------
>
> ...
>
> INFO: Server startup in 306 ms
> javax.naming.NamingException: Cannot create resource instance
> at
>
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.
> java:146)
> at
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
> at org.apache.jsp.SampleForm_jsp._jspService(SampleForm_jsp.java:104)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.
> java:4
> 19)
> at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appli
> cation
> FilterChain.java:304)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFi
> lterCh
> ain.java:210)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVa
> lve.ja
> va:240)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextVa
> lve.ja
> va:164)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authenticat
> orBase
> .java:462)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.ja
> va:164
> )
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.ja
> va:100
> )
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValv
> e.java
> :118)
> at
>
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proces
> s(Http
> 11Protocol.java:188)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proces
> s(Http
> 11Protocol.java:166)
> at
>
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:
> 302)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.j
> ava:11
> 10)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.
> java:6
> 03)
> at java.lang.Thread.run(Thread.java:722)
>
> -----------------------------------------------------------------
>
>
>
>
>
> Thank you,
>
>
>
> David Aleksanyan
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: DB Pool Setup Tomcat 7.0.12 for Derby DB
Posted by Casper Wandahl Schmidt <ka...@gmail.com>.
Den 21-02-2012 07:10, David Aleksanyan skrev:
> I have been struggling with a DB Pool setup for DerbyDB 10.8.2.2 on Tomcat
> 7.0.12 looks like no matter what I do I cannot get things going.
>
> So far I've done the following:
>
> Edit context xml According to JNDI-HOW-TO
>
> -------------------------------------------------------------------------
>
> context.xml
> ...
> <Context>
> <Resource name="jdbc/DerbyDB" auth="Container"
> type="javax.sql.DataSource"
> maxActive="100" maxIdle="30" maxWait="15000"
> username="sa" password="test"
> driverClassName="org.apache.derby.jdbc.ClientDriver"
>
> url="jdbc:derby://localhost:1527/C:\shelf\development\db-derby-10.8.2.2-bin\
> bin\TestDB1"/>
> <!-- Default set of monitored resources -->
> ...
>
> -------------------------------------------------------------------------
>
>
>
>
> I also have this in the web.xml (in Eclipse, I'm deploying from eclipse)
>
>
>
>
>
> -------------------------------------------------------------------------
>
> web.xml
> ...
> <resource-ref>
> <description>DerbyDataSource</description>
> <res-ref-name>jdbc/DerbyDB</res-ref-name>
> <res-type>java.sql.DatSource</res-type>
I suppose the line above should read java.sql.DataSource (note the extra
a :) )
-Casper
> <res-auth>Container</res-auth>
> </resource-ref>
> ...
>
> -------------------------------------------------------------------------
>
> derbyDB is running and I can connect to it from eclipse db console.
>
> the derby client jar file is in the Tomcat/lib
>
> -------------------------------------------------------------------------
>
> jsp code is the following:
> ....
>
> <%
> Context initContext;
> try {
> initContext = new InitialContext();
>
> Context envContext = (Context) initContext.lookup("java:/comp/env");
> DataSource datasource = (DataSource) envContext.lookup("jdbc/DerbyDB");
> Connection con = datasource.getConnection();
> } catch (NamingException e) {
> e.printStackTrace();
> } catch (SQLException e) {
> e.printStackTrace();
> }
> %>
>
> ...
>
> ------------------------------------------------------------
>
>
>
>
>
> Whenever I try to load the page after I deploy from Eclipse I get the
> following
>
>
>
> -----------------------------------------------------------------
>
> ...
>
> INFO: Server startup in 306 ms
> javax.naming.NamingException: Cannot create resource instance
> at
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.
> java:146)
> at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
> at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
> at org.apache.jsp.SampleForm_jsp._jspService(SampleForm_jsp.java:104)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:4
> 19)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:304)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:210)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:240)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:164)
> at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
> .java:462)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164
> )
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100
> )
> at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :118)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
> 11Protocol.java:188)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
> 11Protocol.java:166)
> at
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:
> 302)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:11
> 10)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:6
> 03)
> at java.lang.Thread.run(Thread.java:722)
>
> -----------------------------------------------------------------
>
>
>
>
>
> Thank you,
>
>
>
> David Aleksanyan
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org