You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Rob S." <ro...@tintri.com> on 2010/03/04 20:12:55 UTC

[6.0.20] Using -Dcatalina.config breaks our databases resources

Hi everyone,

We have a custom resource defined in context.xml:

<Resource name="jdbc/postgres" scope="Shareable" type="javax.sql.DataSource"
    ...
    driverClassName="org.postgresql.Driver"/>

We prefer to locate the postgres jar file in CATALINA_BASE, so we modified
this line in catalina.config

common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,*
${catalina.base}/lib,${catalina.base}/lib/*.jar*

We made this change in both out catalina.properties and
catalina.properties.development files.

Unfortunately when we use -Dcatalina.config to specify
catalina.properties.development, the postgres.jar file is no longer found
when Tomcat attempts to create a connection.

I know that our catalina.properties.development file is being used because
other properties in that file are used (i.e. ${https.port} is used in
server.xml and Tomcat does use that correct value).

Any ideas?  Is there a way for me to dump the value of common.loader after
Tomcat starts to be sure it's at least seeing the value from our config
file?

Thanks!

Rob

RE: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rob S. [mailto:rob@tintri.com]
> Subject: Re: [6.0.20] Using -Dcatalina.config breaks our databases
> resources
> 
> I've been following the 6.0 "monitoring" guide although jconsole 
> says it can't connect

What JVM version are you using?  What's your platform?  (If you're running Tomcat as a Windows service on Vista or later, you won't be able to connect to it with JConsole unless JConsole is using the same account as the service.)

Look at the System Properties; the one named common.loader contains the path that ClassLoader is using.

> netstat doesn't report anyone listening on the port I specified.

That's a serious problem.

> > Any chance this is a permissions problem?
> 
> Could be!  How do you mean? :)

Does the userid Tomcat is running under have access to the .properties file and the jar when you're running in development mode?

Another thought: make sure you haven't changed the line terminator mode in catalina.properties.development.  If there's a carriage return at the end and you're running on a Linux box, the CR might be taken as part of the lib/*.jar entry - resulting in a no find.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Rob S." <ro...@tintri.com>.
Ah, well I have to apologize, it looks like my IDE was culprit.

IDEA deploys Tomcat from a newly created directory at each deploy (i.e. it
copies some known files from CATALINA_BASE).

Well of course it doesn't copy /lib since we created that directory - it's
not part of the "standard" CATALINA_BASE.  Here's what the classloader
thinks the path is, from a println inside of Bootstrap.java.

CLNAME[common] Locations:[/opt/tools-ui/apache-tomcat-6.0.20/lib,
/opt/tools-ui/apache-tomcat-6.0.20/lib/,
/home/rob/.IntelliJIdea90/system/tomcat/Unnamed_App39c00e45/lib,
/home/rob/.IntelliJIdea90/system/tomcat/Unnamed_App39c00e45/lib/]

The 3rd and 4th paths don't exist.

Time to file an improvement request with IDEA :)

Thanks for all your help!

Rob



On Thu, Mar 4, 2010 at 1:36 PM, Rob S. <ro...@tintri.com> wrote:

> 1) getting JMX running on Tomcat so I can connect w/jconsole.  I've been
>> following the 6.0 "monitoring" guide although jconsole says it can't connect
>> and netstat doesn't report anyone listening on the port I specified.
>>
>
> This is working and I can see the ServerClassLoader MBean inside of
> jConsole.  Unfortunately it doesn't have the rich set of info that the other
> server MBeans have (e.g. Server/Attributes, very full of good stuff).
>
> Rob
>

Re: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Rob S." <ro...@tintri.com>.
>
> 1) getting JMX running on Tomcat so I can connect w/jconsole.  I've been
> following the 6.0 "monitoring" guide although jconsole says it can't connect
> and netstat doesn't report anyone listening on the port I specified.
>

This is working and I can see the ServerClassLoader MBean inside of
jConsole.  Unfortunately it doesn't have the rich set of info that the other
server MBeans have (e.g. Server/Attributes, very full of good stuff).

Rob

Re: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Rob S." <ro...@tintri.com>.
Hi Chuck,

That means the <Resource> applies to all your webapps; is that what you
> want?
>

Yep, we only have one webapp and it's deployed to our appliance :)


>  > DataSource ds = (DataSource) new
> > InitialContext().lookup("java:comp/env/jdbc/postgres");
> > ds.getConnection();
> >
> > org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver
> > class 'org.postgresql.Driver'
> >     at
> > org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource
> > (BasicDataSource.java:1136)
> >     at
> > org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection
> > (BasicDataSource.java:880)
>
> There should be an additional stack trace related to the error that has
> more specific information in it.
>

I've been looking for that, unfortunately all I see is non-Tomcat code (e.g.
Class.forName, etc.).

I'm working on two things:

1) getting JMX running on Tomcat so I can connect w/jconsole.  I've been
following the 6.0 "monitoring" guide although jconsole says it can't connect
and netstat doesn't report anyone listening on the port I specified.
2) Instrumenting the Tomcat source with debug statements to see what the
state of the bootstrap classloader Konstantin pointed out is.  Although
that's added to JMX so if (1) works then I might not need this step :)


> Any chance this is a permissions problem?
>

Could be!  How do you mean? :)

Rob

RE: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rob S. [mailto:rob@tintri.com]
> Subject: Re: [6.0.20] Using -Dcatalina.config breaks our databases
> resources
> 
> The global one in the conf directory.

That means the <Resource> applies to all your webapps; is that what you want?

> DataSource ds = (DataSource) new
> InitialContext().lookup("java:comp/env/jdbc/postgres");
> ds.getConnection();
> 
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver
> class 'org.postgresql.Driver'
>     at
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource
> (BasicDataSource.java:1136)
>     at
> org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection
> (BasicDataSource.java:880)

There should be an additional stack trace related to the error that has more specific information in it.

Any chance this is a permissions problem?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Rob S." <ro...@tintri.com>.
 Hi Chuck,


> Which context.xml?  The global one in the conf directory, or an
> app-specific one in its META-INF directory?
>

The global one in the conf directory.


> > we modified this line in catalina.config
>
> I presume you mean catalina.properties in the above statment.
>

Yep, typo, sorry :)


>  > common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,*
> > ${catalina.base}/lib,${catalina.base}/lib/*.jar*
>
> Did you add the extra asterisks, or is that an artifact of your copy &
> paste?
>

C&P artifact.  In my sent items folder on Gmail, I'm not seeing them.


>  > Unfortunately when we use -Dcatalina.config to specify
> > catalina.properties.development, the postgres.jar file
> > is no longer found when Tomcat attempts to create a connection.
>
> Evidence to support that assertion?  (I.e., post the stack trace.)
>

When we use catalina.properties (and omit the -Dcatalina.config option),
everything works.  When we attempt to use catalina.properties.development
(file diff shows no differences) by specifying the -Dcatalina.config
property, this is what happens:

DataSource ds = (DataSource) new
InitialContext().lookup("java:comp/env/jdbc/postgres");
ds.getConnection();

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver
class 'org.postgresql.Driver'
    at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
    at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

Thanks guys, really appreciate the help!

Rob

RE: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Rob S. [mailto:rob@tintri.com]
> Subject: [6.0.20] Using -Dcatalina.config breaks our databases
> resources
> 
> We have a custom resource defined in context.xml:

Which context.xml?  The global one in the conf directory, or an app-specific one in its META-INF directory?

> we modified this line in catalina.config

I presume you mean catalina.properties in the above statment.

> common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,*
> ${catalina.base}/lib,${catalina.base}/lib/*.jar*

Did you add the extra asterisks, or is that an artifact of your copy & paste?

> Unfortunately when we use -Dcatalina.config to specify
> catalina.properties.development, the postgres.jar file 
> is no longer found when Tomcat attempts to create a connection.

Evidence to support that assertion?  (I.e., post the stack trace.)

> Is there a way for me to dump the value of common.loader after
> Tomcat starts to be sure it's at least seeing the value from 
> our config file?

Use JConsole to poke around in the JMX objects Tomcat creates.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by "Rob S." <ro...@tintri.com>.
Hi Konstantin,

The quote I'm seeing in your response isn't the line that was in my previous
message, perhaps something is coming across scrambled?

Those extra "*" characters aren't in our catalina.properties.

common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.base}/lib,${catalina.base}/lib/*.jar

Rob

On Thu, Mar 4, 2010 at 11:24 AM, Konstantin Kolinko
<kn...@gmail.com>wrote:

> 2010/3/4 Rob S. <ro...@tintri.com>:
> >
> > common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,*
> > ${catalina.base}/lib,${catalina.base}/lib/*.jar*
> >
>
> The above is wrong.  The only mask that is recognized there is "*.jar"
> and only when used as a suffix. There are too many extra "*"s in your
> value.
>
> You can look at
> org.apache.catalina.startup.Bootstrap.createClassLoader(...) where it
> is implemented.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: [6.0.20] Using -Dcatalina.config breaks our databases resources

Posted by Konstantin Kolinko <kn...@gmail.com>.
2010/3/4 Rob S. <ro...@tintri.com>:
>
> common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,*
> ${catalina.base}/lib,${catalina.base}/lib/*.jar*
>

The above is wrong.  The only mask that is recognized there is "*.jar"
and only when used as a suffix. There are too many extra "*"s in your
value.

You can look at
org.apache.catalina.startup.Bootstrap.createClassLoader(...) where it
is implemented.

Best regards,
Konstantin Kolinko

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