Re: Trouble with context and JNDI resource

View: New views
7 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Trouble with context and JNDI resource

by Carsten Pohl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am no expert, but your lookup looks strange. (Empty string in lookup). Furthermore these two contextes seem "strange" to me.

This works great for me:
    @Override
    public void init() throws ServletException {
    LOGGER.info("INIT has been called");
       try
       {
         final InitialContext initialContext = new InitialContext();
         if ( initialContext == null )
         {
          final String error = "Could not create initialContext. Errors WILL happen";
          LOGGER.severe(error);
          throw new ServletException(error);
         }

         // actual jndi name is "jdbc/postgres"
         CustomerloungeServlet.datasource = (DataSource) initialContext.lookup( "java:/comp/env/jdbc/postgres" );

         if ( CustomerloungeServlet.datasource == null )
         {
          final String error = "Could not lookup, Errors WILL happen";
          LOGGER.severe(error);
          throw new ServletException(error);
         }
       }
       catch (NamingException e)
       {
      LOGGER.log(Level.SEVERE,"Namingexception in init",e);
          throw new ServletException(e.getMessage());
       }  
    }


And I did not put

org.apache.commons.dbcp.BasicDataSource as type of the ressource.

I guess it must be org.apache.commons.dbcp.dbcp..... (I guess) but in the tomcat source is string compared to:

"javax.sql.DataSource"

You can try that.

Regards,
Carsten Pohl



----- Original Message -----
From: "Mike Baranski" <list-subscriptions@...>
To: "Tomcat Users List" <users@...>
Sent: Tuesday, 3 November, 2009 14:49:04 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Trouble with context and JNDI resource

I'm using this page, trying to get a resource in a java class:

http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html

I have this in context.xml:


<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
       
    <!-- Uncomment this to disable session persistence across Tomcat
restarts -->
    <!--
    <Manager pathname="" />
    -->
                <Resource name="proteus" auth="Container"
type="org.apache.commons.dbcp.BasicDataSource"
              maxActive="100" maxIdle="30" maxWait="10000"
              username="install" password="install"
driverClassName="com.informix.jdbc.IfxDriver"
 
url="jdbc:informix-sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
                </Resource>
</Context>

I have this in web.xml:

<resource-env-ref>
                <description>
                        Connection pool for xmlrpc.
                </description>
                <resource-env-ref-name>
                        proteus
                </resource-env-ref-name>
                <resource-env-ref-type>
                        org.apache.commons.dbcp.BasicDataSource

                </resource-env-ref-type>
</resource-env-ref>

I have this code:

l.debug("Created the status xmlrpc class");
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("");
this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));

I get this error:

Name proteus is not bound in this Context


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


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


RE: Trouble with context and JNDI resource

by Mike Baranski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, thanks, what does your context.xml look like for the jdbc/progress?

>-----Original Message-----
>From: Carsten Pohl [mailto:pohl@...]
>Sent: Tuesday, November 03, 2009 9:03 AM
>To: Tomcat Users List
>Subject: Re: Trouble with context and JNDI resource
>
>Hi,
>
>I am no expert, but your lookup looks strange. (Empty string in lookup).
>Furthermore these two contextes seem "strange" to me.
>
>This works great for me:
>    @Override
>    public void init() throws ServletException {
>   LOGGER.info("INIT has been called");
>       try
>       {
>         final InitialContext initialContext = new InitialContext();
>         if ( initialContext == null )
>         {
>         final String error = "Could not create initialContext.
>Errors WILL happen";
>         LOGGER.severe(error);
>         throw new ServletException(error);
>         }
>
>         // actual jndi name is "jdbc/postgres"
>         CustomerloungeServlet.datasource = (DataSource)
>initialContext.lookup( "java:/comp/env/jdbc/postgres" );
>
>         if ( CustomerloungeServlet.datasource == null )
>         {
>         final String error = "Could not lookup, Errors WILL happen";
>         LOGGER.severe(error);
>         throw new ServletException(error);
>         }
>       }
>       catch (NamingException e)
>       {
>       LOGGER.log(Level.SEVERE,"Namingexception in init",e);
>          throw new ServletException(e.getMessage());
>       }
>    }
>
>
>And I did not put
>
>org.apache.commons.dbcp.BasicDataSource as type of the ressource.
>
>I guess it must be org.apache.commons.dbcp.dbcp..... (I guess) but in
>the tomcat source is string compared to:
>
>"javax.sql.DataSource"
>
>You can try that.
>
>Regards,
>Carsten Pohl
>
>
>
>----- Original Message -----
>From: "Mike Baranski" <list-subscriptions@...>
>To: "Tomcat Users List" <users@...>
>Sent: Tuesday, 3 November, 2009 14:49:04 GMT +01:00 Amsterdam / Berlin /
>Bern / Rome / Stockholm / Vienna
>Subject: Trouble with context and JNDI resource
>
>I'm using this page, trying to get a resource in a java class:
>
>http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
>
>I have this in context.xml:
>
>
><Context>
>
>    <!-- Default set of monitored resources -->
>    <WatchedResource>WEB-INF/web.xml</WatchedResource>
>
>    <!-- Uncomment this to disable session persistence across Tomcat
>restarts -->
>    <!--
>    <Manager pathname="" />
>    -->
> <Resource name="proteus" auth="Container"
>type="org.apache.commons.dbcp.BasicDataSource"
>              maxActive="100" maxIdle="30" maxWait="10000"
>              username="install" password="install"
>driverClassName="com.informix.jdbc.IfxDriver"
>
>url="jdbc:informix-
>sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
>ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
> </Resource>
></Context>
>
>I have this in web.xml:
>
><resource-env-ref>
> <description>
> Connection pool for xmlrpc.
> </description>
> <resource-env-ref-name>
> proteus
> </resource-env-ref-name>
> <resource-env-ref-type>
> org.apache.commons.dbcp.BasicDataSource
>
> </resource-env-ref-type>
></resource-env-ref>
>
>I have this code:
>
>l.debug("Created the status xmlrpc class");
>Context initCtx = new InitialContext();
>Context envCtx = (Context) initCtx.lookup("");
>this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
>
>I get this error:
>
>Name proteus is not bound in this Context
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@...
>For additional commands, e-mail: users-help@...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@...
>For additional commands, e-mail: users-help@...


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


Re: Trouble with context and JNDI resource

by Carsten Pohl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My context.xml is quite straightforward.

<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <Resource name="jdbc/postgres"
        override="true"
        auth="Container"
        type="javax.sql.DataSource"
        driverClassName="org.postgresql.Driver"
        url="jdbc:postgresql://SERVERNAME:5432/Dionysos"
        username="FOO"
        password="BAZ"
        maxActive="20"
        maxIdle="10"
        maxWait="1000"
        removeAbandoned="true"
        removeAbandonedTimeout="15"
        logAbandoned="true"
        validationQuery="SELECT 1"/>
</Context>


I put it in the META-INF folder of my WAR.

But be advised: If you think you can change the url/username or passwd once the app has been deployed in Catalina/localhost/WEBAPPNAME.xml it will NOT work.

Regards,
Carsten Pohl


----- Original Message -----
From: "Mike Baranski" <list-subscriptions@...>
To: "Tomcat Users List" <users@...>, pohl@...
Sent: Tuesday, 3 November, 2009 15:15:45 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: RE: Trouble with context and JNDI resource

OK, thanks, what does your context.xml look like for the jdbc/progress?

>-----Original Message-----
>From: Carsten Pohl [mailto:pohl@...]
>Sent: Tuesday, November 03, 2009 9:03 AM
>To: Tomcat Users List
>Subject: Re: Trouble with context and JNDI resource
>
>Hi,
>
>I am no expert, but your lookup looks strange. (Empty string in lookup).
>Furthermore these two contextes seem "strange" to me.
>
>This works great for me:
>    @Override
>    public void init() throws ServletException {
>   LOGGER.info("INIT has been called");
>       try
>       {
>         final InitialContext initialContext = new InitialContext();
>         if ( initialContext == null )
>         {
>         final String error = "Could not create initialContext.
>Errors WILL happen";
>         LOGGER.severe(error);
>         throw new ServletException(error);
>         }
>
>         // actual jndi name is "jdbc/postgres"
>         CustomerloungeServlet.datasource = (DataSource)
>initialContext.lookup( "java:/comp/env/jdbc/postgres" );
>
>         if ( CustomerloungeServlet.datasource == null )
>         {
>         final String error = "Could not lookup, Errors WILL happen";
>         LOGGER.severe(error);
>         throw new ServletException(error);
>         }
>       }
>       catch (NamingException e)
>       {
>       LOGGER.log(Level.SEVERE,"Namingexception in init",e);
>          throw new ServletException(e.getMessage());
>       }
>    }
>
>
>And I did not put
>
>org.apache.commons.dbcp.BasicDataSource as type of the ressource.
>
>I guess it must be org.apache.commons.dbcp.dbcp..... (I guess) but in
>the tomcat source is string compared to:
>
>"javax.sql.DataSource"
>
>You can try that.
>
>Regards,
>Carsten Pohl
>
>
>
>----- Original Message -----
>From: "Mike Baranski" <list-subscriptions@...>
>To: "Tomcat Users List" <users@...>
>Sent: Tuesday, 3 November, 2009 14:49:04 GMT +01:00 Amsterdam / Berlin /
>Bern / Rome / Stockholm / Vienna
>Subject: Trouble with context and JNDI resource
>
>I'm using this page, trying to get a resource in a java class:
>
>http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
>
>I have this in context.xml:
>
>
><Context>
>
>    <!-- Default set of monitored resources -->
>    <WatchedResource>WEB-INF/web.xml</WatchedResource>
>
>    <!-- Uncomment this to disable session persistence across Tomcat
>restarts -->
>    <!--
>    <Manager pathname="" />
>    -->
> <Resource name="proteus" auth="Container"
>type="org.apache.commons.dbcp.BasicDataSource"
>              maxActive="100" maxIdle="30" maxWait="10000"
>              username="install" password="install"
>driverClassName="com.informix.jdbc.IfxDriver"
>
>url="jdbc:informix-
>sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
>ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
> </Resource>
></Context>
>
>I have this in web.xml:
>
><resource-env-ref>
> <description>
> Connection pool for xmlrpc.
> </description>
> <resource-env-ref-name>
> proteus
> </resource-env-ref-name>
> <resource-env-ref-type>
> org.apache.commons.dbcp.BasicDataSource
>
> </resource-env-ref-type>
></resource-env-ref>
>
>I have this code:
>
>l.debug("Created the status xmlrpc class");
>Context initCtx = new InitialContext();
>Context envCtx = (Context) initCtx.lookup("");
>this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
>
>I get this error:
>
>Name proteus is not bound in this Context
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@...
>For additional commands, e-mail: users-help@...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@...
>For additional commands, e-mail: users-help@...


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


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


RE: Trouble with context and JNDI resource

by Mike Baranski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, I know, what's the convention for doing this without changing the context.xml and restarting tomcat?

>-----Original Message-----
>From: Carsten Pohl [mailto:pohl@...]
>Sent: Tuesday, November 03, 2009 9:30 AM
>To: Tomcat Users List
>Subject: Re: Trouble with context and JNDI resource
>
>My context.xml is quite straightforward.
>
><?xml version="1.0" encoding="UTF-8"?>
><Context>
>    <Resource name="jdbc/postgres"
>        override="true"
>        auth="Container"
>        type="javax.sql.DataSource"
>        driverClassName="org.postgresql.Driver"
>        url="jdbc:postgresql://SERVERNAME:5432/Dionysos"
>        username="FOO"
>        password="BAZ"
>        maxActive="20"
>        maxIdle="10"
>        maxWait="1000"
>        removeAbandoned="true"
>        removeAbandonedTimeout="15"
>        logAbandoned="true"
>        validationQuery="SELECT 1"/>
></Context>
>
>
>I put it in the META-INF folder of my WAR.
>
>But be advised: If you think you can change the url/username or passwd
>once the app has been deployed in Catalina/localhost/WEBAPPNAME.xml it
>will NOT work.
>
>Regards,
>Carsten Pohl
>
>
>----- Original Message -----
>From: "Mike Baranski" <list-subscriptions@...>
>To: "Tomcat Users List" <users@...>, pohl@...
>Sent: Tuesday, 3 November, 2009 15:15:45 GMT +01:00 Amsterdam / Berlin /
>Bern / Rome / Stockholm / Vienna
>Subject: RE: Trouble with context and JNDI resource
>
>OK, thanks, what does your context.xml look like for the jdbc/progress?
>
>>-----Original Message-----
>>From: Carsten Pohl [mailto:pohl@...]
>>Sent: Tuesday, November 03, 2009 9:03 AM
>>To: Tomcat Users List
>>Subject: Re: Trouble with context and JNDI resource
>>
>>Hi,
>>
>>I am no expert, but your lookup looks strange. (Empty string in
>lookup).
>>Furthermore these two contextes seem "strange" to me.
>>
>>This works great for me:
>>    @Override
>>    public void init() throws ServletException {
>>   LOGGER.info("INIT has been called");
>>       try
>>       {
>>         final InitialContext initialContext = new InitialContext();
>>         if ( initialContext == null )
>>         {
>>         final String error = "Could not create initialContext.
>>Errors WILL happen";
>>         LOGGER.severe(error);
>>         throw new ServletException(error);
>>         }
>>
>>         // actual jndi name is "jdbc/postgres"
>>         CustomerloungeServlet.datasource = (DataSource)
>>initialContext.lookup( "java:/comp/env/jdbc/postgres" );
>>
>>         if ( CustomerloungeServlet.datasource == null )
>>         {
>>         final String error = "Could not lookup, Errors WILL happen";
>>         LOGGER.severe(error);
>>         throw new ServletException(error);
>>         }
>>       }
>>       catch (NamingException e)
>>       {
>>       LOGGER.log(Level.SEVERE,"Namingexception in init",e);
>>          throw new ServletException(e.getMessage());
>>       }
>>    }
>>
>>
>>And I did not put
>>
>>org.apache.commons.dbcp.BasicDataSource as type of the ressource.
>>
>>I guess it must be org.apache.commons.dbcp.dbcp..... (I guess) but in
>>the tomcat source is string compared to:
>>
>>"javax.sql.DataSource"
>>
>>You can try that.
>>
>>Regards,
>>Carsten Pohl
>>
>>
>>
>>----- Original Message -----
>>From: "Mike Baranski" <list-subscriptions@...>
>>To: "Tomcat Users List" <users@...>
>>Sent: Tuesday, 3 November, 2009 14:49:04 GMT +01:00 Amsterdam / Berlin
>/
>>Bern / Rome / Stockholm / Vienna
>>Subject: Trouble with context and JNDI resource
>>
>>I'm using this page, trying to get a resource in a java class:
>>
>>http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
>>
>>I have this in context.xml:
>>
>>
>><Context>
>>
>>    <!-- Default set of monitored resources -->
>>    <WatchedResource>WEB-INF/web.xml</WatchedResource>
>>
>>    <!-- Uncomment this to disable session persistence across Tomcat
>>restarts -->
>>    <!--
>>    <Manager pathname="" />
>>    -->
>> <Resource name="proteus" auth="Container"
>>type="org.apache.commons.dbcp.BasicDataSource"
>>              maxActive="100" maxIdle="30" maxWait="10000"
>>              username="install" password="install"
>>driverClassName="com.informix.jdbc.IfxDriver"
>>
>>url="jdbc:informix-
>>sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
>>ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
>> </Resource>
>></Context>
>>
>>I have this in web.xml:
>>
>><resource-env-ref>
>> <description>
>> Connection pool for xmlrpc.
>> </description>
>> <resource-env-ref-name>
>> proteus
>> </resource-env-ref-name>
>> <resource-env-ref-type>
>> org.apache.commons.dbcp.BasicDataSource
>>
>> </resource-env-ref-type>
>></resource-env-ref>
>>
>>I have this code:
>>
>>l.debug("Created the status xmlrpc class");
>>Context initCtx = new InitialContext();
>>Context envCtx = (Context) initCtx.lookup("");
>>this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
>>
>>I get this error:
>>
>>Name proteus is not bound in this Context
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@...
>>For additional commands, e-mail: users-help@...
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@...
>>For additional commands, e-mail: users-help@...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@...
>For additional commands, e-mail: users-help@...
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@...
>For additional commands, e-mail: users-help@...


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


Re: Trouble with context and JNDI resource

by Mikolaj Rydzewski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mike Baranski wrote:
> Yes, I know, what's the convention for doing this without changing the context.xml and restarting tomcat?
>  
Put context.xml in META-INF directory of your webapp.

--
Mikolaj Rydzewski <miki@...>


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


RE: Trouble with context and JNDI resource

by mgainty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


carsten is correct

i would set the PGDATA environment var to point to exact location of Postgres Database directory e.g (pg_ctl -D, --pgdata DATADIR) before attempting connect to Postgres

Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Tue, 3 Nov 2009 15:30:12 +0100
> From: pohl@...
> To: users@...
> Subject: Re: Trouble with context and JNDI resource
>
> My context.xml is quite straightforward.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Context>
>     <Resource name="jdbc/postgres"
>         override="true"
>         auth="Container"
>         type="javax.sql.DataSource"
>         driverClassName="org.postgresql.Driver"
>         url="jdbc:postgresql://SERVERNAME:5432/Dionysos"
>         username="FOO"
>         password="BAZ"
>         maxActive="20"
>         maxIdle="10"
>         maxWait="1000"
>         removeAbandoned="true"
>         removeAbandonedTimeout="15"
>         logAbandoned="true"
>         validationQuery="SELECT 1"/>
> </Context>
>
>
> I put it in the META-INF folder of my WAR.
>
> But be advised: If you think you can change the url/username or passwd once the app has been deployed in Catalina/localhost/WEBAPPNAME.xml it will NOT work.
>
> Regards,
> Carsten Pohl
>
>
> ----- Original Message -----
> From: "Mike Baranski" <list-subscriptions@...>
> To: "Tomcat Users List" <users@...>, pohl@...
> Sent: Tuesday, 3 November, 2009 15:15:45 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
> Subject: RE: Trouble with context and JNDI resource
>
> OK, thanks, what does your context.xml look like for the jdbc/progress?
>
> >-----Original Message-----
> >From: Carsten Pohl [mailto:pohl@...]
> >Sent: Tuesday, November 03, 2009 9:03 AM
> >To: Tomcat Users List
> >Subject: Re: Trouble with context and JNDI resource
> >
> >Hi,
> >
> >I am no expert, but your lookup looks strange. (Empty string in lookup).
> >Furthermore these two contextes seem "strange" to me.
> >
> >This works great for me:
> >    @Override
> >    public void init() throws ServletException {
> >   LOGGER.info("INIT has been called");
> >       try
> >       {
> >         final InitialContext initialContext = new InitialContext();
> >         if ( initialContext == null )
> >         {
> >         final String error = "Could not create initialContext.
> >Errors WILL happen";
> >         LOGGER.severe(error);
> >         throw new ServletException(error);
> >         }
> >
> >         // actual jndi name is "jdbc/postgres"
> >         CustomerloungeServlet.datasource = (DataSource)
> >initialContext.lookup( "java:/comp/env/jdbc/postgres" );
> >
> >         if ( CustomerloungeServlet.datasource == null )
> >         {
> >         final String error = "Could not lookup, Errors WILL happen";
> >         LOGGER.severe(error);
> >         throw new ServletException(error);
> >         }
> >       }
> >       catch (NamingException e)
> >       {
> >       LOGGER.log(Level.SEVERE,"Namingexception in init",e);
> >          throw new ServletException(e.getMessage());
> >       }
> >    }
> >
> >
> >And I did not put
> >
> >org.apache.commons.dbcp.BasicDataSource as type of the ressource.
> >
> >I guess it must be org.apache.commons.dbcp.dbcp..... (I guess) but in
> >the tomcat source is string compared to:
> >
> >"javax.sql.DataSource"
> >
> >You can try that.
> >
> >Regards,
> >Carsten Pohl
> >
> >
> >
> >----- Original Message -----
> >From: "Mike Baranski" <list-subscriptions@...>
> >To: "Tomcat Users List" <users@...>
> >Sent: Tuesday, 3 November, 2009 14:49:04 GMT +01:00 Amsterdam / Berlin /
> >Bern / Rome / Stockholm / Vienna
> >Subject: Trouble with context and JNDI resource
> >
> >I'm using this page, trying to get a resource in a java class:
> >
> >http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
> >
> >I have this in context.xml:
> >
> >
> ><Context>
> >
> >    <!-- Default set of monitored resources -->
> >    <WatchedResource>WEB-INF/web.xml</WatchedResource>
> >
> >    <!-- Uncomment this to disable session persistence across Tomcat
> >restarts -->
> >    <!--
> >    <Manager pathname="" />
> >    -->
> > <Resource name="proteus" auth="Container"
> >type="org.apache.commons.dbcp.BasicDataSource"
> >              maxActive="100" maxIdle="30" maxWait="10000"
> >              username="install" password="install"
> >driverClassName="com.informix.jdbc.IfxDriver"
> >
> >url="jdbc:informix-
> >sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
> >ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
> > </Resource>
> ></Context>
> >
> >I have this in web.xml:
> >
> ><resource-env-ref>
> > <description>
> > Connection pool for xmlrpc.
> > </description>
> > <resource-env-ref-name>
> > proteus
> > </resource-env-ref-name>
> > <resource-env-ref-type>
> > org.apache.commons.dbcp.BasicDataSource
> >
> > </resource-env-ref-type>
> ></resource-env-ref>
> >
> >I have this code:
> >
> >l.debug("Created the status xmlrpc class");
> >Context initCtx = new InitialContext();
> >Context envCtx = (Context) initCtx.lookup("");
> >this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
> >
> >I get this error:
> >
> >Name proteus is not bound in this Context
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe@...
> >For additional commands, e-mail: users-help@...
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: users-unsubscribe@...
> >For additional commands, e-mail: users-help@...
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
     
_________________________________________________________________
Windows 7: Unclutter your desktop.
http://go.microsoft.com/?linkid=9690331&ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen:112009

Re: Trouble with context and JNDI resource

by Mikolaj Rydzewski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Martin Gainty wrote:
> i would set the PGDATA environment var to point to exact location of Postgres Database directory e.g (pg_ctl -D, --pgdata DATADIR) before attempting connect to Postgres
>  
Since we use TCP/IP to talk to postgres PGDATA is irrevelant (at client
side).

--
Mikolaj Rydzewski <miki@...>


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