7 Replies Latest reply on May 10, 2004 1:58 PM by Chris Bonham

    JBossSecurityMgrRealm as a Valve doesn't work after upgradin

    Chris Bonham Newbie

      I'm upgrading an application from JBoss 3.2.2 to 3.2.4RC1 where Tomcat changed from 4.1.27 to 5.0.19. I used the JBossSecurityMgrRealm as a valve in JBoss 3.2.2 to obtain the subject from a request attribute j_subject. After upgrading to JBoss 3.2.4RC1, I now get an NPE. Here's the server.xml config portion:

      <Host name="localhost" autoDeploy="false">
      
       <!-- Access logger -->
       <!--
       <Valve className="org.apache.catalina.valves.AccessLogValve"
       prefix="localhost_access_log." suffix=".log"
       pattern="common" directory="${jboss.server.home.dir}/log"
       resolveHosts="false" />
       -->
      
       <Valve className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
       subjectAttributeName="j_subject"
       certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
       />
      
       <!-- Uncomment to enable single sign-on across web apps
       deployed to this host.
       <Valve className="org.apache.catalina.authenticator.SingleSignOn"
       debug="0"/>
       -->
      
       <!-- Check for unclosed connections -->
       <Valve className="org.jboss.web.tomcat.tc5.jca.CachedConnectionValve"
       cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" />
      
       <!-- Default context parameters -->
       <DefaultContext cookies="true" crossContext="true" override="true" />
      
       </Host>


      And the stack trace:

      2004-04-27 13:59:57,218 ERROR [org.apache.catalina.realm.RealmBase] (main:jboss.web:service=WebServer Tomcat5) Can't register null
      java.lang.NullPointerException
       at org.apache.catalina.realm.RealmBase.init(RealmBase.java:1241)
       at org.apache.catalina.realm.RealmBase.start(RealmBase.java:922)
       at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.start(JBossSecurityMgrRealm.java:128)
       at org.apache.catalina.core.StandardPipeline.start(StandardPipeline.java:287)
       at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1131)
       at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:521)
       at org.apache.catalina.core.StandardService.start(StandardService.java:519)
       at org.apache.catalina.core.StandardServer.start(StandardServer.java:2345)
       at org.apache.catalina.startup.Catalina.start(Catalina.java:594)
       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.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
       at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:110)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.web.tomcat.tc5.Tomcat5.startService(Tomcat5.java:184)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:825)
       at $Proxy16.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:360)
       at org.jboss.system.ServiceController.start(ServiceController.java:382)
       at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:174)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:250)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:833)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:643)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:606)
       at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:174)
       at $Proxy7.deploy(Unknown Source)
       at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
       at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
       at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
       at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
       at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:825)
       at $Proxy0.start(Unknown Source)
       at org.jboss.system.ServiceController.start(ServiceController.java:360)
       at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:324)
       at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:174)
       at $Proxy4.start(Unknown Source)
       at org.jboss.deployment.SARDeployer.start(SARDeployer.java:250)
       at org.jboss.deployment.MainDeployer.start(MainDeployer.java:833)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:643)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:606)
       at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:590)
       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.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
       at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
       at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
       at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
       at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
       at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:174)
       at $Proxy5.deploy(Unknown Source)
       at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:404)
       at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
       at org.jboss.Main.boot(Main.java:144)
       at org.jboss.Main$1.run(Main.java:389)
       at java.lang.Thread.run(Thread.java:536)


      It appears the container for the JBossSecurityMgrRealm has not been set when used as a Realm. Does it make sense to add the instance itself as a valve when the JBossSecurityMgrRealm starts up?

      Thanks.