You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Caldarale, Charles R" <Ch...@unisys.com> on 2010/06/06 01:11:54 UTC

RE: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not run on Tomcat 6.0.26 ...

> From: Frank Burns [mailto:francisburns@gmail.com]
> Subject: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not run
> on Tomcat 6.0.26 ...
> 
> the context that I use in the server.xml of each Tomcat 

Let's get the <Context> element straightened out first.  You should not be placing <Context> elements in server.xml; although it works (if you're careful), it is extremely poor practice.  The <Context> element should be in the app's META-INF/context.xml file, without any docBase or path attributes.  If you don't want to keep the <Context> element with the webapp, place the webapp outside of Tomcat's directory structure, and put the <Context> element in conf/Catalina/[hostName]/[appName].xml, with a docBase attribute pointing to the app's location, but without a path attribute.

> Here it is for Tomcat 6.0.26.
> 
> <Context path="/sfpfulladmin"
> docBase="C:\SoftwareDevelopment\apache-tomcat-6.0.26\webapps\sfpfulladmin"

Move the <Context> element and get rid of the path and docBase, as noted above.

> debug="0">

The debug attribute hasn't been used for years.

> <Realm
> className="org.apache.catalina.realm.JDBCRealm"
> driverName="com.mysql.jdbc.Driver"
> connectionURL="jdbc:mysql://127.0.0.1:3306/ppadminsite"
> connectionName="frank"
> connectionPassword="burns"
> userTable="SFP_USER"
> userNameCol="USERNAME"
> userCredCol="PASSWORD"
> userRoleTable="USER_ROLE_ASSOCIATION"
> roleNameCol="PARENT_ROLE_NAME" />

The JDBCRealm is a poor choice due to inherent design issues (e.g., single-thread, no DB connection pooling).  Much better to use a DataSourceRealm:
http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#DataSourceRealm

Where is the MySQL JDBC driver jar located?  It should be in Tomcat's lib directory (and nowhere else) if using a DataSourceRealm; for a JDBCRealm, the jar can be in either Tomcat's lib directory or the app's WEB-INF/lib directory, but not both.

 - 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: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not run on Tomcat 6.0.26 ...

Posted by Frank Burns <fr...@gmail.com>.
Fully understood -- and very clearly explained.

Again, thanks Chuck.

Cheers,

Frank

On Sun, Jun 6, 2010 at 3:25 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Frank Burns [mailto:francisburns@gmail.com]
> > Subject: Re: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not
> > run on Tomcat 6.0.26 ...
> >
> > didn't realise that specifying the context in the server.xml
> > was poor practice and that if you did so then you had to be
> > careful.
> >
> > Can you tell me why that is?
>
> Placing the <Context> element in server.xml requires a Tomcat restart
> anytime the context attributes need to be changed (including those of nested
> elements), since server.xml is only read when Tomcat starts.  Especially
> when running multiple webapps, this can be an administrative nightmare.
>  Keeping the <Context> element with the webapp avoids that issue, and makes
> the URI path of the webapp independent of the <Context> settings.
>
> Having the <Context> in server.xml also runs the risk of double deployment,
> which can occur when the path attribute doesn't exactly match the file
> system location of the webapp.  People often don't even recognize that
> they've got a second copy of the webapp running, consuming resources and
> providing an unexpected path into the server.
>
>  - 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: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not run on Tomcat 6.0.26 ...

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Frank Burns [mailto:francisburns@gmail.com]
> Subject: Re: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not
> run on Tomcat 6.0.26 ...
> 
> didn't realise that specifying the context in the server.xml
> was poor practice and that if you did so then you had to be
> careful.
> 
> Can you tell me why that is?

Placing the <Context> element in server.xml requires a Tomcat restart anytime the context attributes need to be changed (including those of nested elements), since server.xml is only read when Tomcat starts.  Especially when running multiple webapps, this can be an administrative nightmare.  Keeping the <Context> element with the webapp avoids that issue, and makes the URI path of the webapp independent of the <Context> settings.

Having the <Context> in server.xml also runs the risk of double deployment, which can occur when the path attribute doesn't exactly match the file system location of the webapp.  People often don't even recognize that they've got a second copy of the webapp running, consuming resources and providing an unexpected path into the server.

 - 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: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not run on Tomcat 6.0.26 ...

Posted by Frank Burns <fr...@gmail.com>.
HeyChuck,

Thanks very much for your excellent reply and advice.

Moving the MySQL JDBC driver jar app's WEB-INF/lib directoryto Tomcat's lib
directory sorted the problem and it's working now.

I am aware of the various ways in which you can deploy a webapp, but didn't
realise that specifying the context in the server.xml was poor practice and
that if you did so then you had to be careful.

Can you tell me why that is?

Thanks again.

Frank


On Sun, Jun 6, 2010 at 12:11 AM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Frank Burns [mailto:francisburns@gmail.com]
> > Subject: Web app using JDBCRealm runs on Tomcat 5.5.20 but will not run
> > on Tomcat 6.0.26 ...
> >
> > the context that I use in the server.xml of each Tomcat
>
> Let's get the <Context> element straightened out first.  You should not be
> placing <Context> elements in server.xml; although it works (if you're
> careful), it is extremely poor practice.  The <Context> element should be in
> the app's META-INF/context.xml file, without any docBase or path attributes.
>  If you don't want to keep the <Context> element with the webapp, place the
> webapp outside of Tomcat's directory structure, and put the <Context>
> element in conf/Catalina/[hostName]/[appName].xml, with a docBase attribute
> pointing to the app's location, but without a path attribute.
>
> > Here it is for Tomcat 6.0.26.
> >
> > <Context path="/sfpfulladmin"
> >
> docBase="C:\SoftwareDevelopment\apache-tomcat-6.0.26\webapps\sfpfulladmin"
>
> Move the <Context> element and get rid of the path and docBase, as noted
> above.
>
> > debug="0">
>
> The debug attribute hasn't been used for years.
>
> > <Realm
> > className="org.apache.catalina.realm.JDBCRealm"
> > driverName="com.mysql.jdbc.Driver"
> > connectionURL="jdbc:mysql://127.0.0.1:3306/ppadminsite"
> > connectionName="frank"
> > connectionPassword="burns"
> > userTable="SFP_USER"
> > userNameCol="USERNAME"
> > userCredCol="PASSWORD"
> > userRoleTable="USER_ROLE_ASSOCIATION"
> > roleNameCol="PARENT_ROLE_NAME" />
>
> The JDBCRealm is a poor choice due to inherent design issues (e.g.,
> single-thread, no DB connection pooling).  Much better to use a
> DataSourceRealm:
> http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#DataSourceRealm
>
> Where is the MySQL JDBC driver jar located?  It should be in Tomcat's lib
> directory (and nowhere else) if using a DataSourceRealm; for a JDBCRealm,
> the jar can be in either Tomcat's lib directory or the app's WEB-INF/lib
> directory, but not both.
>
>  - 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
>
>