And finally it WORKS!!! It seems that tomcat failed to connect to MySql so authentication failed too. so I have change my connector version from 3.1.12 to 3.0.17, register the DB as global JNDI resource in server.xml and use only a minimal set of parameter (just username, password, driver class and connection url). I've added a reference in <myapp> web.xml, and I've created the <mmyapp> Context in server.xml. Inside that context I've declared my DataSourceRealm pointing at my JNDI datasource and.. IT WORKS! :-DDDD
Thank's for the useful help! ale -----Messaggio originale----- Da: Franck Borel [mailto:[EMAIL PROTECTED] Inviato: giovedì 13 aprile 2006 10.34 A: Tomcat Users List Oggetto: Re: R: R: Form Authentication against JNDI Datasource Realm Try this: Remove 'source' from your Context Element: <Context docBase="PMS" path="/PMS" reloadable="true"> -- Franck > Thanks but that's not the problem.. the carriage return was inserted during > copy&paste, and it's not present in the original server.xml. Anyway I > probably find the REAL problem. > If I remove the "realm" tag from the "Context" I could start tomcat > otherwise I get the: > > GRAVE: Begin event threw exception > > java.lang.NullPointerException > > at > org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader > .java:769) > [..] > > exception.. so it seems to me there's only some possible causes: > > 1) tomcat can't find org.apache.catalina.realm.JDBCRealm > (but it can find, for sure, org.apache.catalina.realm.UserDatabaseRealm) > > 2) tomcat can't find "com.mysql.jdbc.Drive"r or "org.gjt.mm.mysql.Driver" > (but "mysql-connector-java-3.1.12-bin.jar" is already in > $CATALINA_HOME/common/lib) > > 3) some other class missing but which one? > > So it's seems a classpath or class reference problem.. > but I don't know how to solve it.. > > DO I have to set Some special path in global OS CLASSPATH variable? > Do the JVM need some particular configuration to run tomcat?? > > S***t :-///// > > -----Messaggio originale----- > Da: Allistair Crossley [mailto:[EMAIL PROTECTED] > Inviato: mercoledì 12 aprile 2006 17.39 > A: Tomcat Users List > Oggetto: RE: R: Form Authentication against JNDI Datasource Realm > > > I suspect from the error msg that your server.xml is non well-formed > somewhere, has a syntax error or bad class name. Try checking through it, or > comparing it to a fresh server.xml from a Tomcat distro. Frustrating, but > that's all it will be I think. Not sure if the carriage return is allowed or > not in the value here .. > > <parameter> > <name>factory</name> > <value> > > org.apache.catalina.users.MemoryUserDatabaseFactory > </value> > > -----Original Message----- > From: Brambilla Alessandro [mailto:[EMAIL PROTECTED] > Sent: 12 April 2006 16:34 > To: 'Tomcat Users List' > Subject: R: R: Form Authentication against JNDI Datasource Realm > > so now these are my config files: > > server.xml: > <?xml version="1.0" encoding="UTF-8"?> > <!-- Example Server Configuration File --> > <!-- Note that component elements are nested corresponding to their > parent-child relationships with each other --> > <!-- A "Server" is a singleton element that represents the entire JVM, > which may contain one or more "Service" instances. The Server > listens for a shutdown command on the indicated port. > > Note: A "Server" is not itself a "Container", so you may not > define subcomponents such as "Valves" or "Loggers" at this level. > --> > <Server port="8005" shutdown="SHUTDOWN" debug="0"> > > <Listener > > className="org.apache.catalina.mbeans.ServerLifecycleListener" > debug="0" /> > <Listener > > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" > debug="0" /> > > <!-- Global JNDI resources --> > <GlobalNamingResources> > <!-- Editable user database that can also be used by > UserDatabaseRealm to authenticate users --> > <Resource name="UserDatabase" auth="Container" > type="org.apache.catalina.UserDatabase" > description="User database that can be updated and > saved"> > </Resource> > <ResourceParams name="UserDatabase"> > <parameter> > <name>factory</name> > <value> > > org.apache.catalina.users.MemoryUserDatabaseFactory > </value> > </parameter> > <parameter> > <name>pathname</name> > <value>conf/tomcat-users.xml</value> > </parameter> > </ResourceParams> > > > </GlobalNamingResources> > > <!-- A "Service" is a collection of one or more "Connectors" that > share > a single "Container" (and therefore the web applications > visible > within that Container). Normally, that Container is an > "Engine", > but this is not required. > > Note: A "Service" is not itself a "Container", so you may > not > define subcomponents such as "Valves" or "Loggers" at this > level. > --> > > <!-- Define the Tomcat Stand-Alone Service --> > <Service name="Catalina"> > > <!-- A "Connector" represents an endpoint by which requests > are received > and responses are returned. Each Connector passes > requests on to the > associated "Container" (normally an Engine) for > processing. > > > --> > > <!-- Define a non-SSL Coyote HTTP/1.1 Connector on the port > specified > during installation --> > <Connector port="8080" maxThreads="150" minSpareThreads="25" > maxSpareThreads="75" enableLookups="false" > redirectPort="8443" > acceptCount="100" debug="0" > connectionTimeout="20000" > disableUploadTimeout="true" compression="on" > compressionMinSize="2048" > compressableMimeType="text/html,text/xml" /> > > <!-- Note : To use gzip compression you could set the > following properties : > > compression="on" > compressionMinSize="2048" > noCompressionUserAgents="gozilla, traviata" > compressableMimeType="text/html,text/xml" > --> > <!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> > > <Connector port="8443" maxThreads="150" minSpareThreads="25" > maxSpareThreads="75" enableLookups="false" > disableUploadTimeout="true" acceptCount="100" > debug="0" > scheme="https" secure="true" clientAuth="false" > sslProtocol="TLS" > compression="on" /> > > > <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 --> > <Connector port="8009" enableLookups="false" > redirectPort="8443" > debug="0" protocol="AJP/1.3" /> > > <!-- An Engine represents the entry point (within Catalina) > that processes > every request. The Engine implementation for Tomcat > stand alone > analyzes the HTTP headers included with the request, > and passes them > on to the appropriate Host (virtual host). --> > > <!-- You should set jvmRoute to support load-balancing via > JK/JK2 ie : > <Engine name="Standalone" defaultHost="localhost" > debug="0" jvmRoute="jvm1"> > --> > > <!-- Define the top level container in our container > hierarchy --> > <Engine name="Catalina" defaultHost="localhost" debug="0"> > > > <!-- Request dumping is disabled by default. > Uncomment the following > element to enable it. --> > <!-- > <Valve > className="org.apache.catalina.valves.RequestDumperValve"/> > --> > > <!-- Global logger unless overridden at lower levels > --> > <Logger > className="org.apache.catalina.logger.FileLogger" > prefix="catalina_log." suffix=".txt" > timestamp="true" /> > > <!-- Because this Realm is here, an instance will be > shared globally --> > > <!-- This Realm uses the UserDatabase configured in > the global JNDI > resources under the key "UserDatabase". Any > edits > that are performed against this UserDatabase > are immediately > available for use by the Realm. --> > <Realm > > className="org.apache.catalina.realm.UserDatabaseRealm" debug="0" > resourceName="UserDatabase" /> > > > <!-- Define the default virtual host > Note: XML Schema validation will not work > with Xerces 2.2. > --> > <Host name="localhost" debug="0" appBase="webapps" > unpackWARs="true" autoDeploy="true" > xmlValidation="false" > xmlNamespaceAware="false"> > > > <!-- Normally, users must authenticate > themselves to each web app > individually. Uncomment the > following entry if you would like > a user to be authenticated the first > time they encounter a > resource protected by a security > constraint, and then have that > user identity maintained across > *all* web applications contained > in this virtual host. --> > <!-- > <Valve > className="org.apache.catalina.authenticator.SingleSignOn" > debug="0"/> > --> > > <!-- Access log processes all requests for > this virtual host. By > default, log files are created in > the "logs" directory relative to > $CATALINA_HOME. If you wish, you > can specify a different > directory with the "directory" > attribute. Specify either a relative > (to $CATALINA_HOME) or absolute path > to the desired directory. > --> > > <Valve > > className="org.apache.catalina.valves.AccessLogValve" > directory="logs" > prefix="localhost_access_log." suffix=".txt" > pattern="common" > resolveHosts="false" /> > > > <!-- Logger shared by all Contexts related > to this virtual host. By > default (when using FileLogger), log > files are created in the "logs" > directory relative to > $CATALINA_HOME. If you wish, you can specify > a different directory with the > "directory" attribute. Specify either a > relative (to $CATALINA_HOME) or > absolute path to the desired > directory.--> > <Logger > > className="org.apache.catalina.logger.FileLogger" directory="logs" > prefix="localhost_log." > suffix=".txt" timestamp="true" /> > > > <Context docBase="PMS" path="/PMS" > reloadable="true" > > source="org.eclipse.jst.j2ee.server:PMS"> > <Realm > > classname="org.apache.catalina.realm.JDBCRealm" debug="99" > > driverName="org.gjt.mm.mysql.Driver" > > connectionURL="jdbc:mysql://localhost:3306/pms?user=usr&password=pass" > userTable="users" > userRoleTable="roles" userNameCol="username" > userCredCol="password" > roleNameCol="role"/> > </Context> > </Host> > > > </Engine> > > </Service> > > </Server> > > 2. Web.xml: > > <?xml version="1.0" encoding="UTF-8"?> > <web-app id="WebApp_ID" version="2.4" > xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> > > <display-name>PMS</display-name> > <welcome-file-list> > <welcome-file>home.jsp</welcome-file> > <welcome-file>index.jsp</welcome-file> > <welcome-file>default.jsp</welcome-file> > </welcome-file-list> > > <!-- Sezione di gestione dell'accesso. l'autorizzazione è verificata > > utilizzando un'autenticazione basata su form --> > > <security-constraint> > <web-resource-collection> > <web-resource-name>Entire > Application</web-resource-name> > <description> > L'accesso è consentito solo agli utenti > autorizzati > </description> > <url-pattern>/*</url-pattern><!-- Tutti i file > dell'applicazione --> > </web-resource-collection> > <auth-constraint> > <description> > Questi sono i ruoli che hanno accesso al > sito > </description> > <role-name>root</role-name> > </auth-constraint> > > <!-- seleziona la forma di sicureza a livello di trasporto > dati: > NONE = nessuna CONFIDENTIAL o INTEGRAL = SSL Tunnel > --> > <user-data-constraint> > <!-- dovrà essere almeno CONFIDENTIAL se non > INTEGRAL.. --> > <transport-guarantee>NONE</transport-guarantee> > </user-data-constraint> > </security-constraint> > > <!-- login via Form Authentication --> > <login-config> > <auth-method>FORM</auth-method> > <form-login-config> > <form-login-page>/login.jsp</form-login-page> > <form-error-page> > /ErrorPages/loginError.jsp > </form-error-page> > </form-login-config> > </login-config> > > <!-- Ruoli ammessi ad accedere al sito --> > <security-role> > <description>Amministratore del sito</description> > <role-name>root</role-name> > </security-role> > > </web-app> > > > they looks very closer to yours "working file" right? > so.. why I cannot even start tomcat now?? > > I get that output: > > 12-apr-2006 17.28.03 org.apache.commons.digester.Digester startElement > GRAVE: Begin event threw exception > java.lang.NullPointerException > at > org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader > .java:769) > at > org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader > .java:721) > at > org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:252 > ) > at org.apache.commons.digester.Rule.begin(Rule.java:200) > at > org.apache.commons.digester.Digester.startElement(Digester.java:1273) > at > org.apache.catalina.util.CatalinaDigester.startElement(CatalinaDigester.java > :65) > at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown > Source) > at > org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unkno > wn Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc > her.dispatch(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.commons.digester.Digester.parse(Digester.java:1548) > at org.apache.catalina.startup.Catalina.load(Catalina.java:489) > at org.apache.catalina.startup.Catalina.load(Catalina.java:528) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:250) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424) > Catalina.start using conf/server.xml: java.lang.NullPointerException > java.lang.NullPointerException > at > org.apache.commons.digester.Digester.createSAXException(Digester.java:2540) > at > org.apache.commons.digester.Digester.createSAXException(Digester.java:2566) > at > org.apache.commons.digester.Digester.startElement(Digester.java:1276) > at > org.apache.catalina.util.CatalinaDigester.startElement(CatalinaDigester.java > :65) > at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown > Source) > at > org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unkno > wn Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc > her.dispatch(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.commons.digester.Digester.parse(Digester.java:1548) > at org.apache.catalina.startup.Catalina.load(Catalina.java:489) > at org.apache.catalina.startup.Catalina.load(Catalina.java:528) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:250) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424) > 12-apr-2006 17.28.03 org.apache.commons.digester.Digester startElement > GRAVE: Begin event threw exception > java.lang.NullPointerException > at > org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader > .java:769) > at > org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader > .java:721) > at > org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:252 > ) > at org.apache.commons.digester.Rule.begin(Rule.java:200) > at > org.apache.commons.digester.Digester.startElement(Digester.java:1273) > at > org.apache.catalina.util.CatalinaDigester.startElement(CatalinaDigester.java > :65) > at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown > Source) > at > org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unkno > wn Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc > her.dispatch(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.commons.digester.Digester.parse(Digester.java:1548) > at org.apache.catalina.startup.Catalina.load(Catalina.java:489) > at org.apache.catalina.startup.Catalina.start(Catalina.java:548) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425) > Catalina.start using conf/server.xml: java.lang.NullPointerException > java.lang.NullPointerException > at > org.apache.commons.digester.Digester.createSAXException(Digester.java:2540) > at > org.apache.commons.digester.Digester.createSAXException(Digester.java:2566) > at > org.apache.commons.digester.Digester.startElement(Digester.java:1276) > at > org.apache.catalina.util.CatalinaDigester.startElement(CatalinaDigester.java > :65) > at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown > Source) > at > org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown > Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unkno > wn Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatc > her.dispatch(Unknown Source) > at > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > Source) > at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) > at org.apache.commons.digester.Digester.parse(Digester.java:1548) > at org.apache.catalina.startup.Catalina.load(Catalina.java:489) > at org.apache.catalina.startup.Catalina.start(Catalina.java:548) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425) > 12-apr-2006 17.28.03 org.apache.catalina.startup.Catalina start > INFO: Server startup in 0 ms > java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287) > at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:425) > Caused by: java.lang.NullPointerException > at org.apache.catalina.startup.Catalina.await(Catalina.java:619) > at org.apache.catalina.startup.Catalina.start(Catalina.java:579) > ... 6 more > > I'm thinking about Connector/J jar file.. but it's in the right location.. > (Catilina_home/common/lib/).. > > I'm getting crazy and I have no IDEA!!! better to shut down and go home... > > Bye > Ale > > > > > > > -----Messaggio originale----- > Da: Franck Borel [mailto:[EMAIL PROTECTED] > Inviato: mercoledì 12 aprile 2006 16.54 > A: Tomcat Users List > Oggetto: Re: R: Form Authentication against JNDI Datasource Realm > > > > > The server.xml is looking for Windows like server.xml for all other OS. > Tomcat is written in pure Java, so mostly is looking the same in any > operating system. > I give you a working example with a postgres implementation and you can > try to make it run on your machine: > [....] > > ==================================================================== > Dipl.-Hyd. Franck Borel Universitaetsbibliothek Freiburg > EMail: [EMAIL PROTECTED] EDV-Dezernat > Tel. : +49-761 / 203-3908 Werthmannplatz 2 | Postfach 1629 > Fax : +49-761 / 203-3987 79098 Freiburg | 79016 Freiburg > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> > ------------------------------------------------------- > QAS Ltd. > Registered in England: No 2582055 > Registered in Australia: No 082 851 474 > ------------------------------------------------------- > </FONT> <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLACK> > Disclaimer: The information contained within this e-mail is confidential > and may be privileged. This email is intended solely for the named recipient > only; if you are not authorised you must not disclose, copy, distribute, or > retain this message or any part of it. If you have received this message in > error please contact the sender at once so that we may take the appropriate > action and avoid troubling you further. Any views expressed in this message > are those of the individual sender. QAS Limited has the right lawfully to > record, monitor and inspect messages between its employees and any third > party. Your messages shall be subject to such lawful supervision as QAS > Limited deems to be necessary in order to protect its information, its > interests and its reputation. > > Whilst all efforts are made to safeguard Inbound and Outbound emails, QAS > Limited cannot guarantee that attachments are virus free or compatible with > your systems and does not accept any liability in respect of viruses or > computer problems experienced. > </FONT> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- ==================================================================== Dipl.-Hyd. Franck Borel Universitaetsbibliothek Freiburg EMail: [EMAIL PROTECTED] EDV-Dezernat Tel. : +49-761 / 203-3908 Werthmannplatz 2 | Postfach 1629 Fax : +49-761 / 203-3987 79098 Freiburg | 79016 Freiburg --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]