3 Replies Latest reply on Jul 14, 2013 3:27 PM by Rafael Pestano

    WELD-001305 The given type class org.jboss.weld.bean.SessionBean is not a type of the bean Session bean

    Rafael Pestano Novice

      Hi everyone,

       

       

      im facing an error when looking up an local EJB via bean manager: http://dominikdorn.com/2010/04/cdi-weld-manual-bean-lookup/

       

       

      The lookup works fine with Weld 1.1.8 but fails in newer version(i'm using 1.1.13).

       

       

      The question is, it should never work or it is a bug in recent versions?

       

       

      i've tested under GFv3.x, GF4.x and AS7.1 and got same behavior, what realy matters is weld version.

       

       

      if you need any example code  you can get it here: https://github.com/rmpestano/cdi-generic-dao, the lookup is done in DaoProducer.java. Just change the maven profile to run it under jboss or glassfish.

       

       

      Thanks in advance.

        • 1. Re: WELD-001305 The given type class org.jboss.weld.bean.SessionBean is not a type of the bean Session bean
          Rafael Pestano Novice

          here is the complete stacktrace:

           

          org.jboss.weld.exceptions.IllegalArgumentException: WELD-001305 The given type class org.jboss.weld.bean.SessionBean is not a type of the bean Session bean [class com.cdi.genericdao.dao.BaseDao with qualifiers [@Any @Default @Named]; local interfaces are [BaseDao<T, ID>]

          org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:633)

          com.cdi.genericdao.producer.DaoProducer.getBeanByName(DaoProducer.java:54)

          com.cdi.genericdao.producer.DaoProducer.produce(DaoProducer.java:39)

          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          java.lang.reflect.Method.invoke(Method.java:606)

          org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)

          org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)

          org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)

          org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)

          org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

          org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)

          org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)

          org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

          org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)

          org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)

          org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)

          org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)

          org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)

          com.cdi.genericdao.producer.DaoProducer$$$view13.produce(Unknown Source)

          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          java.lang.reflect.Method.invoke(Method.java:606)

          org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)

          org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)

          org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)

          org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)

          org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:115)

          org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)

          org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

          com.cdi.genericdao.producer.DaoProducer$Proxy$_$$_Weld$Proxy$.produce(DaoProducer$Proxy$_$$_Weld$Proxy$.java)

          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          java.lang.reflect.Method.invoke(Method.java:606)

          org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)

          org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)

          org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)

          org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)

          org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)

          org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:137)

          org.jboss.weld.bean.ProducerMethod$ProducerMethodProducer.produce(ProducerMethod.java:136)

          org.jboss.weld.bean.AbstractProducerBean$AbstractProducer.produce(AbstractProducerBean.java:319)

          org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:307)

          org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:68)

          org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:608)

          org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:674)

          org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:136)

          org.jboss.weld.util.Beans.injectBoundFields(Beans.java:763)

          org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:772)

          org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:165)

          org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:48)

          org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:161)

          org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:135)

          org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:157)

          org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:297)

          org.apache.myfaces.extensions.cdi.core.impl.util.CodiUtils.createNewInstanceOfBean(CodiUtils.java:69)

          org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.AbstractConversationBeanEntry.createNewBeanInstance(AbstractConversationBeanEntry.java:139)

          org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.AbstractConversationBeanEntry.getBeanInstance(AbstractConversationBeanEntry.java:84)

          org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.AbstractGroupedConversationContext.create(AbstractGroupedConversationContext.java:100)

          org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.ConversationContextAdapter.get(ConversationContextAdapter.java:81)

          org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90)

          org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79)

          com.cdi.genericdao.bean.MyBean$Proxy$_$$_WeldClientProxy.getPersonList(MyBean$Proxy$_$$_WeldClientProxy.java)

          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          java.lang.reflect.Method.invoke(Method.java:606)

          javax.el.BeanELResolver.getValue(BeanELResolver.java:302)

          com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)

          com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)

          org.apache.el.parser.AstValue.getValue(AstValue.java:169)

          org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)

          org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)

          com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)

          javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)

          javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)

          javax.faces.component.UIData.getValue(UIData.java:731)

          org.primefaces.component.datatable.DataTable.getValue(DataTable.java:867)

          org.primefaces.component.api.UIData.getDataModel(UIData.java:579)

          javax.faces.component.UIData.getRowCount(UIData.java:356)

          org.primefaces.component.api.UIData.calculateFirst(UIData.java:157)

          org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:176)

          org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)

          javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)

          com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)

          com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)

          com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)

          javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

          javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)

          javax.faces.render.Renderer.encodeChildren(Renderer.java:168)

          javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)

          javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)

          javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)

          javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)

          com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)

          com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)

          javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)

          javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)

          com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)

          com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

          com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

          org.apache.myfaces.extensions.cdi.jsf2.impl.listener.phase.CodiLifecycleWrapper.render(CodiLifecycleWrapper.java:126)

          javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

          org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

          • 2. Re: WELD-001305 The given type class org.jboss.weld.bean.SessionBean is not a type of the bean Session bean
            Marko Lukša Apprentice

            You're calling beanManager.getReference(bean, bean.getClass(), context), where bean is an instance of SessionBean.class. You're basically telling beanManager to give you a reference of type SessionBean, which you don't even need.

            The second argument to getReference() should be the type of the bean you are expecting (in your case something like BaseDao).

            • 3. Re: WELD-001305 The given type class org.jboss.weld.bean.SessionBean is not a type of the bean Session bean
              Rafael Pestano Novice

              Thank you Marko!

               

              that was the issue, solved with:

               

              Object o = bm.getReference(bean, bean.getBeanClass(), ctx);   instead of bean.getClass() in second argument