You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by torben <to...@frojonck.dk> on 2006/01/24 22:55:35 UTC

Postgresql and JNDI Datasource

I am trying to define a global JDBC datasource, where the database is 
Postgresql (version 7.3) ni Tomcat version 5.5.15.

I have strictly followed the example in 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html,
but it does not work if I define the datasource in 
$CATALINA_HOME/conf/server.xml.

However if I define the datasource in the application 
META-INF/context.xml, it is working.

I would prefer to define the datasource in 
$CATALINA_HOME/conf/server.xml. Has somebody succeded in doing that ? 
And if yes, how ?


Torben Frøberg

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


Re: Postgresql and JNDI Datasource

Posted by torben <to...@frojonck.dk>.
Edoardo Panfili wrote:

> torben ha scritto:
>
>> I am trying to define a global JDBC datasource, where the database is 
>> Postgresql (version 7.3) ni Tomcat version 5.5.15.
>>
>> I have strictly followed the example in 
>> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html, 
>>
>> but it does not work if I define the datasource in 
>> $CATALINA_HOME/conf/server.xml.
>>
>> However if I define the datasource in the application 
>> META-INF/context.xml, it is working.
>>
>> I would prefer to define the datasource in 
>> $CATALINA_HOME/conf/server.xml. Has somebody succeded in doing that ? 
>> And if yes, how ?
>>
>>
>> Torben Frøberg
>>
> this is my configuration:
> now I am using postgres 8.1 but it is the same configuration for my 
> old configuration (1 month ago) with postgres 7.4
>
> server.xml------------------------------------------
>        <Context path="/lisy" docBase="lisy" debug="5" reloadable="true">
>                <Resource name="jdbc/lisy" auth="Container" 
> type="javax.sql.DataSource"
>                        maxActive="8" maxIdle="5" maxWait="10000"
>                        username="uname" password="pwd" 
> driverClassName="org.postgresql.Driver"
>                        url="jdbc:postgresql://127.0.0.1:5432/lisy"
>                        removeAbandoned="true"
>                        removeAbandonedTimeout="30"
>                        logAbandoned="true"
>                />
>
>        </Context>
> web-xml------------------------------------------------
>        <resource-ref>
>                <description>postgreSQL Datasource</description>
>                <res-ref-name>jdbc/lisy</res-ref-name>
>                <res-type>javax.sql.DataSource</res-type>
>                <res-auth>Container</res-auth>
>        </resource-ref>
>
>
> I hope that this can help you
>
Yes, thank you. It works.

But how comes that it is not possible to define the resource as a 
GlobalNamingResource ?
It is the way it is defined in the example in 
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html. 


Torben

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


Re: Are servlet name and class name required in web.xml for tomcat 5.5?

Posted by David Smith <dn...@cornell.edu>.
You're talking about the Invoker servlet that automagicly mapped
requests to servlets.  This is a bad security problem that's best avoided.

First you need to declare all your servlets in web.xml:

<servlet>
  <servlet-name>NameOfServlet</servlet-name>
  <servlet-class>com.mycompany.myproject.MyServlet</servlet-class>
</servlet>

then declare the mappings of requests to servlets:

<servlet-mapping>
  <servlet-name>NameOfServlet</servlet-name>
  <url-pattern>/doAction/*</url-pattern>
</servlet-mapping>

In servlet specs prior to 2.4, the order of elements in the web.xml file
was important.  All the <servlet> elements had to be together and
precede the <servlet-mapping> elements.  Writing the web.xml file to
servlet spec 2.4 standard eliminates the ordering requirement.  More
information on this subject can be found in the servlet specs
themselves.  Tomcat 5.5 is servlet spec 2.4 conformant but can work with
previous servlet specs.

http://java.sun.com/products/servlet/download.html

--David

Alla Winter wrote:

>For Tomcat 4.x I didn't have to set up anything in web.xml.  But it seems
>that I have to define each servlet name and corresponding class name in
>web.xml in order to make it to work for Tomcat 5.5.  Is that right
>statement? 
>I have a lot of servlets, it seems like it is a lot of work.
>Can not find what info is required in web.xml and what is optional? Can you
>please refer me to that info?
>Thanks 
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
>
>  
>


-- 
=======================================
David Smith
Network Operations Supervisor
Department of Entomology
College of Agriculture & Life Sciences
Cornell University
2132 Comstock Hall
Ithaca, NY  14853
Phone: 607.255.9571
Fax: 607.255.0939


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


Are servlet name and class name required in web.xml for tomcat 5.5?

Posted by Alla Winter <al...@cobrasource.com>.
For Tomcat 4.x I didn't have to set up anything in web.xml.  But it seems
that I have to define each servlet name and corresponding class name in
web.xml in order to make it to work for Tomcat 5.5.  Is that right
statement? 
I have a lot of servlets, it seems like it is a lot of work.
Can not find what info is required in web.xml and what is optional? Can you
please refer me to that info?
Thanks 



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


Re: Postgresql and JNDI Datasource

Posted by Edoardo Panfili <ed...@aspix.it>.
torben ha scritto:
> I am trying to define a global JDBC datasource, where the database is 
> Postgresql (version 7.3) ni Tomcat version 5.5.15.
>
> I have strictly followed the example in 
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html, 
>
> but it does not work if I define the datasource in 
> $CATALINA_HOME/conf/server.xml.
>
> However if I define the datasource in the application 
> META-INF/context.xml, it is working.
>
> I would prefer to define the datasource in 
> $CATALINA_HOME/conf/server.xml. Has somebody succeded in doing that ? 
> And if yes, how ?
>
>
> Torben Frøberg
>
this is my configuration:
now I am using postgres 8.1 but it is the same configuration for my old 
configuration (1 month ago) with postgres 7.4

server.xml------------------------------------------
        <Context path="/lisy" docBase="lisy" debug="5" reloadable="true">
                <Resource name="jdbc/lisy" auth="Container" 
type="javax.sql.DataSource"
                        maxActive="8" maxIdle="5" maxWait="10000"
                        username="uname" password="pwd" 
driverClassName="org.postgresql.Driver"
                        url="jdbc:postgresql://127.0.0.1:5432/lisy"
                        removeAbandoned="true"
                        removeAbandonedTimeout="30"
                        logAbandoned="true"
                />

        </Context>
web-xml------------------------------------------------
        <resource-ref>
                <description>postgreSQL Datasource</description>
                <res-ref-name>jdbc/lisy</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
        </resource-ref>


I hope that this can help you

-- 
edoardo@aspix.it
AIM: edoardopn 
Jabber: edoardopa@talk.google.com
tel:075 9142766


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