0 Replies Latest reply on Feb 10, 2009 1:00 AM by Benjamin Seyinbour

    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
      ----------------------------------------------------------------------------------------------------
      -
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_5_0.dtd">
      <jboss>
       <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.get
      Log(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).ge
      tTime(), 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.RenewalNoticeTimerLo
      cal, 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.StatelessRemo
      teProxyInvocationHandler@43de84
      2009-02-08 16:38:08,715 DEBUG [org.jboss.ejb3.proxy.invocation.InvokableContextStatefulRemoteProxyIn
      vocationHack] (HDScanner) Received invocation request to method com.xxxxxxxx.xxxx.jms.intf.RenewalNo
      ticeTimerRemote: 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 dyn
      amic 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.Ejb3AuthenticationInt
      erceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:137)
      2009-02-08 16:38:08,949 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,949 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.ENCPropagationInterceptor.invo
      ke(ENCPropagationInterceptor.java:41)
      2009-02-08 16:38:08,949 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,950 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.asynchronous.AsynchronousInter
      ceptor.invoke(AsynchronousInterceptor.java:106)
      2009-02-08 16:38:08,950 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,951 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.BlockContainerShutdownIntercep
      tor.invoke(BlockContainerShutdownInterceptor.java:65)
      2009-02-08 16:38:08,951 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,951 ERROR [STDERR] (HDScanner) at org.jboss.aspects.currentinvocation.CurrentIn
      vocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
      2009-02-08 16:38:08,952 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,952 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.stateless.StatelessContainer.d
      ynamicInvoke(StatelessContainer.java:486)
      2009-02-08 16:38:08,953 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.remoting.IsLocalInterceptor.in
      vokeLocal(IsLocalInterceptor.java:97)
      2009-02-08 16:38:08,953 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.remoting.IsLocalInterceptor.in
      voke(IsLocalInterceptor.java:74)
      2009-02-08 16:38:08,954 ERROR [STDERR] (HDScanner) at org.jboss.aop.joinpoint.MethodInvocation.invo
      keNext(MethodInvocation.java:102)
      2009-02-08 16:38:08,954 ERROR [STDERR] (HDScanner) at org.jboss.aspects.remoting.PojiProxy.invoke(P
      ojiProxy.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.ProxyInvocationH
      andlerBase.invoke(ProxyInvocationHandlerBase.java:261)
      2009-02-08 16:38:08,955 ERROR [STDERR] (HDScanner) at org.jboss.ejb3.proxy.handler.session.SessionS
      pecProxyInvocationHandlerBase.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(StartupTimerSer
      vletContextListener.java:111) 2009-02-08 16:38:08,957
      
      
      ERROR [STDERR] (HDScanner) at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
      t.java:3910)
      2009-02-08 16:38:08,957 ERROR [STDERR] (HDScanner) at org.apache.catalina.core.StandardContext.star
      t(StandardContext.java:4393)
      2009-02-08 16:38:08,957 ERROR [STDERR] (HDScanner) at org.jboss.web.tomcat.service.deployers.Tomcat
      Deployment.performDeployInternal(TomcatDeployment.java:367)
      2009-02-08 16:38:08,958 ERROR [STDERR] (HDScanner) at org.jboss.web.tomcat.service.deployers.Tomcat
      Deployment.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(WebMo
      dule.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(N
      ativeMethodAccessorImpl.java:39)
      2009-02-08 16:38:08,960 ERROR [STDERR] (HDScanner) at sun.reflect.DelegatingMethodAccessorImpl.invo
      ke(DelegatingMethodAccessorImpl.java:25)
      2009-02-08 16:38:08,961 ERROR [STDERR] (HDScanner) at java.lang.reflect.Method.invoke(Method.java:5
      97)
      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(Invoc
      ation.java:96)
      2009-02-08 16:38:08,962 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.Invocation.invoke(Invocat
      ion.java:88)
      2009-02-08 16:38:08,962 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.AbstractMBeanInvoker.invo
      ke(AbstractMBeanInvoker.java:264)
      2009-02-08 16:38:08,963 ERROR [STDERR] (HDScanner) at org.jboss.mx.server.MBeanServerImpl.invoke(MB
      eanServerImpl.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.StartStopLife
      cycleAction.installAction(StartStopLifecycleAction.java:42)
      2009-02-08 16:38:08,965 ERROR [STDERR] (HDScanner) at org.jboss.system.microcontainer.StartStopLife
      cycleAction.installAction(StartStopLifecycleAction.java:37)
      2009-02-08 16:38:08,965 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.action.SimpleCon
      trollerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
      2009-02-08 16:38:08,965 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.action.AccessCon
      trollerContextAction.install(AccessControllerContextAction.java:71)
      2009-02-08 16:38:08,966 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      erContextActions.install(AbstractControllerContextActions.java:51)
      2009-02-08 16:38:08,966 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      erContext.install(AbstractControllerContext.java:348)
      2009-02-08 16:38:08,967 ERROR [STDERR] (HDScanner) at org.jboss.system.microcontainer.ServiceContro
      llerContext.install(ServiceControllerContext.java:286)
      2009-02-08 16:38:08,967 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.install(AbstractController.java:1598)
      2009-02-08 16:38:08,968 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.incrementState(AbstractController.java:934)
      2009-02-08 16:38:08,968 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.resolveContexts(AbstractController.java:1062)
      2009-02-08 16:38:08,969 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.resolveContexts(AbstractController.java:984)
      2009-02-08 16:38:08,969 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.change(AbstractController.java:822)
      2009-02-08 16:38:08,969 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.change(AbstractController.java:553)
      2009-02-08 16:38:08,970 ERROR [STDERR] (HDScanner) at org.jboss.system.ServiceController.doChange(S
      erviceController.java:688)
      2009-02-08 16:38:08,970 ERROR [STDERR] (HDScanner) at org.jboss.system.ServiceController.start(Serv
      iceController.java:460)
      2009-02-08 16:38:08,971 ERROR [STDERR] (HDScanner) at org.jboss.system.deployers.ServiceDeployer.st
      art(ServiceDeployer.java:146)
      2009-02-08 16:38:08,971 ERROR [STDERR] (HDScanner) at org.jboss.system.deployers.ServiceDeployer.de
      ploy(ServiceDeployer.java:104)
      2009-02-08 16:38:08,971 ERROR [STDERR] (HDScanner) at org.jboss.system.deployers.ServiceDeployer.de
      ploy(ServiceDeployer.java:45)
      2009-02-08 16:38:08,972 ERROR [STDERR] (HDScanner) at org.jboss.deployers.spi.deployer.helpers.Abst
      ractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
      2009-02-08 16:38:08,972 ERROR [STDERR] (HDScanner) at org.jboss.deployers.spi.deployer.helpers.Abst
      ractRealDeployer.deploy(AbstractRealDeployer.java:50)
      2009-02-08 16:38:08,973 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rWrapper.deploy(DeployerWrapper.java:171)
      2009-02-08 16:38:08,973 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rsImpl.doDeploy(DeployersImpl.java:1439)
      2009-02-08 16:38:08,974 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rsImpl.doInstallParentFirst(DeployersImpl.java:1157)
      2009-02-08 16:38:08,974 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rsImpl.doInstallParentFirst(DeployersImpl.java:1178)
      2009-02-08 16:38:08,974 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rsImpl.doInstallParentFirst(DeployersImpl.java:1210)
      2009-02-08 16:38:08,975 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rsImpl.install(DeployersImpl.java:1098)
      2009-02-08 16:38:08,975 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      erContext.install(AbstractControllerContext.java:348)
      2009-02-08 16:38:08,976 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.install(AbstractController.java:1598)
      2009-02-08 16:38:08,976 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.incrementState(AbstractController.java:934)
      2009-02-08 16:38:08,977 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.resolveContexts(AbstractController.java:1062)
      2009-02-08 16:38:08,977 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.resolveContexts(AbstractController.java:984)
      2009-02-08 16:38:08,977 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.change(AbstractController.java:822)
      2009-02-08 16:38:08,978 ERROR [STDERR] (HDScanner) at org.jboss.dependency.plugins.AbstractControll
      er.change(AbstractController.java:553)
      2009-02-08 16:38:08,978 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.deployers.Deploye
      rsImpl.process(DeployersImpl.java:781)
      2009-02-08 16:38:08,979 ERROR [STDERR] (HDScanner) at org.jboss.deployers.plugins.main.MainDeployer
      Impl.process(MainDeployerImpl.java:545)
      2009-02-08 16:38:08,979 ERROR [STDERR] (HDScanner) at org.jboss.system.server.profileservice.hotdep
      loy.HDScanner.scan(HDScanner.java:290)
      2009-02-08 16:38:08,980 ERROR [STDERR] (HDScanner) at org.jboss.system.server.profileservice.hotdep
      loy.HDScanner.run(HDScanner.java:221)
      2009-02-08 16:38:08,980 ERROR [STDERR] (HDScanner) at java.util.concurrent.Executors$RunnableAdapte
      r.call(Executors.java:441)
      2009-02-08 16:38:08,981 ERROR [STDERR] (HDScanner) at java.util.concurrent.FutureTask$Sync.innerRun
      AndReset(FutureTask.java:317)
      2009-02-08 16:38:08,981 ERROR [STDERR] (HDScanner) at java.util.concurrent.FutureTask.runAndReset(F
      utureTask.java:150)
      2009-02-08 16:38:08,981 ERROR [STDERR] (HDScanner) at java.util.concurrent.ScheduledThreadPoolExecu
      tor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
      2009-02-08 16:38:08,982 ERROR [STDERR] (HDScanner) at java.util.concurrent.ScheduledThreadPoolExecu
      tor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
      2009-02-08 16:38:08,982 ERROR [STDERR] (HDScanner) at java.util.concurrent.ScheduledThreadPoolExecu
      tor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
      2009-02-08 16:38:08,983 ERROR [STDERR] (HDScanner) at java.util.concurrent.ThreadPoolExecutor$Worke
      r.runTask(ThreadPoolExecutor.java:886)
      2009-02-08 16:38:08,983 ERROR [STDERR] (HDScanner) at java.util.concurrent.ThreadPoolExecutor$Worke
      r.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] (H
      DScanner) Exiting contextInitialized