You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mauro <mr...@gmail.com> on 2013/01/02 15:52:03 UTC

Re: some clarification about context.

On 30 December 2012 09:43, Pid * <pi...@pidster.com> wrote:
> On 29 Dec 2012, at 13:21, Mauro <mr...@gmail.com> wrote:
>
>> On 29 December 2012 13:04, Konstantin Kolinko <kn...@gmail.com> wrote:
>>> 2012/12/29 Mauro <mr...@gmail.com>:
>>>> Hello.
>>>> I've various web applications running under tomcat6.
>>>
>>> Which one of many 6.0.x versions?
>>
>> 6.0.35
>>
>>>
>>>> One of those use jndi, say the name of webapp is my_app.
>>>> I put a my_app.xml under Catalina/localhost/ with a context section in
>>>> which I put:
>>>>
>>>> <Resource name="jdbc/my_app" auth="Container" type="javax.sql.DataSource"
>>>>         maxActive="100" maxIdle="30" maxWait="10000"
>>>>         username="xxx" password="xxx" driverClassName="org.postgresql.Driver"
>>>>         url="jdbc:postgresql://svsopsql01.comune.cagliari.loc:5432/my_app"/>
>>>>
>>>> The jndi connection work well but........
>>>> I deploy another web application that uses jndi, say my_app1.
>>>> Put a my_app1.xml under Catalina/localhost/
>>>>
>>>>
>>>> <Resource name="jdbc/my_app1" auth="Container" type="javax.sql.DataSource"
>>>>         maxActive="100" maxIdle="30" maxWait="10000"
>>>>         username="xxx" password="xxx" driverClassName="org.postgresql.Driver"
>>>>         url="jdbc:postgresql://svsopsql01.comune.cagliari.loc:5432/my_app1"/>
>>>>
>>>>
>>>> This second application does not work and I must investigate on it but
>>>> the problem is that also the jndi connection of the first application,
>>>> my_app, does not work.
>>>> Why?
>>>> I'm correct on putting my_app.xml and my_app1.xml under Catalina/localhost?
>>>
>>> So, if it is one application then it works. If you deploy the second
>>> application then both the first and the second do not work?
>>
>> Yes, the second application has a problem and I must investigate on it
>> but it is strange to me that also the first application doesn't work.
>> Here what I do:
>> Deploy the second application, it does not work, the first application works.
>> To connect the second application via jndi I create my_app1.xml with a
>> resource section and put under Catalina/localhost.
>> So under Catalina/localhost i have my_app.xml and my_app1.xml.
>> Redeploy the second and the forst applications, the second still does
>> not work but now does not work also the first application.
>>
>>
>>> What do you mean by "does not work"?
>>> What are the symptoms, messages etc.
>>
>> Here is the message error of the first application:
>>
>> org.jruby.rack.RackInitializationException: The driver encountered an
>> unknown error: Cannot create JDBC driver of class
>> 'org.postgresql.Driver' for connect URL
>>
>>
>>>
>>> Where did you place your JDBC drivers?
>>> I'd say that they should be in $CATALINA_BASE/lib, and NOT in any of your wars.
>>
>> My drivers are under $CATALINA_BASE/lib, I use only postgres.
>
> Are you setting path or docBase in your Context XML?
>
> Can you post the exact file content, password redacted etc?

Here is my_app.xml:

<Context path="/myapp>
    <Resource name="jdbc/myapp" auth="Container" type="javax.sql.DataSource"
         maxActive="100" maxIdle="30" maxWait="10000"
         username="mauro" password="xxx" driverClassName="org.postgresql.Driver"
         url="jdbc:postgresql://svsopsql01.mydomain.com:5432/my_app"/>
</Context>

and here is my_app1.xml

<Context path="/myapp1>
    <Resource name="jdbc/myapp1" auth="Container" type="javax.sql.DataSource"
         maxActive="100" maxIdle="30" maxWait="10000"
         username="mauro" password="xxx" driverClassName="org.postgresql.Driver"
         url="jdbc:postgresql://svsopsql01.mydomain.com:5432/my_app1"/>
</Context>

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


Re: some clarification about context.

Posted by Mauro <mr...@gmail.com>.
On 3 January 2013 04:28, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Mauro,
>
> On 1/2/13 9:52 AM, Mauro wrote:
>> Here is my_app.xml:
>>
>> <Context path="/myapp> <Resource name="jdbc/myapp" auth="Container"
>> type="javax.sql.DataSource" maxActive="100" maxIdle="30"
>> maxWait="10000" username="mauro" password="xxx"
>> driverClassName="org.postgresql.Driver"
>> url="jdbc:postgresql://svsopsql01.mydomain.com:5432/my_app"/>
>> </Context>
>
> You should not be setting the "path" attribute of the <Context>: the
> path will be determined from the name of the file. Are you placing
> your WAR file (or exploded WAR directory) in your <Host>'s deployment
> directory (typically CATALINA_BASE/webapps)?

Yes.


> Unless you have a copy/paste error, the above is invalid XML because
> you haven't closed the "path" attribute's value.

It's a refuse.

>
> Everything else looks good to me.
>
>> and here is my_app1.xml
>>
>> <Context path="/myapp1> <Resource name="jdbc/myapp1"
>> auth="Container" type="javax.sql.DataSource" maxActive="100"
>> maxIdle="30" maxWait="10000" username="mauro" password="xxx"
>> driverClassName="org.postgresql.Driver"
>> url="jdbc:postgresql://svsopsql01.mydomain.com:5432/my_app1"/>
>> </Context>
>
> Same comments as above.
>
>> Here is the message error of the first application:
>>
>> org.jruby.rack.RackInitializationException: The driver encountered
>> an unknown error: Cannot create JDBC driver of class
>> 'org.postgresql.Driver' for connect URL
>
> You mentioned that you put your Postgres driver in CATALINA_BASE/lib.
> Do you also have those drivers in the WEB-INF/lib directory of either
> 'my_app' or 'my_app1'?

No, I've put the driver only under CATALINA_BASE/lib.

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


Re: some clarification about context.

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mauro,

On 1/2/13 9:52 AM, Mauro wrote:
> Here is my_app.xml:
> 
> <Context path="/myapp> <Resource name="jdbc/myapp" auth="Container"
> type="javax.sql.DataSource" maxActive="100" maxIdle="30"
> maxWait="10000" username="mauro" password="xxx"
> driverClassName="org.postgresql.Driver" 
> url="jdbc:postgresql://svsopsql01.mydomain.com:5432/my_app"/> 
> </Context>

You should not be setting the "path" attribute of the <Context>: the
path will be determined from the name of the file. Are you placing
your WAR file (or exploded WAR directory) in your <Host>'s deployment
directory (typically CATALINA_BASE/webapps)? If not, you'll have to
specify the docBase attribute in your <Context>.

Unless you have a copy/paste error, the above is invalid XML because
you haven't closed the "path" attribute's value.

Everything else looks good to me.

> and here is my_app1.xml
> 
> <Context path="/myapp1> <Resource name="jdbc/myapp1"
> auth="Container" type="javax.sql.DataSource" maxActive="100"
> maxIdle="30" maxWait="10000" username="mauro" password="xxx"
> driverClassName="org.postgresql.Driver" 
> url="jdbc:postgresql://svsopsql01.mydomain.com:5432/my_app1"/> 
> </Context>

Same comments as above.

> Here is the message error of the first application:
> 
> org.jruby.rack.RackInitializationException: The driver encountered
> an unknown error: Cannot create JDBC driver of class 
> 'org.postgresql.Driver' for connect URL

You mentioned that you put your Postgres driver in CATALINA_BASE/lib.
Do you also have those drivers in the WEB-INF/lib directory of either
'my_app' or 'my_app1'?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEAREIAAYFAlDk+vEACgkQ9CaO5/Lv0PB/bwCggAAiuB8oEXI9TR4vc9dwXMDU
u/YAn2k3S7anrY8SKZLMjSG/QxBf7ajG
=udjH
-----END PGP SIGNATURE-----

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