2 Replies Latest reply on Mar 12, 2005 1:31 PM by Kenneth Bogert

    Startup login problem

    Kenneth Bogert Newbie

      Hello all,

      I am trying to use a ServletContextListener to start an ejb timed object when I deploy the application. The timed object will run nightly maintenance within the application, and needs to be initialized only once. When the listener starts, I get a Password Incorrect exception. However, if I create a simple POJO and execute the listener from it, it works fine.

      Here is the relevant code:

       public void contextInitialized(ServletContextEvent arg0) {
      
       try {
      
       System.setProperty("java.security.auth.login.config", "/home/kbogert/jboss-4.0.1/client/auth.conf");
       UsernamePasswordHandler handler = new UsernamePasswordHandler("administrator", "test".toCharArray());
       LoginContext lc = new LoginContext("secure", handler);
       lc.login();
      
       Maintenance myMaint = MaintenanceUtil.getHome().create();
       myMaint.initializeTimer(IConstants.MAINTENANCE_TIME);
       } catch (RemoteException e) {
       e.printStackTrace();
       } catch (CreateException e) {
       e.printStackTrace();
       } catch (NamingException e) {
       e.printStackTrace();
       } catch (LoginException e) {
       e.printStackTrace();
       } catch (Exception e) {
       e.printStackTrace();
       }
      }
      


      Here is the stack trace:



      00:29:13,965 INFO [STDOUT] java.rmi.AccessException: SecurityException; nested exception is:
      javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
      00:29:13,966 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:370)
      00:29:13,966 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:125)
      00:29:13,966 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      00:29:13,967 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
      00:29:13,967 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:891)
      00:29:13,967 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      00:29:13,967 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      00:29:13,967 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,967 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,967 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      00:29:13,967 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      00:29:13,968 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      00:29:13,968 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      00:29:13,968 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      00:29:13,968 INFO [STDOUT] at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
      00:29:13,968 INFO [STDOUT] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
      00:29:13,968 INFO [STDOUT] at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:115)
      00:29:13,968 INFO [STDOUT] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:101)
      00:29:13,969 INFO [STDOUT] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      00:29:13,969 INFO [STDOUT] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
      00:29:13,969 INFO [STDOUT] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:169)
      00:29:13,969 INFO [STDOUT] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:91)
      00:29:13,969 INFO [STDOUT] at $Proxy202.create(Unknown Source)
      00:29:13,969 INFO [STDOUT] at com.rad300.web.InitListener.contextInitialized(InitListener.java:66)
      00:29:13,969 INFO [STDOUT] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
      00:29:13,969 INFO [STDOUT] at org.apache.catalina.core.StandardContext.start(StandardContext.java:4343)
      00:29:13,969 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
      00:29:13,970 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
      00:29:13,970 INFO [STDOUT] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
      00:29:13,970 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      00:29:13,970 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      00:29:13,970 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,970 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,970 INFO [STDOUT] at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
      00:29:13,970 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
      00:29:13,971 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      00:29:13,971 INFO [STDOUT] at org.apache.catalina.core.StandardContext.init(StandardContext.java:5441)
      00:29:13,971 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      00:29:13,971 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      00:29:13,971 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,971 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,971 INFO [STDOUT] at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
      00:29:13,971 INFO [STDOUT] at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
      00:29:13,971 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      00:29:13,972 INFO [STDOUT] at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:332)
      00:29:13,972 INFO [STDOUT] at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:85)
      00:29:13,972 INFO [STDOUT] at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:374)
      00:29:13,972 INFO [STDOUT] at org.jboss.web.WebModule.startModule(WebModule.java:62)
      00:29:13,972 INFO [STDOUT] at org.jboss.web.WebModule.startService(WebModule.java:40)
      00:29:13,972 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
      00:29:13,972 INFO [STDOUT] at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)00:29:13,972 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      00:29:13,972 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      00:29:13,973 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,973 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,973 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      00:29:13,973 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      00:29:13,974 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      00:29:13,974 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      00:29:13,974 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      00:29:13,974 INFO [STDOUT] at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
      00:29:13,974 INFO [STDOUT] at $Proxy0.start(Unknown Source)
      00:29:13,974 INFO [STDOUT] at org.jboss.system.ServiceController.start(ServiceController.java:416)
      00:29:13,974 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      00:29:13,974 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,975 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,975 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      00:29:13,975 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      00:29:13,975 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      00:29:13,975 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      00:29:13,975 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      00:29:13,975 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      00:29:13,975 INFO [STDOUT] at $Proxy28.start(Unknown Source)
      00:29:13,976 INFO [STDOUT] at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:360)
      00:29:13,976 INFO [STDOUT] at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
      00:29:13,976 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
      00:29:13,976 INFO [STDOUT] at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
      00:29:13,976 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
      00:29:13,976 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,976 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,976 INFO [STDOUT] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      00:29:13,976 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      00:29:13,977 INFO [STDOUT] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      00:29:13,977 INFO [STDOUT] at $Proxy8.deploy(Unknown Source)
      00:29:13,977 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
      00:29:13,978 INFO [STDOUT] at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:463)
      00:29:13,978 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
      00:29:13,978 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
      00:29:13,978 INFO [STDOUT] at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
      00:29:13,978 INFO [STDOUT] Caused by: javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
      00:29:13,978 INFO [STDOUT] at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:160)
      00:29:13,979 INFO [STDOUT] at org.jboss.security.auth.spi.UsersRolesLoginModule.login(UsersRolesLoginModule.java:124)
      00:29:13,979 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      00:29:13,979 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      00:29:13,979 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      00:29:13,979 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      00:29:13,979 INFO [STDOUT] at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
      00:29:13,988 INFO [STDOUT] at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
      00:29:13,988 INFO [STDOUT] at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
      00:29:13,988 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
      00:29:13,988 INFO [STDOUT] at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
      00:29:13,988 INFO [STDOUT] at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
      00:29:13,988 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecurityManager.java:480)00:29:13,992 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecurityManager.java:420)00:29:13,992 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:237)
      00:29:13,993 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:210)
      00:29:13,993 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:163)
      00:29:13,993 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:91)
      00:29:13,993 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
      00:29:13,993 INFO [STDOUT] ... 93 more



      Here is the code that makes it work:

       public static void main(String[] args) {
      
       InitListener test = new InitListener();
       test.contextInitialized(null);
       }
      

      What am I doing wrong? Do I have to change some settings in the LoginContext in order for it to work when run from inside Tomcat as opposed to normal execution?

      Thanks,
      kdb