tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mitch Claborn <mi...@claborn.net>
Subject Re: Can a Realm communicate with a web application?
Date Thu, 23 Jul 2009 13:46:15 GMT

Pid wrote:
> On 22/7/09 19:32, Mitch Claborn wrote:
>> Pid wrote:
>>> On 21/7/09 23:23, Mitch Claborn wrote:
>>>> I am toying with the idea of writing my own Realm for authentication.
>>>> Much of the code and structures that I need are already present in the
>>>> web application.  Is there any way for the Realm to access Java
>>>> objects
>>>> from the web application?  They don't appear to share the same class
>>>> loader.
>>>>
>>>> As an alternative is there a mechanism for providing the functionality
>>>> of a Realm, but within the web application structure?
>>> You can define the Realm in your context.xml, (which of course you'll
>>> be configuring in the META-INF dir of your web-app, hint hint).
>>>
>>> I think this will load classes from your web-app classloader.
>>>
>>>
>>> N.B. Check out the "localDataSource" attribute, if you're also using a
>>> web-app specific DataSource.
>>>
>>> http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#DataSourceRealm
>>>
>>>
>>> p
>>>
>> I found that I can define the Realm in the conext.xml in my WEB-INF, but
>> it is not being located - getting java.lang.ClassNotFoundException when
>> the web app deploys/starts.  I've triple checked that the class files
>> are there in WEB-INF/classes.  I also tried putting in a jar in
>> WEB-INF/ilb.  I'm guessing that the Realm is still being loaded in a
>> different class loader.  I would guess the Realm is loaded in the
>> "common" class loader, as defined at
>> http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html.
>
> What is the exact CNFE and is there a stacktrace to go with it?
>
> You've only got the class in one place at any one time I presume?
>
> It's also spelled correctly in the context.xml definition? (you could
> post that file here, sanitised for passwords if present).
>
> p
>
everything looks correctly spelled to me.  That class only in one place.

find . -name MyRealm.class
./MMWebServer/WEB-INF/classes/com/csc/mm/web/tomcat/MyRealm.class

ls webapps/MMWebServer/WEB-INF/classes/com/csc/mm/web/tomcat/
MyRealm.class  MyRealm$MyPrincipal.class

jarfind MyRealm.class
(no results)


context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="">
    <Manager pathname="" />
    <Realm className="com.csc.mm.web.tomcat.MyRealm" />
</Context>

Jul 23, 2009 8:40:10 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive MMWebServer.war
Jul 23, 2009 8:40:10 AM org.apache.tomcat.util.digester.Digester
startElement
SEVERE: Begin event threw exception
java.lang.ClassNotFoundException: com.csc.mm.web.tomcat.MyRealm
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
        at
org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:205)
        at org.apache.tomcat.util.digester.Rule.begin(Rule.java:153)
        at
org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1358)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:504)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1315)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2723)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:624)
        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:486)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:810)
        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:740)
        at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:110)
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
        at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:525)
        at
org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
        at
org.apache.catalina.startup.ContextConfig.processContextConfig(ContextConfig.java:789)
        at
org.apache.catalina.startup.ContextConfig.contextConfig(ContextConfig.java:732)
        at
org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:1009)
        at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at
org.apache.catalina.core.StandardContext.init(StandardContext.java:5398)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4177)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
        at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:850)
        at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:724)
        at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:493)
        at
org.apache.catalina.startup.HostConfig.check(HostConfig.java:1274)
        at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:296)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at
org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
        at
org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
        at java.lang.Thread.run(Thread.java:636)



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message