tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Posner <cuco2...@gmail.com>
Subject Re: Realm configuration issues
Date Sun, 06 Sep 2009 23:07:07 GMT
I tried commented out everything between the context tags in
server.xml and put it in context.xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<Context>

    <!--
     <Resource name="jdbc/trailsDB" auth="Container"
         type="javax.sql.DataSource"
         username="buzz" password="999999"
         driverClassName="com.mysql.jdbc.Driver"
         url="jdbc:mysql://localhost:3306/trailsDB"
         maxActive="8"
     />
     -->
<Realm classname="org.apache.catalina.realm.DataSourceRealm"
    dataSourceName="jdbc/trailsDB"
    roleNameCol="role_name"
    userCredCol="user_pass"
    userNameCol="user_name"
    userRoleTable="user_roles"
    userTable="user"
    localDataSource="true"
/>

</Context>

It broke it; I got a parse error(NullPointerException) in context.xml line
21. So I could not even access my welcome page.
I tried it with the resource element commented out and uncommented; same
error both times.
      This brings me to the question about the resource element.
Where should that be put ? It is unclear from the documentation where to put
that. (Sorry for asking all these questions. I do read the docs. )

Do I still need that <Resource element above to be defined somewhere, given
that  I have the following in my web.xml:


<resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/trailsDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

Thanks,

Adam


On Sat, Sep 5, 2009 at 6:44 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Adam Posner [mailto:cuco2772@gmail.com]
> > Subject: Re: Realm configuration issues
> >
> > One of the conflicting info is whether to put the DataSource Realm
> > declaration inside a context element in META-INF/context.xml versus
> > putting it in a context element inside a host element in server.xml.
>
> Anything recommending putting a <Context> element in server.xml is sadly
> out of date; that was necessary for older, now unsupported Tomcat levels.
>  The current method is to place a webapp's <Context> element in the webapp's
> META-inf/context.xml file, or in conf/Catalina/[host]/[appName].xml if the
> webapp is stored outside of the <Host> appBase or if you want to override
> the one in META-INF/context.xml.  (For compatibility reasons, current Tomcat
> versions do support <Context> elements in conf/server.xml, but it's strongly
> discouraged.)
>
> > I get the impression that the META-INF directory is more for if
> > you're packaging your webapp as a WAR.
>
> Not true; the same structure is used whether the webapp is deployed in
> expanded form or as a war file.
>
> > The other thing that's causing me some confusion is if you're
> > putting your Realm declaration in server.xml should you comment
> > out the default UserDatabase Realm that's above it ?
>
> Depends on the desired scope of the <Realm>; it may be inside an <Engine>,
> <Host>, or <Context>.  The one in Tomcat's default configuration is
> immediately under the <Engine>, so it applies to all <Host>s and webapps,
> unless overridden by one nested more deeply.  Again, this is all in the
> docs:
>
> http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#Configuring%20a%20Realm
>
> > right now I'm just trying to get it working - I can changs that later
>
> Famous last words (based on 40 years of experience is this industry :-);
> get in the habit of doing it the right way from the start.
>
>  - 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
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message