Configuration error: Must be attached to a Context

Oct 12, 2010 at 4:57 PM

When I add the valve parameter to the server.xml in tomcat 6.0.17 win 2008 64 bit

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
   
  <Realm className="waffle.apache.WindowsRealm" />
  <Valve className="waffle.apache.NegotiateAuthenticator"/>

 

I get the below error when I remove the valve the error goes away.

SEVERE: End event threw exception
java.lang.reflect.InvocationTargetException
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:922)
 at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:193)
 at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
 at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1140)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
 at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:516)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:550)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
Caused by: java.lang.IllegalArgumentException: Configuration error:  Must be attached to a Context
 at org.apache.catalina.authenticator.AuthenticatorBase.setContainer(AuthenticatorBase.java:265)
 at org.apache.catalina.core.StandardPipeline.addValve(StandardPipeline.java:436)
 at org.apache.catalina.core.ContainerBase.addValve(ContainerBase.java:1217)
 ... 26 more
Oct 12, 2010 3:33:01 PM org.apache.catalina.startup.Catalina load
WARNING: Catalina.start using conf/server.xml:
java.lang.IllegalArgumentException: Configuration error:  Must be attached to a Context
 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.endElement(Digester.java:1143)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
 at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
 at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1644)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:516)
 at org.apache.catalina.startup.Catalina.load(Catalina.java:550)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:260)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
Oct 12, 2010 3:33:01 PM org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw exception

Coordinator
Oct 13, 2010 at 1:20 PM

It's cause you need a Context container.

<Context path="/examples" ...>
  ...
  <Valve className="org.apache.catalina.valves.AccessLogValve"
         prefix="localhost_access_log." suffix=".txt"
         pattern="common"/>
  ...
</Context>

I don't recommend using valves for new implementations, it's only useful if you already have a mess of a configuration. Valves are deprecated in Tomcat 7. Consider a generic servlet filter.

Oct 14, 2010 at 5:26 PM
Edited Oct 15, 2010 at 3:33 AM

Thanks for the timely response. However, I have tested waffle-negotiate without the context.xml and it still works. How is it  invoking waffle.apache.NegotiateAuthenticator without any reference to it.

Is it part of this process "Deploying configuration descriptor waffle-negotiate.xml" ? How can I get my app to invoke this class waffle.apache.NegotiateAuthenticator without a context?

Also, does waffle have any issues working over ssl?

Thanks!

Coordinator
Oct 14, 2010 at 9:34 PM

I am not sure I understand. Are you saying you took the waffle-negotiate demo and just deleted the context.xml and it still works? That can't be, so it's probably cause the configuration is cached - I bet that if you delete Tomcat's work and conf/Catalina/localhost directories it will stop working.

Tell me about your application, how you do authentication today, and what you're trying to solve. Maybe that's a better place to start.

Waffle has no known issues with SSL.

Oct 15, 2010 at 5:35 AM

The application is Struts based J2EE with NTLM authentication with IIS doing pass through to tomcat for SSO (isapi_redirect.dll). It doesn't have a context.xml file but reads from external cfg file. We have to add ssl to all open ports and this stopped sso from working. I'm trying to resolve the issue of sso and ssl. I tried adding the context to the server.xml but that didn't work.

Thanks!

Coordinator
Oct 15, 2010 at 1:18 PM

I think you're on the right track. Get rid of IIS, but use the Waffle filter, not the valve as those are deprecated. Whatever code you have that deals with authentication can be deleted, the session will be authenticated upfront by Waffle and you can retrieve the current user information the normal Servlet/Tomcat way.