3 Replies Latest reply on Nov 11, 2006 9:28 AM by Walter Herbert

    inject @EJB dosn't work with 4.0.5

    Walter Herbert Newbie

      I have 2 Statless Sessionbeans in one I invoke the other by using
      @EJB

      The same jar works fine under 4.0.4 GA!!

      Example Javacode:

      import javax.annotation.EJB;
      import javax.ejb.Stateless;
      
      public @Stateless class MailBoxAccountManagerBean implements WM_MailBoxAccountManager {
      
       @PersistenceContext
       private EntityManager manager;
      
       @EJB
       FolderManager folderManager;
      
       public void deleteFolder(Integer folderId){
       if(folderId == null ) return;
       manager.deleteAllMailsInFolder(folderId);
       folderManager.deleteFolder(folderId);
       }
      }



      @Remote
      @Local
      public interface WM_FolderManager{
       public void deleteFolder(Integer folderId);
       ...
      }


      persistence.xml
      <?xml version="1.0" encoding="UTF-8" ?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence">
       <persistence-unit name="WM2Manager">
       <description>Persistens Manager from modul WebMailer 2.0
       </description>
       <jta-data-source>java:/mySQL-wm2-DS</jta-data-source>
       </persistence-unit>
      </persistence>



      Now i only get a NullpointerException in the line where i use the folderManager, a sysout showes it is null.
      hmm...
      I'm also happy about some linkes or something else if i overread something in the changelogs!

      thx

        • 1. Re: inject @EJB dosn't work with 4.0.5
          Andrew Rubinger Master

           

          javax.ejb.EJB


          ...should work. :)

          S,
          ALR

          • 2. Re: inject @EJB dosn't work with 4.0.5
            Walter Herbert Newbie

            Thx allot ALRubinger,
            this solve the NullpointerException!! I forgot to add the new Jars to my Eclipse Project *ups* i use this library's from jboss 4.0.5 now:
            *jboss-ejb3x.jar
            *hibernate-client.jar
            *ejb3-persistence.jar


            But yet i get this crazy error!

            Work right!!

            WM_MailManager mm =(WM_MailManager) new InitialContext().lookup("WM_MailManagerBean/local");
            mm.deleteAllMailsInFolder(folder,userId,leaveHashes);



            Create the following error!
            @EJB
            WM_MailManager mailManager;
            ....
            
            mailManager.deleteAllMailsInFolder(folder,userId,leaveHashes);




            00:55:33,281 ERROR [STDERR] javax.ejb.EJBTransactionRolledbackException: java.lang.IllegalArgumentException: Wrong target. class wm2.ejb.session.WM_MailManagerBean for public void wm2.ejb.session.WM_MailManagerBean.deleteAllMailsInFolder(wm2.ejb.entity.WM_Folder,java.lang.Integer,boolean) throws wm2.exception.WM_PermissionDenied
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:93)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:201)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:58)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
            00:55:33,281 ERROR [STDERR] at $Proxy687.deleteAllMailsInFolder(Unknown Source)
            00:55:33,281 ERROR [STDERR] at wm2.ejb.session.WM_FolderManagerBean.recrusiveDeleteFolderAndContent(WM_FolderManagerBean.java:264)
            00:55:33,281 ERROR [STDERR] at wm2.ejb.session.WM_FolderManagerBean.deleteFolderAndContentRecrusive(WM_FolderManagerBean.java:242)
            00:55:33,281 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            00:55:33,281 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            00:55:33,281 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            00:55:33,281 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
            00:55:33,281 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
            00:55:33,281 ERROR [STDERR] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
            00:55:33,281 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
            00:55:33,281 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
            00:55:33,281 ERROR [STDERR] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
            00:55:33,281 ERROR [STDERR] Caused by: java.lang.IllegalArgumentException: Wrong target. class wm2.ejb.session.WM_MailManagerBean for public void wm2.ejb.session.WM_MailManagerBean.deleteAllMailsInFolder(wm2.ejb.entity.WM_Folder,java.lang.Integer,boolean) throws wm2.exception.WM_PermissionDenied
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.handleErrors(MethodInvocation.java:141)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:116)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
            00:55:33,281 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
            00:55:33,281 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
            00:55:33,281 ERROR [STDERR] ... 54 more



            WM_Folder:
            package wm2.ejb.entity;
            
            import javax.persistence.Column;
            import javax.persistence.Entity;
            import javax.persistence.GeneratedValue;
            import javax.persistence.GenerationType;
            import javax.persistence.Id;
            import javax.persistence.NamedQueries;
            import javax.persistence.NamedQuery;
            import javax.persistence.OneToMany;
            import javax.persistence.Table;
            
            @SuppressWarnings("serial")
            @Entity
            @Table(name="folder")
            @NamedQueries({
             ....
            })
            
            public class WM_Folder implements Serializable{
            ....
            }



            thx 4 help

            • 3. Re: inject @EJB dosn't work with 4.0.5
              Walter Herbert Newbie

              A restart of Jboss solve the problem !!!

              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=93486

              how ever in Jboss 4.0.4 GA it works well!!!