On 4/5/06, Mark Slater <[EMAIL PROTECTED]> wrote:
>
> I've been trying to get PostgreSQL set up to be accessed through JNDI
> in Tomcat 5.5.x. I found the docs page describing it, "jndi-
> datasource-examples-howto.html", and followed the example there, but
> it still doesn't work. I'm trying to provide access to PostgreSQL for
> use by both JDO and JCR in my web-apps.
>
> Here's the Resource definition I'm using:
>
>      <Resource name="jdbc/whisper_db"
>          auth="Container"
>          type="javax.sql.Datasource"
>          driverClassName="org.postgresql.Driver"
>          url="jdbc:postgresql://127.0.0.1:5432/my_db"


this is a postgres problem rather than tomcat problem.
try here jdbc:postgresql://localhost:5432/my_db (or template1)

if you want to access the database giving 127.0.0.1 you have to put
an entry in pg_hda.conf file.



         username="-------------------"
>          password="-------------------""
>          maxActive="10"
>          maxIdle="100"
>          maxWait="3000" />
>
>
> In my application's META-INF/context.xml, I have the following
> ResourceLink:
>
>      <ResourceLink
>          global="jdbc/whisper_db" name="jdbc/whisper_orm"
> type="javax.sql.Datasource" />
>
> In my application's WEB-INF/web.xml, I have the following resource-
> env-ref:
>
>      <resource-env-ref>
>          <description>Whisper's Database</description>
>          <resource-env-ref-name>jdbc/whisper_orm</resource-env-ref-name>
>          <resource-env-ref-type>javax.sql.Datasource</resource-env-
> ref-type>
>      </resource-env-ref>
>
>
> Depending on where I put the Resource definition, I get different
> errors.
>
> If I put it in the web-app's META-INF/context.xml, or in $TOMCAT_HOME/
> conf/context.xml, my JDO implementation complains:
>      NestableRuntimeException: There was an error duing JNDI lookup
> of the name "java:comp/env/jdbc/whisper_orm".
>      ....
>      Caused by: javax.naming.NameNotFoundException: Name jdbc is not
> bound in this Context
>
> If I put it in $TOMCAT_HOME/conf/server.xml, in the
> GlobalNamingResources section, I get:
>
> 2006-04-04 11:58:27,866 ERROR
> [org.apache.catalina.mbeans.GlobalResourcesLifecycleListener] -
> <Exception processing Global JNDI Resources>
> javax.naming.NamingException: Cannot create resource instance
>          at
> org.apache.naming.factory.ResourceFactory.getObjectInstance
> (ResourceFactory.java:132)
>          at javax.naming.spi.NamingManager.getObjectInstance
> (NamingManager.java:304)
>          at org.apache.naming.NamingContext.lookup(NamingContext.java:
> 792)
>          at org.apache.naming.NamingContext.lookup(NamingContext.java:
> 152)
>          at
> org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans
> (GlobalResourcesLifecycleListener.java:138)
>          at
> org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans
> (GlobalResourcesLifecycleListener.java:143)
>          at
> org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans
> (GlobalResourcesLifecycleListener.java:108)
>          at
> org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEve
> nt(GlobalResourcesLifecycleListener.java:80)
>          at
> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent
> (LifecycleSupport.java:119)
>          at org.apache.catalina.core.StandardServer.start
> (StandardServer.java:693)
>          at org.apache.catalina.startup.Catalina.start(Catalina.java:
> 551)
>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          at sun.reflect.NativeMethodAccessorImpl.invoke
> (NativeMethodAccessorImpl.java:39)
>          at sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.java:25)
>          at java.lang.reflect.Method.invoke(Method.java:585)
>          at org.apache.catalina.startup.Bootstrap.start
> (Bootstrap.java:275)
>          at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:
> 413)
>
> I'm assuming these errors are related, and that whatever is causing
> the NamingException is the same fundamental problem causing the
> NameNotFoundException in the context-based configuration. My problem
> is that I can't figure out what it is. The driver for the database
> (postgresql-8.1-405.jdbc3.jar) is in $TOMCAT_HOME/common/lib/, and
> I've also tried adding commons-dbcp-1.2.1.jar and commons-
> pool-1.2.jar alongside it (even though the docs say that shouldn't be
> necessary), but get the same errors.
>
> Is there any logging that I can turn on that will tell me the WHY
> Tomcat "Cannot create resource instance"? Or am I doing something
> obviously stupid with my Resource definition? Or could it be
> something else entirely?
>
> Any suggestions would be really helpful.
>
> Thanks!
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to