5 Replies Latest reply on Apr 16, 2010 8:57 AM by Jimmy Shine

    Why can not inject EJB to WebBean?

    Jimmy Shine Newbie
      When I use Weld with EJB.
      The codes below:

      @Qualifier
      @Retention(RUNTIME)
      @Target( { TYPE, METHOD, FIELD, PARAMETER, PACKAGE })
      public @interface Framework {

      }


      public class AttachmentDao{
         @PersistenceContext(unitName = "Vaalhaai")
         private EntityManager em;
      }

      @Stateless
      @LocalBean
      @Framework
      public class AttachmentService{
          @Inject private AttachmentDao attachmentDao;
      }

      public class AttachmentAction{
          @Inject @Framework private AttachementService attachmentService;
      }

      The error is:
      ERROR [AbstractKernelController] Error installing to Start: name=vfszip:/D:/jboss-6.0.0.M2/server/default/deploy/vaalhaai.war/_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Injection point has unsatisfied dependencies.  Injection point:  field com.vaalhaai.framework.attachs.web.AttachmentAction.attachmentService;  Qualifiers:  [@com.vaalhaai.framework.annotation.Framework()]

      Can any one told me why?
        • 1. Re: Why can not inject EJB to WebBean?
          Jimmy Shine Newbie

          I used JBoss6.0 M2 to run it!

          • 2. Re: Why can not inject EJB to WebBean?
            John Ament Master

            Try using @EJB.  Do you know what version of weld you're using?  I know there are some issues w/ EJB integration and I believe this is one of them.

            • 3. Re: Why can not inject EJB to WebBean?
              Jimmy Shine Newbie
              Thanks for your reply, John.

              First,I used Weld1.0.1 Final.

              I had been tried use @EJB to inject the session bean, it had no problem on start the JBoss6.0M2.
              But when I used the attachmentAction in JSF pages.
              The JSF page is:

              <h:form>
                   <h:outputText value="#{attachmentAction.message}"></h:outputText>
                   <h:inputText value="#{attachmentAction.attachment.name}"/>
                   <h:commandButton value="Add" action="#{attachmentAction.add}" />
              </h:form>


              The error like these below:
              [javax.enterprise.resource.webcontainer.jsf.application] Error Rendering View[/view/framework/attachs/add.xhtml]: javax.el.ELException: /view/framework/attachs/add.xhtml @11,52 value="#{attachmentAction.message}": org.jboss.ejb3.common.resolvers.spi.UnresolvableReferenceException: Could not resolve reference [EJB Reference: beanInterface 'com.vaalhaai.framework.attachs.service.AttachmentService', beanName '', mappedName 'null'] in AbstractVFSDeploymentContext@19807859{vfszip:/D:/jboss-6.0.0.M2/server/default/deploy/vaalhaai.war/}
                   at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:107)
                   at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
                   at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
                   at javax.faces.component.UIOutput.getValue(UIOutput.java:168)
                   at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
                   at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338)
                   at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
                   at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
                   at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
                   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
                   at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
                   at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
                   at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
                   at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
                   at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
                   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
                   at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:336)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
                   at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:66)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:274)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)
                   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:276)
                   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)
                   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)
                   at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                   at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
                   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:872)
                   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
                   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
                   at java.lang.Thread.run(Thread.java:619)

              I relly know how to inject the ejb to the webbean.
              I had read the replies that Gavin King said, had @LocalBean annotation to the stateless ejb.

              Thanks!
              • 4. Re: Why can not inject EJB to WebBean?
                Pete Muir Master

                JBoss AS 6 M2 still has some issues with no-interface view EJBs, hence why this isn't working for you. It doesn't look like this is fixed for M3 either, but will be for M4 I hope.


                Anyway, just add a local interface.

                • 5. Re: Why can not inject EJB to WebBean?
                  Jimmy Shine Newbie

                  Thanks for Pete!
                  In fact,now I changed my project used SSH now.
                  Hope the JBoss AS 6 RC will fixed it.