tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Posner <>
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"?>

     <Resource name="jdbc/trailsDB" auth="Container"
         username="buzz" password="999999"
<Realm classname="org.apache.catalina.realm.DataSourceRealm"


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:

    <description>DB Connection</description>



On Sat, Sep 5, 2009 at 6:44 PM, Caldarale, Charles R <> wrote:

> > From: Adam Posner []
> > 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:
> > 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
> 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:
> For additional commands, e-mail:

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