2 Replies Latest reply on Nov 6, 2007 1:34 PM by Daniel Spangler

    Error Injecting EntityManager

    Livia Santos Newbie

      Hi guys,

      I hava an EJB project and I separated it into two components: service.jar (which contains only interfaces) and service-impl.jar (which contains implementation of those interfaces).

      At service.jar I've a ordinary interface. At service-impl.jar I've an local interface (@Local), remote interface (@Remote) and a bean (@Stateless).

      All those compoments are packaged into a ear file.

      The problem is that in one of my stateless, when injecting an EntityManager object, the following error occurs:

      # Caused by: java.lang.RuntimeException: Non matching type for inject of field: private javax.persistence.EntityManager br.unicamp.hc.caa.ejb.eao.PeriodoCadastralEAOBean.entityManager for type: org.jboss.ejb3.entity.InjectedEntityManagerFactory of jndiName env/br.unicamp.hc.caa.ejb.eao.PeriodoCadastralEAOBean/entityManager
      # intfs: , javax.persistence.EntityManagerFactory, java.io.Externalizable
      # at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:127)
      # at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:105)
      # at org.jboss.injection.JndiFieldInjector.inject(JndiFieldInjector.java:62)
      # at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:111)
      # at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:61)
      # at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      # at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
      # at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      # at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      # at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      # at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
      # at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
      # at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
      # at $Proxy124.findUltimoPeriodoCadastral(Unknown Source)
      # at br.unicamp.hc.caa.ejb.facade.PeriodoCadastralFacadeBean.findUltimoPeriodoCadastral(Unknown Source)
      # at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      # at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
      # 09:56:32,011 ERROR [STDERR] 39)
      # at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      # at java.lang.reflect.Method.invoke(Method.java:597)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      # at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      # at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      # at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      # at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      # at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      # Caused by: java.lang.IllegalArgumentException: Can not set javax.persistence.EntityManager field br.unicamp.hc.caa.ejb.eao.PeriodoCadastralEAOBean.entityManager to org.jboss.ejb3.entity.InjectedEntityManagerFactory
      


      This error occurs only when I call stateless session bean. Deployment is fine.

      Does anybody know what's going on?

      Thanks in advance
      LISS