2 Replies Latest reply on Jan 19, 2006 8:36 AM by Francesco Casati

    LocalAccessError with MDB

    Francesco Casati Newbie

      Hi, I am new to Jboss ad EJB and I am experiencing a problem with MDB:

      The question is: I can I access session Beans for a MDB using local interfaces?
      My MDB code is:

       public void onMessage(Message msg) {
       System.out.println("onMessage");
       try {
      
       InitialContext lContext = new InitialContext();
       System.out.println("Message Received: "+msg.toString());
       home = (MMSServicesLocalHome) lContext.lookup("java:/comp/env/MMSServicesLocal");
       home.create();
       }
       catch(Exception e) {
       e.printStackTrace();
       }
      


      that gives me an error when calling create():
      12:39:38,579 INFO [STDOUT] javax.ejb.AccessLocalException: SecurityException; CausedByException is:
       Password Incorrect/Password Required
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:366)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:125)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:894)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:344)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
      12:39:38,579 INFO [STDOUT] at $Proxy716.create(Unknown Source)
      12:39:38,579 INFO [STDOUT] at unimib.util.TestJMS.onMessage(TestJMS.java:93)
      12:39:38,579 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      12:39:38,579 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      12:39:38,579 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      12:39:38,579 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      12:39:38,579 INFO [STDOUT] at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
      12:39:38,579 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:101)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:873)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
      12:39:38,579 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1379)
      12:39:38,579 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      12:39:38,579 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904)
      12:39:38,579 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
      12:39:38,579 INFO [STDOUT] at org.jboss.mq.SpySession.run(SpySession.java:333)
      12:39:38,579 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      12:39:38,579 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
      12:39:38,579 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      12:39:38,579 INFO [STDOUT] javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
      12:39:38,579 INFO [STDOUT] at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:189)
      12:39:38,579 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      12:39:38,579 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      12:39:38,579 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      12:39:38,579 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      12:39:38,579 INFO [STDOUT] at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
      12:39:38,579 INFO [STDOUT] at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
      12:39:38,579 INFO [STDOUT] at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
      12:39:38,579 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
      12:39:38,594 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecurityManager.java:572)
      12:39:38,594 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecurityManager.java:506)
      12:39:38,594 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:315)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:196)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:120)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:894)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:344)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
      12:39:38,594 INFO [STDOUT] at $Proxy716.create(Unknown Source)
      12:39:38,594 INFO [STDOUT] at unimib.util.TestJMS.onMessage(TestJMS.java:93)
      12:39:38,594 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      12:39:38,594 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      12:39:38,594 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      12:39:38,594 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      12:39:38,594 INFO [STDOUT] at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
      12:39:38,594 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:101)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:873)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
      12:39:38,594 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1379)
      12:39:38,594 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      12:39:38,594 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904)
      12:39:38,594 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
      12:39:38,594 INFO [STDOUT] at org.jboss.mq.SpySession.run(SpySession.java:333)
      12:39:38,594 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      12:39:38,594 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
      12:39:38,594 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      12:39:38,594 INFO [STDOUT] javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
      12:39:38,594 INFO [STDOUT] at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:189)
      12:39:38,594 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      12:39:38,594 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      12:39:38,594 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      12:39:38,594 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
      12:39:38,594 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
      12:39:38,594 INFO [STDOUT] at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
      12:39:38,594 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecurityManager.java:572)
      12:39:38,594 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecurityManager.java:506)
      12:39:38,594 INFO [STDOUT] at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:315)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:196)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:120)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:613)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:894)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:344)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
      12:39:38,610 INFO [STDOUT] at $Proxy716.create(Unknown Source)
      12:39:38,610 INFO [STDOUT] at unimib.util.TestJMS.onMessage(TestJMS.java:93)
      12:39:38,610 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      12:39:38,610 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      12:39:38,610 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      12:39:38,610 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      12:39:38,610 INFO [STDOUT] at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.java:475)
      12:39:38,610 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterceptor.java:101)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:873)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
      12:39:38,610 INFO [STDOUT] at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerInvoker.java:1379)
      12:39:38,610 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
      12:39:38,610 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904)
      12:39:38,610 INFO [STDOUT] at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
      12:39:38,610 INFO [STDOUT] at org.jboss.mq.SpySession.run(SpySession.java:333)
      12:39:38,610 INFO [STDOUT] at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
      12:39:38,610 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
      12:39:38,610 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      


      The strange (to me) thing is that if I use the same code in a session bean everything works fine.

      Here are my ejb-jar and jboss.xml for TestingJMS:
       <message-driven>
       <ejb-name>TestJMS</ejb-name>
       <ejb-class>unimib.util.TestJMS</ejb-class>
       <transaction-type>Container</transaction-type>
       <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
       <message-driven-destination>
       <destination-type>javax.jms.Queue</destination-type>
       </message-driven-destination>
       <resource-ref>
       <res-ref-name>jms/QCF</res-ref-name>
       <res-type>javax.jms.QueueConnectionFactory</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
       <ejb-local-ref>
       <description />
       <ejb-ref-name>MMSServicesLocal</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
       <local-home>unimib.milk.kme.mms.MMSServicelLocalHome</local-home>
       <local>unimib.util.MMSServicesLocal</local>
       <ejb-link>MMSServices</ejb-link>
       </ejb-local-ref>
       </message-driven>


      and
       <message-driven>
       <ejb-name>TestJMS</ejb-name>
       <destination-jndi-name>queue/MyQueue</destination-jndi-name>
       <resource-ref>
       <res-ref-name>jms/QCF</res-ref-name>
       <jndi-name>QueueConnectionFactory</jndi-name>
       </resource-ref>
       </message-driven>
      

      and for the MMSServicesBean
       <session>
       <ejb-name>MMSServices</ejb-name>
       <jndi-name>MMSServices</jndi-name>
       <local-jndi-name>MMSServicesLocal</local-jndi-name>
       </session>
      

      <display-name>MMSServices</display-name>
       <ejb-name>MMSServices</ejb-name>
       <home>unimib.milk.kme.mms.MMSServicesHome</home>
       <remote>unimib.milk.kme.mms.MMSServices</remote>
       <local>unimib.milk.kme.mms.MMSServicesLocal</local>
       <local-home>unimib.milk.kme.mms.MMSServicesLocalHome</local-home>
       <ejb-class>unimib.milk.kme.mms.MMSServicesBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
      ... (local refs)
      


      Any help? Since I'm just extending the base application with JMS I'm using descriptors made by someone else, are they ok?