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 Mon, 07 Sep 2009 22:48:39 GMT
Yes, that was an exact copy and paste. Here it is again - of my
META-INF/context.xml, before I deleted it and put it back in server.xml :

<?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 throws a NullPointerException due to a parse error in context.xml:

Sep 7, 2009 3:29:47 PM org.apache.catalina.startup.ContextConfig
processContextConfig
SEVERE: Parse error in context.xml for /blurbV1
java.lang.NullPointerException
    at
org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2808)
    at
org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2834)
    at
org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1361)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFra...........

I'm using the editor Kate; I dont see any extra tabs or spaces in
the wrong places, Kate has syntax highlighting so I would see that anyway.

But it does work (up to the authentication part) when I put everything from
my META-INF/context.xml into a context element in server.xml:

  <Context path="/blurbV1"     docBase="blurbV1" reloadable="true">

    <!--
    9/6 ?user=buzz&amp;password=999999" maxActive="8":
        Removing this from the line below gave me an
        'access denied for user @ localhost (HTTP 500),
        using password .. no'; it only works for user buzz,
        not user cuco; (get the same error, but ('..using password .. yes'
    -->

      <Resource name="jdbc/trailsDB" auth="Container"
type="javax.sql.DataSource"
        driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/trailsDB?user=buzz&amp;password=999999"
maxActive="8"/>

   <Realm className="org.apache.catalina.realm.DataSourceRealm"
        dataSourceName="jdbc/trailsDB"
        localDataSource="true"
        debug="99"
        userTable="users"
        userNameCol="user_name"
        userCredCol="user_pass"
        userRoleTable="user_roles"
        roleNameCol="role_name"
        />
      </Context>

Note that I need to enter everything after the '?' above, I can't just put
up to the 'trailsDB' part of the url attribute.
Anyway, here's a copy and paste of catalina.out  with the configuration of
the Realm in server.xml, which is the closest I can get to having it work:

cuco@coati:~/apache-tomcat-6.0.16$ cat logs/catalina.out
Sep 7, 2009 3:42:38 PM org.apache.tomcat.util.digester.SetPropertiesRule
begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context/Realm}
Setting property 'debug' to '99' did not find a matching property.
Sep 7, 2009 3:42:38 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal
performance in production environments was not found on the
java.library.path:
/usr/lib/jdk/jre/lib/i386/client:/usr/lib/jdk/jre/lib/i386:/usr/lib/jdk/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
Sep 7, 2009 3:42:38 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Sep 7, 2009 3:42:38 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 393 ms
Sep 7, 2009 3:42:38 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Sep 7, 2009 3:42:38 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
Sep 7, 2009 3:42:39 PM org.apache.catalina.core.StandardContext
addApplicationListener
INFO: The listener "listeners.ContextListener" is already configured for
this context. The duplicate definition has been ignored.
Sep 7, 2009 3:42:39 PM org.apache.catalina.core.StandardContext
addApplicationListener
INFO: The listener "listeners.SessionListener" is already configured for
this context. The duplicate definition has been ignored.
Sep 7, 2009 3:42:39 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Sep 7, 2009 3:42:39 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Sep 7, 2009 3:42:39 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/23  config=null


I'm ready to pull my hair out with this, I haven't been able to find
a good Tomcat book, unfortunately.
Thanks for all your help,

Adam




On Mon, Sep 7, 2009 at 12:33 PM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: Adam Posner [mailto:cuco2772@gmail.com]
> > Subject: Re: Realm configuration issues
> >
> > I tried commented out everything between the context tags in
> > server.xml and put it in context.xml like this:
>
> What context.xml?  Be specific as to the location.
>
> > It broke it; I got a parse error(NullPointerException) in context.xml
> > line 21.
>
> I don't see anything in particular wrong with what you posted; is that an
> exact copy & paste, or is it subject to transcription errors?
>
> > This brings me to the question about the resource element.
> > Where should that be put ?
>
> As the documentation for DataSourceRealm states, you may place the
> <Resource> inside the <Context> element, as long as you set the
> localDataSource attribute for the <Realm> to "true".
>
> > Do I still need that <Resource element above to be defined somewhere,
>
> Yes - the <Realm> needs to use it.
>
> > <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>
>
> The <resource-ref> shouldn't be used, since it's the <Realm> that needs the
> JDBC connection, not your webapp.
>
>  - 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