Hello, I have the following scenario - runtime I want to remove one Valve from a specified StandardContext. I'm using the following method: org.apache.catalina.core.StandardContext.removeValve(Valve valve) which invokes org.apache.catalina.core.StandardPipeline.removeValve(Valve valve) The problem is that the following exception is thrown: Caused by: java.lang.IllegalArgumentException: Configuration error: Must be attached to a Context at org.apache.catalina.authenticator.AuthenticatorBase.setContainer(AuthenticatorBase.java:277) at org.apache.catalina.core.StandardPipeline.removeValve(StandardPipeline.java:537) It appears that setContainer is invoked with "null" which leads to this IlleagalArgumentException. I want to propose the following change: Index: AuthenticatorBase.java =================================================================== --- AuthenticatorBase.java (revision 1100912) +++ AuthenticatorBase.java (working copy) @@ -273,7 +273,7 @@ */ public void setContainer(Container container) { - if (!(container instanceof Context)) + if (container != null && !(container instanceof Context)) throw new IllegalArgumentException (sm.getString("authenticator.notContext")); Please tell me if there is more appropriate way to remove a Valve if the one above that I'm describing is not the correct one. Thanks in advance. Regards Violeta Georgieva
You are doing exactly the right thing. That is a bug in 6.0.x (that is fixed in 7.0.x by the way). I have proposed your patch for 6.0.x
Thanks for the patch. It has been applied to 6.0.x and will be included in 6.0.33 onwards.
(In reply to comment #2) > Thanks for the patch. It has been applied to 6.0.x and will be included in > 6.0.33 onwards. Great!Thanks!
(In reply to comment #2) > Thanks for the patch. It has been applied to 6.0.x and will be included in > 6.0.33 onwards. I just checked the commit and the description of the problem is IAE not NPE :( Index: changelog.xml =================================================================== --- changelog.xml (revision 1135555) +++ changelog.xml (working copy) @@ -115,7 +115,7 @@ than as a String. (markt) </fix> <fix> - <bug>51315</bug>: Fix NPE when removing an authenticator valve from a + <bug>51315</bug>: Fix IAE when removing an authenticator valve from a container. Patch provided by Violeta Georgieva. (markt) </fix> <fix>
Corrected
(In reply to comment #5) > Corrected Thanks