You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ps <pe...@ptinovacao.pt> on 2003/02/04 22:34:32 UTC
DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Greetings,
I'm downgrading my web application to work on tomcat 3.2.4 (initially
was developed and tested OK on tomcat 4.1.18). I'm using DBCP1.0.
problem:
--------
I can't get a datasource through JNDI that usually worked fine in tomcat
4.1.x, instead I'm getting an exception! Since I'm not aware about the
compatibility versions of tomcat, I ask for your help.
exception:
----------
"
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
...
"
And is caused on the following server code:
"
try{
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env/");
this.ds = (DataSource)envCtx.lookup("/jdbc/ngincaredb");
}
catch(NamingException e){
logger.fatal("datasource error", e);
}
"
web.xml:
--------
<resource-ref>
<res-ref-name>jdbc/ngincaredb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
server.xml:
-----------
<Context path="/ngincare"
docBase="webapps/ngincare"
crossContext="true"
debug="9"
reloadable="true"
trusted="false" >
<Resource name="jdbc/ngincaredb" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/ngincaredb">
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
...
</ResourceParams>
</Context>
thanks,
Pedro Salazar
--
<ps>
pedro-b-salazar@ptinovacao.pt
key id: 0E129E31D803BC61
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 5 Feb 2003, Sean Dockery wrote:
> Date: Wed, 05 Feb 2003 11:03:00 -0700
> From: Sean Dockery <se...@sbdconsultants.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
>
> You can still use DBCP in Tomcat 3.x, right?
Should work.
> You just can't deploy the
> data source through JNDI automatically...
>
Right.
> Could this be done manually? That is, could I not write a context listener
Um, context listeners are Servlet 2.3 things ... :-)
> that deployed the DBCP factory through JNDI when the application was
> started? I know that it would involve changing the catalina.policy file so
> that JNDI wasn't read-only to web applications, but could it not be done?
>
There *is* no implemented JNDI context to deploy into under Tomcat 3.2,
unless you create one yourself and include it in your webapp.
If you want to use DBCP under Tomcat 3.2, just set up an instance of
org.apache.commons.dbcp.BasicDataSource in the init() method of a servlet,
and make it available as a servlet context attribute (instead of through
JNDI).
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by Sean Dockery <se...@sbdconsultants.com>.
You can still use DBCP in Tomcat 3.x, right? You just can't deploy the
data source through JNDI automatically...
Could this be done manually? That is, could I not write a context listener
that deployed the DBCP factory through JNDI when the application was
started? I know that it would involve changing the catalina.policy file so
that JNDI wasn't read-only to web applications, but could it not be done?
At 09:07 2003-02-05 -0800, you wrote:
>Tomcat 3.2.4 does not support JNDI resources at all. You'll need to stick
>with current versions if you want that to work.
>
>Craig
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Sean Dockery
sean@sbdconsultants.com
Certified Java Web Component Developer
Certified Delphi Programmer
SBD Consultants
http://www.sbdconsultants.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 -> javax.naming.NoInitialContextException
Posted by ps <pe...@ptinovacao.pt>.
It appears that it needs more than an empty constructor in
InitialContext():
try{
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env/");
this.ds = (DataSource)envCtx.lookup("/jdbc/ngincaredb");
}
catch(NamingException e){
logger.fatal("datasource error", e);
}
So, the solution maybe doing something like this:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "????????");
Context initCtx = new InitialContext(env);
But the obvious question (and unknown for me) is what should be the
tomcat 3.2.4 default JNDI factory to put in
Context.INITIAL_CONTEXT_FACTORY attribute?? And why in tomcat 4.1.x it's
enough put a empty InitialContext()??
I don't find docs for tomcat 3.2.x about the resources/jndi...
thanks,
Pedro Salazar.
On Wed, 2003-02-05 at 11:48, ps wrote:
> Please, how should I interpret the exception message header below:
>
> javax.naming.NoInitialContextException: Need to specify class name in
> environment or system property, or as an applet parameter, or in an
> application resource file: java.naming.factory.initial
>
> I'm using jdk1.4.1 (SUN) and tomcat 3.2.4.
>
> thanks,
> Pedro Salazar.
>
--
<ps>
pedro-b-salazar@ptinovacao.pt
key id: 0E129E31D803BC61
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by ps <pe...@ptinovacao.pt>.
On Wed, 2003-02-05 at 17:07, Craig R. McClanahan wrote:
>
>
> On Wed, 5 Feb 2003, ps wrote:
>
> > Date: 05 Feb 2003 11:48:15 +0000
> > From: ps <pe...@ptinovacao.pt>
> > Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> > To: Tomcat Users List <to...@jakarta.apache.org>
> > Subject: Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
> >
> > Please, how should I interpret the exception message header below:
> >
> > javax.naming.NoInitialContextException: Need to specify class name in
> > environment or system property, or as an applet parameter, or in an
> > application resource file: java.naming.factory.initial
> >
> > I'm using jdk1.4.1 (SUN) and tomcat 3.2.4.
> >
>
> Tomcat 3.2.4 does not support JNDI resources at all. You'll need to stick
> with current versions if you want that to work.
OK, thanks Graig.
I wasn't sure about that but I was suspecting something *ugly* and
*stupid* like that. For one side I'm frustrated about that confirmation,
but I feel also relieved because I was struggling about configurations
and more configurations...
...I don't know much about the persistence of the using of tomcat 3.2.x
for production purposes but I have to resign to the power of politics in
force :-|
thanks,
Pedro Salazar.
--
<ps>
pedro-b-salazar@ptinovacao.pt
key id: 0E129E31D803BC61
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Wed, 5 Feb 2003, ps wrote:
> Date: 05 Feb 2003 11:48:15 +0000
> From: ps <pe...@ptinovacao.pt>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
>
> Please, how should I interpret the exception message header below:
>
> javax.naming.NoInitialContextException: Need to specify class name in
> environment or system property, or as an applet parameter, or in an
> application resource file: java.naming.factory.initial
>
> I'm using jdk1.4.1 (SUN) and tomcat 3.2.4.
>
Tomcat 3.2.4 does not support JNDI resources at all. You'll need to stick
with current versions if you want that to work.
> thanks,
> Pedro Salazar.
>
Craig
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by ps <pe...@ptinovacao.pt>.
Please, how should I interpret the exception message header below:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
I'm using jdk1.4.1 (SUN) and tomcat 3.2.4.
thanks,
Pedro Salazar.
On Tue, 2003-02-04 at 21:34, ps wrote:
> Greetings,
>
> I'm downgrading my web application to work on tomcat 3.2.4 (initially
> was developed and tested OK on tomcat 4.1.18). I'm using DBCP1.0.
>
> problem:
> --------
> I can't get a datasource through JNDI that usually worked fine in tomcat
> 4.1.x, instead I'm getting an exception! Since I'm not aware about the
> compatibility versions of tomcat, I ask for your help.
>
> exception:
> ----------
> "
> javax.naming.NoInitialContextException: Need to specify class name in
> environment or system property, or as an applet parameter, or in an
> application resource file: java.naming.factory.initial
> at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
> at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
> at
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
> at javax.naming.InitialContext.lookup(InitialContext.java:347)
> ...
> "
>
> And is caused on the following server code:
> "
> try{
> Context initCtx = new InitialContext();
> Context envCtx = (Context)initCtx.lookup("java:comp/env/");
> this.ds = (DataSource)envCtx.lookup("/jdbc/ngincaredb");
> }
> catch(NamingException e){
> logger.fatal("datasource error", e);
> }
>
> "
> web.xml:
> --------
> <resource-ref>
> <res-ref-name>jdbc/ngincaredb</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
>
> server.xml:
> -----------
> <Context path="/ngincare"
> docBase="webapps/ngincare"
> crossContext="true"
> debug="9"
> reloadable="true"
> trusted="false" >
>
> <Resource name="jdbc/ngincaredb" auth="Container"
> type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/ngincaredb">
> <parameter>
> <name>driverClassName</name>
> <value>oracle.jdbc.driver.OracleDriver</value>
> </parameter>
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> ...
> </ResourceParams>
>
> </Context>
>
> thanks,
> Pedro Salazar
>
> --
> <ps>
> pedro-b-salazar@ptinovacao.pt
> key id: 0E129E31D803BC61
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
--
<ps>
pedro-b-salazar@ptinovacao.pt
key id: 0E129E31D803BC61
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by ps <pe...@ptinovacao.pt>.
On Tue, 2003-02-04 at 22:38, Sean Dockery wrote:
> Weird that your envCtx.lookup is done on /jdbc/ngincaredb. I've never seen
> it done on an absolute path before. :-)
Yes, I don't know why I put it like that, maybe I was guided by an
example, maybe it was a writing mistake that worked fine in tomcat
4.1.x, ... I don't know :-|
>
> Please provide all of the parameters that you are declaring under the
> ResourceParams section. (I don't want to know your username and
> password--I just want to know the entire list...)
>
Sure! I just didn't put that here because I was thinking in a macro
structure and maybe the rest (password or not) was not relevant to debug
my problem. But as you request it, I will post the complete resource
here.
<Resource name="jdbc/ngincaredb" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/ngincaredb">
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>username</name>
<value>user</value>
</parameter>
<parameter>
<name>password</name>
<value>pass</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@192.168.89.52:1521:dbdev817</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>25</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>50</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>15</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>select 1 as test from dual</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
</ResourceParams>
Thanks,
Pedro Salazar
> At 14:34 2003-02-04, you wrote:
> >And is caused on the following server code:
> >"
> >try{
> > Context initCtx = new InitialContext();
> > Context envCtx = (Context)initCtx.lookup("java:comp/env/");
> > this.ds = (DataSource)envCtx.lookup("/jdbc/ngincaredb");
> >}
> >catch(NamingException e){
> > logger.fatal("datasource error", e);
> >}
> >
> >"
> >web.xml:
> >--------
> ><resource-ref>
> > <res-ref-name>jdbc/ngincaredb</res-ref-name>
> > <res-type>javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> ></resource-ref>
> >
> >
> >server.xml:
> >-----------
> ><Context path="/ngincare"
> > docBase="webapps/ngincare"
> > crossContext="true"
> > debug="9"
> > reloadable="true"
> > trusted="false" >
> >
> > <Resource name="jdbc/ngincaredb" auth="Container"
> > type="javax.sql.DataSource"/>
> > <ResourceParams name="jdbc/ngincaredb">
> > <parameter>
> > <name>driverClassName</name>
> > <value>oracle.jdbc.driver.OracleDriver</value>
> > </parameter>
> > <parameter>
> > <name>factory</name>
> > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> > </parameter>
> > ...
> > </ResourceParams>
> >
> ></Context>
>
> Sean Dockery
> sean@sbdconsultants.com
> Certified Java Web Component Developer
> Certified Delphi Programmer
> SBD Consultants
> http://www.sbdconsultants.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
--
<ps>
pedro-b-salazar@ptinovacao.pt
key id: 0E129E31D803BC61
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: DBCP+TOMCAT 3.2.4 (->4.1.x WORKED OK)
Posted by Sean Dockery <se...@sbdconsultants.com>.
Weird that your envCtx.lookup is done on /jdbc/ngincaredb. I've never seen
it done on an absolute path before. :-)
Please provide all of the parameters that you are declaring under the
ResourceParams section. (I don't want to know your username and
password--I just want to know the entire list...)
At 14:34 2003-02-04, you wrote:
>And is caused on the following server code:
>"
>try{
> Context initCtx = new InitialContext();
> Context envCtx = (Context)initCtx.lookup("java:comp/env/");
> this.ds = (DataSource)envCtx.lookup("/jdbc/ngincaredb");
>}
>catch(NamingException e){
> logger.fatal("datasource error", e);
>}
>
>"
>web.xml:
>--------
><resource-ref>
> <res-ref-name>jdbc/ngincaredb</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
></resource-ref>
>
>
>server.xml:
>-----------
><Context path="/ngincare"
> docBase="webapps/ngincare"
> crossContext="true"
> debug="9"
> reloadable="true"
> trusted="false" >
>
> <Resource name="jdbc/ngincaredb" auth="Container"
> type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/ngincaredb">
> <parameter>
> <name>driverClassName</name>
> <value>oracle.jdbc.driver.OracleDriver</value>
> </parameter>
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> ...
> </ResourceParams>
>
></Context>
Sean Dockery
sean@sbdconsultants.com
Certified Java Web Component Developer
Certified Delphi Programmer
SBD Consultants
http://www.sbdconsultants.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org