0 Replies Latest reply on Feb 8, 2009 11:14 PM by Benjamin Seyinbour

    javax.ejb.EJBAccessException: Invalid User

    Benjamin Seyinbour Expert

      Development Platform:
      Eclipse
      Linux
      JBoss 5
      JSF and Trinadad

      Problem Description:
      I have two classes:
      (a) Stateless bean[RenewalNoticeTimerController] packaged in a ejb.jar
      (b) Servlet [StartupTimerServletContextListener] packaged in web.war

      1. The ejb.jar and web.war are ear modules and deployed in ear file.
      2. When I deploy the ear, I get javax.ejb.EJBAccessException: Invalid User. Please see tha [C] Stack Trace below.
      3. However if I remove the highlighted [Ln 111] in the StartupTimerServletContextListener class, I don't see any error and the ear deploys fine.
      4. You can conclude, therefore that the problem is caused by the RenewalNoticeTimerController from the ejb.jar and is related to security.

      Could someone please take a look at my code, particularly, the security annotations in RenewalNoticeTimerController and help me identify the problem?
      Thanks you in advance

      Additional Info
      -----------------------------------------------------------------------------------------------------
      jboss-app
      -----------------------------------------------------------------------------------------------------
      <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd">
      <jboss-app>
       <security-domain >java:/jaas/odmsRealm</security-domain>
      </jboss-app>
      -----------------------------------------------------------------------------------------------------
      jboss.xml
      -----------------------------------------------------------------------------------------------------
      <jboss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.org/j2ee/schema http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="5.0">
       <security-domain>java:/jaas/xxxxRealm</security-domain>
       <unauthenticated-principal>anonymous</unauthenticated-principal>
      </jboss>
      -----------------------------------------------------------------------------------------------------
      jboss-web.xml
      -----------------------------------------------------------------------------------------------------
      <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
      <jboss-web>
       <security-domain flushOnSessionInvalidation="true">java:/jaas/xxxxRealm</security-domain>
       <context-root>/xxxx-web</context-root>
      </jboss-web>
      


      -----------------------------------------------------------------------------------------------------
      [A] StartupTimerServletContextListener [ejb layer]
      -----------------------------------------------------------------------------------------------------
      // Security annotation
      @javax.annotation.security.DeclareRoles({"admin", "staff"})
      @javax.annotation.security.RolesAllowed({"admin", "staff"})
      @org.jboss.ejb3.annotation.SecurityDomain(value = "xxxxRealm")
      public class StartupTimerServletContextListener implements ServletContextListener{
       /**
       * The logger object.
       */
       private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(StartupTimerServletContextListener.class);
       private static final String ATTRIBUTE_NAME = "RenewalNoticeTimer";
       private javax.servlet.ServletContext servletContextEvent;
      
       @javax.ejb.EJB(mappedName ="ejb/RenewalNoticeTimerController")
       private com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerRemote renewalNoticeTimer;
      
       /**
       * Methods from the ServletContextListener. Initialises the timer service.
       *
       * @param event Event that invoked the listener
       */
       public void contextInitialized(ServletContextEvent servletContextEvent) {
       log.debug("Entering contextInitialized");
       if(this.servletContextEvent != null) {
       throw new IllegalStateException("context is already initialized");
       }
       this.servletContextEvent = servletContextEvent.getServletContext();
       this.servletContextEvent.setAttribute(ATTRIBUTE_NAME, new Integer(0));
       try {
       /*
       * When you deploy the enterprise application you will see that the timer is
       *set to start at midnight and execute every 86400000 ms (i.e. every 24 hours).
       */
       Calendar now = Calendar.getInstance();
       now.set(Calendar.HOUR_OF_DAY, 0);
       now.set(Calendar.MINUTE, 0);
       now.set(Calendar.SECOND, 0);
       int year = now.get(Calendar.YEAR);
       int month = now.get(Calendar.MONTH);
       int dayOfMonth = now.get(Calendar.DAY_OF_MONTH);
       int hourOfDay = now.get(Calendar.HOUR_OF_DAY);
       int minute = now.get(Calendar.MINUTE);
       Long repeat = 60000L * 60L * 24L;
       log.info("Start time: " + now.getTime());
       log.info("Repeat every: " + repeat + " ms (" + (repeat / 3600000L) + " hrs)");
      
       renewalNoticeTimer.startTimer(new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute).getTime(), 60000L * 60L * 24L, DeclaredConstants.RENEWAL_CHECK);
      
       } catch(javax.ejb.EJBAccessException eae) {
       eae.printStackTrace();
       } catch(Throwable ex) {
       ex.printStackTrace();
       }
       log.debug("Exiting contextInitialized");
       }
      
       }
      
      

      -----------------------------------------------------------------------------------------------------
      [B] RenewalNoticeTimerController [web layer]
      -----------------------------------------------------------------------------------------------------
      @javax.ejb.Stateless(mappedName="ejb/RenewalNoticeTimerController")
      @javax.ejb.Remote({com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerRemote.class})
      @javax.ejb.Local({com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerLocal.class})
      // Security annotation
      @javax.annotation.security.DeclareRoles({"admin", "staff"})
      @javax.annotation.security.RolesAllowed({"admin", "staff"})
      @org.jboss.ejb3.annotation.SecurityDomain(value = "xxxxRealm")
      
      public class RenewalNoticeTimerController implements com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerLocal, com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerRemote, java.io.Serializable{
      
       public RenewalNoticeTimerController() {}
      
       /**
       */
       @SuppressWarnings("unchecked")
       @javax.annotation.security.PermitAll
       public void startTimer(Date startDate, Long interval, java.io.Serializable info) {
       log.debug("Entering startTimer");
      
       boolean timerExist = false;
       for (Timer timer : new java.util.ArrayList<Timer>(timerService.getTimers())) {
       if (timer.getInfo().toString().equalsIgnoreCase((String)info))
       log.info("Timer already exist " + info);
       timerExist = true;
       }
       if (timerExist == false) {
       log.info("Starting a new Timer: " + info + " --None exist before");
       timerService.createTimer(startDate, interval, info);
       }
       log.debug("Exiting startTimer");
       }
      
      }
      
      

      -----------------------------------------------------------------------------------------------------
      [C] Stack Trace
      -----------------------------------------------------------------------------------------------------
      
      Date,java.lang.Long,java.io.Serializable)" is not eligible for direct handling by org.jboss.ejb3.proxy.handler.session.stateless.StatelessRemoteProxyInvocationHandler@43de84
      2009-02-08 16:38:08,715 DEBUG [org.jboss.ejb3.proxy.invocation.InvokableContextStatefulRemoteProxyInvocationHack] (HDScanner) Received invocation request to method com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerRemote: com.xxxxxxxx.xxxx.jms.intf.RenewalNoticeTimerService.startTimer(java.util.Date,java.lang.Long,java.io.Serializable); using hash: -5081608935271166128
      2009-02-08 16:38:08,827 DEBUG [org.jboss.ejb3.stateless.StatelessContainer] (HDScanner) Received dynamic invocation for method with hash: -5081608935271166128
      2009-02-08 16:38:08,947 ERROR [STDERR] (HDScanner) javax.ejb.EJBAccessException: Invalid User
      2009-02-08 16:38:08,948 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:137)
      2009-02-08 16:38:08,949 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,949 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
      2009-02-08 16:38:08,949 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,950 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      2009-02-08 16:38:08,950 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,951 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:65)
      2009-02-08 16:38:08,951 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,951 ERROR [STDERR] (HDScanner) at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
      2009-02-08 16:38:08,952 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,952 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:486)
      2009-02-08 16:38:08,953 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:97)
      2009-02-08 16:38:08,953 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
      2009-02-08 16:38:08,954 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,954 ERROR [STDERR] (HDScanner) at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
      2009-02-08 16:38:08,954 ERROR [STDERR] (HDScanner) at $Proxy188.invoke(Unknown Source)
      2009-02-08 16:38:08,955 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase.invoke(ProxyInvocationHandlerBase.java:261)
      2009-02-08 16:38:08,955 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase.invoke(SessionSpecProxyInvocationHandlerBase.java:101)
      2009-02-08 16:38:08,956 ERROR [STDERR] (HDScanner) at $Proxy248.startTimer(Unknown Source)
      2009-02-08 16:38:08,956 ERROR [STDERR] (HDScanner) at
      
      com.xxxxxxxx.xxxx.web.listener.StartupTimerServletContextListener.contextInitialized(StartupTimerServletContextListener.java:111) 2009-02-08 16:38:08,957
      
      ERROR [STDERR] (HDScanner) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910)
      2009-02-08 16:38:08,957 ERROR [STDERR] (HDScanner) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4393)
      2009-02-08 16:38:08,957 ERROR [STDERR] (HDScanner) at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:367)
      2009-02-08 16:38:08,958 ERROR [STDERR] (HDScanner) at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146)
      2009-02-08 16:38:08,958 ERROR [STDERR] (HDScanner) at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:460)
      2009-02-08 16:38:08,959 ERROR [STDERR] (HDScanner) at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
      2009-02-08 16:38:08,959 ERROR [STDERR] (HDScanner) at org.jboss.web.deployers.WebModule.start(WebModule.java:96)
      2009-02-08 16:38:08,959 ERROR [STDERR] (HDScanner) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2009-02-08 16:38:08,960 ERROR [STDERR] (HDScanner) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      2009-02-08 16:38:08,960 ERROR [STDERR] (HDScanner) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2009-02-08 16:38:08,961 ERROR [STDERR] (HDScanner) at java.lang.reflect.Method.invoke(Method.java:597)
      2009-02-08 16:38:08,961 ERROR [STDERR] (HDScanner) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
      2009-02-08 16:38:08,962 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
      2009-02-08 16:38:08,962 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      2009-02-08 16:38:08,962 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      2009-02-08 16:38:08,963 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
      2009-02-08 16:38:08,963 ERROR [STDERR] (HDScanner) at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
      2009-02-08 16:38:08,964 ERROR [STDERR] (HDScanner) at $Proxy36.start(Unknown Source)
      2009-02-08 16:38:08,964 ERROR [STDERR] (HDScanner) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
      2009-02-08 16:38:08,965 ERROR [STDERR] (HDScanner) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
      2009-02-08 16:38:08,965 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
      2009-02-08 16:38:08,965 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
      2009-02-08 16:38:08,966 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
      2009-02-08 16:38:08,966 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
      2009-02-08 16:38:08,967 ERROR [STDERR] (HDScanner) at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
      2009-02-08 16:38:08,967 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
      2009-02-08 16:38:08,968 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
      2009-02-08 16:38:08,968 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
      2009-02-08 16:38:08,969 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
      2009-02-08 16:38:08,969 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
      2009-02-08 16:38:08,969 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
      2009-02-08 16:38:08,970 ERROR [STDERR] (HDScanner) at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
      2009-02-08 16:38:08,970 ERROR [STDERR] (HDScanner) at org.jboss.system.ServiceController.start(ServiceController.java:460)
      2009-02-08 16:38:08,971 ERROR [STDERR] (HDScanner) at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:146)
      2009-02-08 16:38:08,971 ERROR [STDERR] (HDScanner) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:104)
      2009-02-08 16:38:08,971 ERROR [STDERR] (HDScanner) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:45)
      2009-02-08 16:38:08,972 ERROR [STDERR] (HDScanner) at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
      2009-02-08 16:38:08,972 ERROR [STDERR] (HDScanner) at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
      2009-02-08 16:38:08,973 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
      2009-02-08 16:38:08,973 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
      2009-02-08 16:38:08,974 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
      2009-02-08 16:38:08,974 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
      2009-02-08 16:38:08,974 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
      2009-02-08 16:38:08,975 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
      2009-02-08 16:38:08,975 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
      2009-02-08 16:38:08,976 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
      2009-02-08 16:38:08,976 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
      2009-02-08 16:38:08,977 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
      2009-02-08 16:38:08,977 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
      2009-02-08 16:38:08,977 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
      2009-02-08 16:38:08,978 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
      2009-02-08 16:38:08,978 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
      2009-02-08 16:38:08,979 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
      2009-02-08 16:38:08,979 ERROR [STDERR] (HDScanner) at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:290)
      2009-02-08 16:38:08,980 ERROR [STDERR] (HDScanner) at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:221)
      2009-02-08 16:38:08,980 ERROR [STDERR] (HDScanner) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
      2009-02-08 16:38:08,981 ERROR [STDERR] (HDScanner) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
      2009-02-08 16:38:08,981 ERROR [STDERR] (HDScanner) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
      2009-02-08 16:38:08,981 ERROR [STDERR] (HDScanner) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
      2009-02-08 16:38:08,982 ERROR [STDERR] (HDScanner) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
      2009-02-08 16:38:08,982 ERROR [STDERR] (HDScanner) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
      2009-02-08 16:38:08,983 ERROR [STDERR] (HDScanner) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      2009-02-08 16:38:08,983 ERROR [STDERR] (HDScanner) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      2009-02-08 16:38:08,983 ERROR [STDERR] (HDScanner) at java.lang.Thread.run(Thread.java:619)
      2009-02-08 16:38:08,984 DEBUG [com.xxxxxxxx.xxxx.web.listener.StartupTimerServletContextListener] (HDScanner) Exiting contextInitialized