Exception loading custom Realm

2005-10-10 Thread Surya Mishra
Hi,

I created my own realm by extending UserDatabaseRealm. But when I start the
tomcat server, I get the following exception. If I use UserDatabaseRealm,
everything works fine. That means Tomcat can and does load the
UserDatabaseRealm class without any problem.

java.lang.NoClassDefFoundError: org/apache/catalina/realm/UserDatabaseRealm
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at org.apache.catalina.loader.StandardClassLoader.findClass(
StandardClassLoader.java:485)
at org.apache.catalina.loader.StandardClassLoader.loadClass(
StandardClassLoader.java:820)
at org.apache.catalina.loader.StandardClassLoader.loadClass(
StandardClassLoader.java:721)
at org.apache.catalina.loader.StandardClassLoader.loadClass(
StandardClassLoader.java:803)
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
(UnknownSource)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.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)

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.load(Bootstrap.java:250)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424)
Caused by: java.lang.NoClassDefFoundError:
org/apache/catalina/realm/UserDatabaseRealm
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at org.apache.catalina.loader.StandardClassLoader.findClass(
StandardClassLoader.java:485)
at org.apache.catalina.loader.StandardClassLoader.loadClass(
StandardClassLoader.java:820)
at org.apache.catalina.loader.StandardClassLoader.loadClass(
StandardClassLoader.java:721)
at org.apache.catalina.loader.StandardClassLoader.loadClass(
StandardClassLoader.java:803)
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
(UnknownSource)
at

Re: Exception loading custom Realm

2005-10-10 Thread Surya Mishra
common/lib

But it doesn't have problem loading my custom realm. The problem is actually
in loading the UserDatabaseRealm:
java.lang.NoClassDefFoundError: org/apache/catalina/realm/UserDatabaseRealm

Thanks
-Surya

On 10/10/05, Larry Meadors [EMAIL PROTECTED] wrote:

 Where did you put the classes? They have to go in either common/lib,
 or server/lib.

 Larry

 On 10/10/05, Surya Mishra [EMAIL PROTECTED] wrote:
  Hi,
 
  I created my own realm by extending UserDatabaseRealm. But when I start
 the
  tomcat server, I get the following exception. If I use
 UserDatabaseRealm,
  everything works fine. That means Tomcat can and does load the
  UserDatabaseRealm class without any problem.
 
  java.lang.NoClassDefFoundError:
 org/apache/catalina/realm/UserDatabaseRealm
  at java.lang.ClassLoader.defineClass0(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java
 :123)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  at org.apache.catalina.loader.StandardClassLoader.findClass(
  StandardClassLoader.java:485)
  at org.apache.catalina.loader.StandardClassLoader.loadClass(
  StandardClassLoader.java:820)
  at org.apache.catalina.loader.StandardClassLoader.loadClass(
  StandardClassLoader.java:721)
  at org.apache.catalina.loader.StandardClassLoader.loadClass(
  StandardClassLoader.java:803)
  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
  (UnknownSource)
  at
 
 org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.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)
 
  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.load(Bootstrap.java:250)
  at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424)
  Caused by: java.lang.NoClassDefFoundError:
  org/apache/catalina/realm/UserDatabaseRealm
  at java.lang.ClassLoader.defineClass0(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java
 :123)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  at org.apache.catalina.loader.StandardClassLoader.findClass(
  StandardClassLoader.java:485)
  at org.apache.catalina.loader.StandardClassLoader.loadClass(
  StandardClassLoader.java:820)
  at org.apache.catalina.loader.StandardClassLoader.loadClass(
  StandardClassLoader.java:721)
  at org.apache.catalina.loader.StandardClassLoader.loadClass(
  StandardClassLoader.java:803)
  at org.apache.catalina.loader.StandardClassLoader.loadClass

ClassCastException while sharing objects accross applications

2005-10-03 Thread Surya Mishra
Hi,

I am trying to share an object between 2 applications deployed on the same
tomcat server. I have put the object in the ServletContext in my first
application. I access the object using
ServletContext.getContext(firstApp).getAttribute(object);.
The object comes in fine but it won't let me cast it to the actual Object
Type. I get a ClassCastException. I tried printing the name of the class.
That also came fine (same class name).

Thanks in advance.
-Surya


Multiple realms in Tomcat

2005-09-26 Thread Surya Mishra
My Tomcat server doesn't start if the JNDI realm fails to load (due to
unavailability of the directory server). I want the server to start properly
and serve the unprotected applications at least. Is there a way to specify
multiple realms so that different applications can use different realms for
authentication?
 Thanks
-Surya


Re: Protecting applications in Tomcat using Directory Server

2005-09-25 Thread Surya Mishra
Thank You Mark,
My Tomcat server won't even start if the directory server is unreachable.
That means other applications that have not protected are also failing.
Second question: There is no attribute in the Realm definition to give a
name to realm (as per the how-to document. How do I configure different
realms for different applications? What is the default realm name for the
tomcat-users.xml? I want the manager application to run using the default
tomcat-users.xml. Another application is to be protected using JNDI realm. A
third one is public meaning nothing is protected in that application.
 Thanks
-Surya

 On 9/25/05, Mark Thomas [EMAIL PROTECTED] wrote:

 Surya Mishra wrote:
  I have successfully used JNDI realm to protect my applications on
 Tomcat.
  But if Tomcat is unable to connect to the the directory server, it
 refuses
  access. I want it to use the tomcat-users list as a backup if it fails
 to
  connect to the directory. It seems if the JNDI realm is set up, the
  tomcat-users.cml file entries become useless.
  Need Help!!!
  Thanks
  -Surya
 
 You are correct. This type of fall-back from one realm to another is
 not supported. However, JNDI does have an alternateURL attribute which
 is used if connecting to connectionURL fails. It isn't as well
 documented as it should be - something that I'll fix later today - but
 if you search
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/realm-howto.html for
 alternateURL you should find the info you need.

 More generally, I suspect that making your directory more reliable (or
 replicating to a second directory and using the alternateURL) is going
 to be less effort and less error prone that trying to keep to
 completely different lists of users, passwords and role assignments in
 sync.

 Mark



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Protecting applications in Tomcat using Directory Server

2005-09-24 Thread Surya Mishra
 I have successfully used JNDI realm to protect my applications on Tomcat.
But if Tomcat is unable to connect to the the directory server, it refuses
access. I want it to use the tomcat-users list as a backup if it fails to
connect to the directory. It seems if the JNDI realm is set up, the
tomcat-users.cml file entries become useless.
Need Help!!!
Thanks
-Surya