tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis" <tra...@travislabs.com>
Subject RE: DB connection error -Tomcat 6 config
Date Sat, 20 Mar 2010 14:36:41 GMT
I can't remember the errors, but I had a hard time trying to setup Oracle on
Tomcat 6. My config looks something like this.  The URL is basically the TNS
Names entry with the whitespace removed.  The nice this is that its RAC
aware, and handles failing over to other nodes in the RAC nicely.  


<Resource name="jdbc/atl_cluster" auth="Container"
	type="oracle.jdbc.pool.OracleDataSource"
	driverClassName="oracle.jdbc.OracleDriver"
	factory="oracle.jdbc.pool.OracleDataSourceFactory"
	
url="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1)(PORT
=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=node2)(PORT=1521))(ADDRESS=(PROTOCOL=TCP
)(HOST=node3)(PORT=1521))(LOAD_BALANCE=no)(FAILOVER=yes)(CONNECT_DATA=(SERVE
R=DEDICATED)(SERVICE_NAME=ATLCLUSTER.WORLD)))"
	user="userName"
	password="password"
	maxActive="20"
	maxIdle="10"
	maxWait="500"
	removeAbandoned="true"
	removeAbandonedTimeout="60"
	logAbandoned="true"/>




-Travis



-----Original Message-----
From: Propes, Barry L [mailto:barry.l.propes@citi.com] 
Sent: Tuesday, March 16, 2010 7:07 PM
To: 'Tomcat Users List'
Subject: RE: DB connection error -Tomcat 6 config

And I should have added the proper path(s) was/were

 /webapps/chngctrl/META-INF/context.xml
And /webapps/chngctrl/WEB-INF/web.xml


Regards,

Barry

-----Original Message-----
From: Propes, Barry L [GCG-NAOT] 
Sent: Tuesday, March 16, 2010 6:04 PM
To: 'Tomcat Users List'
Subject: RE: DB connection error -Tomcat 6 config

Well, I'm at a loss.

After even downloading 6.0.24 with the Windows Installer service and
cleaning up the context.xml and web.xml files in the respective places:
/webapps/META-INF/context.xml
And /webapps/WEB-INF/web.xml

Still, the errors I get:
javax.servlet.ServletException: javax.naming.NameNotFoundException: Name
jdbc is not bound in this Context
	
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
mpl.java:862)
	
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:791)
	
org.apache.jsp.chgctrl_005fdetails_jsp._jspService(chgctrl_005fdetails_jsp.j
ava:942)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
77)
	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
	org.apache.naming.NamingContext.lookup(NamingContext.java:770)
	org.apache.naming.NamingContext.lookup(NamingContext.java:153)
	
org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(ResourceLink
Factory.java:97)
	javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
	org.apache.naming.NamingContext.lookup(NamingContext.java:793)
	org.apache.naming.NamingContext.lookup(NamingContext.java:140)
	org.apache.naming.NamingContext.lookup(NamingContext.java:781)
	org.apache.naming.NamingContext.lookup(NamingContext.java:153)
 

My META-INF/context.xml file's contents:

<Context>
<Resource name="jdbc/myoracle" 
auth="Container" 
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.DataSourceConnectionFactory"
driverClassName="oracle.jdbc.driver.OracleDriver"
 maxActive="125" 
 maxIdle="15" 
 maxWait="70000"
 removeAbandoned="true"
 removeAbandonedTimeout="300"
 logAbandoned="true"
username="usernm" 
password="pwd" 
url="jdbc:oracle:thin:@servername100:1526:SID"
minEvictableIdleTimeMillis="5000"
timeBetweenEvictionRunsMillis = "10000"
testWhileIdle="true" />
</Context>

And WEB-INF/web.xml
<resource-ref>
    <description>Change Ctrl App</description>
    <res-ref-name>jdbc/myoracle</res-ref-name>
    <res-ref-type>javax.sql.DataSource</res-ref-type>
    <res-auth>Container</res-auth>
  </resource-ref>

In addition to the previous servlet mappings that were on there before with
version 4.1.31

How/why would it not find the naming context?

Uuuuuggggghhh!!



-----Original Message-----
From: Propes, Barry L [GCG-NAOT] 
Sent: Thursday, February 25, 2010 3:53 PM
To: 'Tomcat Users List'
Subject: RE: DB connection error -Tomcat 6 config

I'll totally remove factory. It was necessary in my 4.1 build.

I'll also tweak the other ms time settings, and the WhileIdle - to borrow,
like you suggest and see if that works better, of if at all.

I'll also try removing the resource-ref and see what occurs.

Thanks, Chris.


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net]
Sent: Thursday, February 25, 2010 3:26 PM
To: Tomcat Users List
Subject: Re: DB connection error -Tomcat 6 config

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Barry,

On 2/25/2010 3:45 PM, Propes, Barry L wrote:
> Should be noted: for the factory type in the params below, I tried 
> both factory="org.apache.commons.dbcp.BasicDataSourceFactory" and 
> factory="org.apache.dbcp.BasicDataSourceFactory", each to no avail.

How about either factory="org.apache.tomcat.dbcp.BasicDataSourceFactory"
or specifying no factory at all and accepting the default (which is that
shown above)?

> I removed the commons ref to test out since there's no commons/lib dir 
> in TC 6.0.24, unlike in TC 4.1.31


Right: common/lib, server/lib, and shared/lib are essentially all merged
into a single /lib in Tomcat 6. You can play with catalina.properties and
make all kinds of ClassLoader hierarchies, but it's usually not worth it.

> <Context>
>   <!-- omitting - factory="oracle.jdbc.pool.OracleDataSourceFactory" 
> below--> <Resource name="jdbc/myoracle"
> auth="Container" 
> type="javax.sql.DataSource"
> factory="org.apache.commons.dbcp.BasicDataSourceFactory"
>  maxActive="125" 
>  maxIdle="15" 
>  maxWait="7000"
>  removeAbandoned="true"
>  removeAbandonedTimeout="30"
>  logAbandoned="true"
> username="user_name" 
> password="pass_word" 
> driverClassName="oracle.jdbc.OracleDriver"
> url="jdbc:oracle:thin:@159.177.102.100:1526:MYSID"
> minEvictableIdleTimeMillis="5000"
> timeBetweenEvictionRunsMillis = "10000"
> testWhileIdle="true"
> />
> </Context>

All that looks okay to me, although 700ms isn't a long time to wait for a
connection to come back from the pool: my guess is that you'd rather wait
for a while for a connection and give the user a complete, if late, response
rather than just giving them an error screen.

My position is that testWhildIdle isn't really useful: if you test on
borrow, that's usually sufficient unless you want to basically eliminate the
possibility that a connection will have to be re-established during a user
request.

Finally, 30 seconds is a very short "abandoned timeout", though only you can
determine what is appropriate in your environment. If you have some code
which executes 3 10-second queries, then your connection is considered
abandoned :(

> in webapps/WEB-INF/web.xml
> 
> <resource-ref>
> <description>My Ora datasource</description> 
> <res-ref-name>jdbc/myoracle</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>

In my experience, <resource-ref> is not necessary in web.xml but does follow
the spec.

So, still getting this error, then:
> javax.servlet.ServletException: javax.naming.NameNotFoundException: 
> Name jdbc is not bound in this Context

?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuG6v8ACgkQ9CaO5/Lv0PACzQCgjVa3oW+0SH14un73MsEFj5k6
yKwAoKSyLVqESWo4CxgiLOgMqXy+0ZNR
=GAHw
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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


---------------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message