You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kunthar <ku...@gmx.net> on 2004/06/13 18:19:55 UTC

I'll kill JNDI

Hi all,

I've installed apache 2.049 + Tomcat 5.0.26 + PostgreSQL and i could 
connect apache to tomcat after painful night with mod_jk2.
So far so good.
I could do regular jdbc connection by using traditional 
Class.forName(ZOBARA) method to my existing fair pgsql.
Then i wanted to try my first application's jdbc connection with DBCP 
Pool exist on Tomcat. You know, we need it for bunch of reasons.
I've read the documentation and also downloaded related JNDI reference 
from sun (which is completely makes blah blah about LDAP)
Check List;
0. rh-postgresql3.jar copied to $CATALINA_HOME/common/lib and removed 
from the all other locations.
1. Server.xml changed for postgre jdbc driver as described. (Checked for 
context tags)
2. web.xml changed as described.
3. My application connection element uses clear sample
// Obtain our environment naming context
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

// Look up our data source
DataSource ds = (DataSource)
  envCtx.lookup("jdbc/mydb");

4. Built this holly mess with ant by using build.xml
5. Point to my page and see this
"java.sql.SQLException: No connection"

Is there any single one have an idea what's going on???
I've double checked all the things. If anyone using postgreSQL with DBCP 
please give me a hint.

Thanks
Take care all


Note: Turkish list fellows just drop me a line :=)




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


Re: I'll kill JNDI

Posted by Kunthar <ku...@gmx.net>.
Thank you for your answer,
I've already done the same thing before i sent message to list. But i've
found that i should point this configuration to the every
context.
When i open admin section and go to Service(Catalina) /Host / Context
(/test) i saw that the defined jdbc connection in server.xml is not defined
for this context.
In DBCP Pool description it says, if you define a jdbc connection in
server.xml and put <resource-ref> tags to the web.xml and it works well.
This is not working on this way.
You should go to admin interface and should define your connection inside of
context.

Anyway,

It is now working for mee too..
Take care of all...


----- Original Message ----- 
From: "Adam Smith" <aj...@csolve.net>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Tuesday, June 15, 2004 2:15 PM
Subject: Re: I'll kill JNDI


> I can confirm that postgresql works ok with DBCP. All of my persistent
> components call the same connection code, whatever the database. It is
doing
> the following :
>
> public static Connection Connect(String resourcename)
>  throws javax.naming.NamingException, java.sql.SQLException
>  {
>   Context initContext = new InitialContext();
>   Context envContext  = (Context)initContext.lookup("java:/comp/env");
>   DataSource ds = (DataSource)envContext.lookup(resourcename);
>   return ds.getConnection();
>  }
>
> The resourcename passed in will be something like "jdbc/asl". An example
> server.xml entry looks
> like :
>
> <ResourceParams name="jdbc/asl">
>   <parameter>
>     <name>factory</name>
>     <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>   </parameter>
>   <parameter>
>     <name>driverClassName</name>
>     <value>org.postgresql.Driver</value>
>   </parameter>
>   <parameter>
>     <name>url</name>
>     <value>jdbc:postgresql://132.1.6.8:5432/asl</value> <!-- asl is a
> database that has been created in postgres -->
>   </parameter>
>   <parameter>
>     <name>username</name>
>     <value>bsuser</value> <!-- not the real user I'm using -->
>   </parameter>
>   <parameter>
>     <name>password</name>
>     <value>bspassword</value> <!-- not the real password I'm using -->
>   </parameter>
>   <parameter>
>     <name>maxActive</name>
>     <value>20</value>
>   </parameter>
>   <parameter>
>     <name>maxIdle</name>
>     <value>10</value>
>   </parameter>
>   <parameter>
>     <name>maxWait</name>
>     <value>-1</value>
>   </parameter>
> </ResourceParams>
>
>
> Hope this helps.
>
> Adam Smith
>
> ----- Original Message -----
> From: "Kunthar" <ku...@gmx.net>
> To: <to...@jakarta.apache.org>
> Sent: Sunday, June 13, 2004 12:19 PM
> Subject: I'll kill JNDI
>
>
> > Hi all,
> >
> > I've installed apache 2.049 + Tomcat 5.0.26 + PostgreSQL and i could
> > connect apache to tomcat after painful night with mod_jk2.
> > So far so good.
> > I could do regular jdbc connection by using traditional
> > Class.forName(ZOBARA) method to my existing fair pgsql.
> > Then i wanted to try my first application's jdbc connection with DBCP
> > Pool exist on Tomcat. You know, we need it for bunch of reasons.
> > I've read the documentation and also downloaded related JNDI reference
> > from sun (which is completely makes blah blah about LDAP)
> > Check List;
> > 0. rh-postgresql3.jar copied to $CATALINA_HOME/common/lib and removed
> > from the all other locations.
> > 1. Server.xml changed for postgre jdbc driver as described. (Checked for
> > context tags)
> > 2. web.xml changed as described.
> > 3. My application connection element uses clear sample
> > // Obtain our environment naming context
> > Context initCtx = new InitialContext();
> > Context envCtx = (Context) initCtx.lookup("java:comp/env");
> >
> > // Look up our data source
> > DataSource ds = (DataSource)
> >   envCtx.lookup("jdbc/mydb");
> >
> > 4. Built this holly mess with ant by using build.xml
> > 5. Point to my page and see this
> > "java.sql.SQLException: No connection"
> >
> > Is there any single one have an idea what's going on???
> > I've double checked all the things. If anyone using postgreSQL with DBCP
> > please give me a hint.
> >
> > Thanks
> > Take care all
> >
> >
> > Note: Turkish list fellows just drop me a line :=)
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.706 / Virus Database: 462 - Release Date: 14.06.2004


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


Re: I'll kill JNDI

Posted by Adam Smith <aj...@csolve.net>.
I can confirm that postgresql works ok with DBCP. All of my persistent
components call the same connection code, whatever the database. It is doing
the following :

public static Connection Connect(String resourcename)
 throws javax.naming.NamingException, java.sql.SQLException
 {
  Context initContext = new InitialContext();
  Context envContext  = (Context)initContext.lookup("java:/comp/env");
  DataSource ds = (DataSource)envContext.lookup(resourcename);
  return ds.getConnection();
 }

The resourcename passed in will be something like "jdbc/asl". An example
server.xml entry looks
like :

<ResourceParams name="jdbc/asl">
  <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
  </parameter>
  <parameter>
    <name>driverClassName</name>
    <value>org.postgresql.Driver</value>
  </parameter>
  <parameter>
    <name>url</name>
    <value>jdbc:postgresql://132.1.6.8:5432/asl</value> <!-- asl is a
database that has been created in postgres -->
  </parameter>
  <parameter>
    <name>username</name>
    <value>bsuser</value> <!-- not the real user I'm using -->
  </parameter>
  <parameter>
    <name>password</name>
    <value>bspassword</value> <!-- not the real password I'm using -->
  </parameter>
  <parameter>
    <name>maxActive</name>
    <value>20</value>
  </parameter>
  <parameter>
    <name>maxIdle</name>
    <value>10</value>
  </parameter>
  <parameter>
    <name>maxWait</name>
    <value>-1</value>
  </parameter>
</ResourceParams>


Hope this helps.

Adam Smith

----- Original Message -----
From: "Kunthar" <ku...@gmx.net>
To: <to...@jakarta.apache.org>
Sent: Sunday, June 13, 2004 12:19 PM
Subject: I'll kill JNDI


> Hi all,
>
> I've installed apache 2.049 + Tomcat 5.0.26 + PostgreSQL and i could
> connect apache to tomcat after painful night with mod_jk2.
> So far so good.
> I could do regular jdbc connection by using traditional
> Class.forName(ZOBARA) method to my existing fair pgsql.
> Then i wanted to try my first application's jdbc connection with DBCP
> Pool exist on Tomcat. You know, we need it for bunch of reasons.
> I've read the documentation and also downloaded related JNDI reference
> from sun (which is completely makes blah blah about LDAP)
> Check List;
> 0. rh-postgresql3.jar copied to $CATALINA_HOME/common/lib and removed
> from the all other locations.
> 1. Server.xml changed for postgre jdbc driver as described. (Checked for
> context tags)
> 2. web.xml changed as described.
> 3. My application connection element uses clear sample
> // Obtain our environment naming context
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("java:comp/env");
>
> // Look up our data source
> DataSource ds = (DataSource)
>   envCtx.lookup("jdbc/mydb");
>
> 4. Built this holly mess with ant by using build.xml
> 5. Point to my page and see this
> "java.sql.SQLException: No connection"
>
> Is there any single one have an idea what's going on???
> I've double checked all the things. If anyone using postgreSQL with DBCP
> please give me a hint.
>
> Thanks
> Take care all
>
>
> Note: Turkish list fellows just drop me a line :=)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>



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


Re: I'll kill JNDI

Posted by Jacob Kjome <ho...@visi.com>.
At 07:19 PM 6/13/2004 +0300, you wrote:
>Hi all,
>
>I've installed apache 2.049 + Tomcat 5.0.26 + PostgreSQL and i could 
>connect apache to tomcat after painful night with mod_jk2.
>So far so good.
>I could do regular jdbc connection by using traditional 
>Class.forName(ZOBARA) method to my existing fair pgsql.
>Then i wanted to try my first application's jdbc connection with DBCP Pool 
>exist on Tomcat. You know, we need it for bunch of reasons.
>I've read the documentation and also downloaded related JNDI reference 
>from sun (which is completely makes blah blah about LDAP)
>Check List;
>0. rh-postgresql3.jar copied to $CATALINA_HOME/common/lib and removed from 
>the all other locations.
>1. Server.xml changed for postgre jdbc driver as described. (Checked for 
>context tags)

What does "Checked for context tags" mean?  Either add the datasource stuff 
to <GlobalNamingResoruces> and provide a <ResourceLink> to it in your 
META-INF/context.xml or just define it completely in the latter.

>2. web.xml changed as described.
>3. My application connection element uses clear sample
>// Obtain our environment naming context
>Context initCtx = new InitialContext();
>Context envCtx = (Context) initCtx.lookup("java:comp/env");
>
>// Look up our data source
>DataSource ds = (DataSource)
>  envCtx.lookup("jdbc/mydb");
>
>4. Built this holly mess with ant by using build.xml
>5. Point to my page and see this
>"java.sql.SQLException: No connection"
>
>Is there any single one have an idea what's going on???
>I've double checked all the things. If anyone using postgreSQL with DBCP 
>please give me a hint.

Have you ever had this working with any database?  If so, then I'd suspect 
a bug in DBCP working with PostgreSQL.  However, if this is your first time 
using DBCP with Tomcat, I suspect it is something you did.  See my 
suggestion above and triple check everything.  If you still can't find 
anything wrong, post your config.


Jake


>Thanks
>Take care all
>
>
>Note: Turkish list fellows just drop me a line :=)
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


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