1 2 Previous Next 18 Replies Latest reply on Aug 8, 2011 1:27 AM by nikida78

    Unable to access no-interface EJB that extends an Abstract Impl

    nikida78

      Hi,

       

      I have an EJB (named VehicleFacade) that does not have business interface. This EJB extends an Abstract class (named AbstractFacade) that implements common logic, such as count and findAll. Using a JSF managed bean, i tried to access the EJB, however, all i get is an error that says "View of type x.y.AbstractFacade not found on bean".

       

      This used to work on JBoss 6 Final.

       

      Some codes (generated by Netbeans 7)

       

      public abstract class AbstractFacade<T> {
          ...
          
          int count() {
              ...
          }
      }
      
      @Stateless
      public class VehicleFacade extends AbstractFacade<Vehicle> {
          ...
      }
      
      @Named
      @SessionScoped
      public class WebBean {
          @Inject private VehicleFacade vf;
          
          public int getCount() {
              return vf.count(); //this is where the error is thrown!!!
          }
      }
      

       

      Next I added a business interface (VehicleFacadeLocal) and have my EJB implements it. And I used the JSF managed bean to call it. And it work! My question is, what did i do wrong here, how can i use this Abstract Facade pattern and no-interface EJB in JBoss 7. Is there a bug somewhere?

        • 1. Re: Unable to access no-interface EJB that extends an Abstract Impl
          jaikiran

          Do you have a ejb-jar.xml in your application? If yes, what xsd version does it use in its declaration?

          • 2. Re: Unable to access no-interface EJB that extends an Abstract Impl
            jaikiran

            all i get is an error that says "View of type x.y.AbstractFacade not found on bean".

            Just read this error message again. Are you sure you posted the exact same code that is failing? Can you post the entire exception stacktrace and the real code?

            • 3. Re: Unable to access no-interface EJB that extends an Abstract Impl
              nikida78

              Here are the java codes:

               

              public abstract class AbstractFacade<T> {
                  private Class<T> entityClass;
              
                  public AbstractFacade(Class<T> entityClass) {
                      this.entityClass = entityClass;
                  }
              
                  protected abstract EntityManager getEntityManager();
              
                  ...
                  
                  public int count() {
                      javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
                      javax.persistence.criteria.Root<T> rt = cq.from(entityClass);
                      cq.select(getEntityManager().getCriteriaBuilder().count(rt));
                      javax.persistence.Query q = getEntityManager().createQuery(cq);
                      return ((Long) q.getSingleResult()).intValue();
                  }
              }
              
              @Stateless
              public class VehicleFacade extends AbstractFacade<Vehicle> {
                  @PersistenceContext(unitName = "testfacadePU")
                  private EntityManager em;
              
                  protected EntityManager getEntityManager() {
                      return em;
                  }
              
                  public VehicleFacade() {
                      super(Vehicle.class);
                  }
              
              }
              
              @Named
              @SessionScoped
              public class WebBean implements Serializable {
              
                  @Inject
                  private VehicleFacade vf;
              
                  public int getVehicleCount() {
                      return vf.count();
                  }
              }
              

               

              Here is the stack trace from the server direct...

               

              09:33:16,886 INFO  [org.jboss.as] (Controller Boot Thread) JBoss AS 7.0.0.Final "Lightning" started in 1872ms - Started 101 of 156 services (55 services are passive or on-demand)
              09:34:36,986 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "testfacade.war"
              09:34:37,235 INFO  [org.jboss.jpa] (MSC service thread 1-1) read persistence.xml for testfacadePU
              09:34:37,267 INFO  [org.jboss.weld] (MSC service thread 1-6) Processing CDI deployment: testfacade.war
              09:34:37,275 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named VehicleFacade in deployment unit deployment "testfacade.war" are as follows:
              
                  java:global/testfacade/VehicleFacade!demo.VehicleFacade
                  java:app/testfacade/VehicleFacade!demo.VehicleFacade
                  java:module/VehicleFacade!demo.VehicleFacade
                  java:global/testfacade/VehicleFacade
                  java:app/testfacade/VehicleFacade
                  java:module/VehicleFacade
              
              09:34:37,407 INFO  [org.jboss.weld] (MSC service thread 1-8) Starting Services for CDI deployment: testfacade.war
              09:34:37,432 INFO  [org.jboss.weld.Version] (MSC service thread 1-8) WELD-000900 1.1.2 (AS7)
              09:34:37,451 INFO  [org.jboss.weld] (MSC service thread 1-1) Starting weld service
              09:34:37,451 INFO  [org.jboss.jpa] (MSC service thread 1-6) starting Persistence Unit Service 'testfacade.war#testfacadePU' 
              09:34:37,549 INFO  [org.hibernate.annotations.common.Version] (MSC service thread 1-6) Hibernate Commons Annotations 3.2.0.Final
              09:34:37,553 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH00412:Hibernate [WORKING]
              09:34:37,555 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH00206:hibernate.properties not found
              09:34:37,556 INFO  [org.hibernate.cfg.Environment] (MSC service thread 1-6) HHH00021:Bytecode provider name : javassist
              09:34:37,570 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-6) HHH00204:Processing PersistenceUnitInfo [
                  name: testfacadePU
                  ...]
              09:34:37,602 WARN  [org.hibernate.cfg.AnnotationBinder] (MSC service thread 1-6) HHH00194:Package not found or wo package-info.java: demo
              09:34:37,673 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-6) HHH00130:Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
              09:34:37,788 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-6) HHH00400:Using dialect: org.hibernate.dialect.SQLServer2008Dialect
              09:34:37,795 INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-6) HHH00423:Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
              09:34:37,801 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-6) HHH00268:Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
              09:34:37,804 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-6) HHH00397:Using ASTQueryTranslatorFactory
              09:34:37,832 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-6) Hibernate Validator 4.1.0.Final
              09:34:37,837 INFO  [org.hibernate.validator.engine.resolver.DefaultTraversableResolver] (MSC service thread 1-6) Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
              09:34:38,046 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) Initializing Mojarra 2.0.4 (FCS b09-jbossorg-4) for context '/testfacade'
              09:34:38,606 INFO  [org.jboss.web] (MSC service thread 1-3) registering web context: /testfacade
              09:34:38,637 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "testfacade.war"
              09:35:00,607 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) Error Rendering View[/index.xhtml]: javax.el.ELException: /index.xhtml @9,72 value="#{webBean.vehicleCount}": java.lang.IllegalArgumentException: View of type class demo.AbstractFacade not found on bean 
                  at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at javax.faces.component.UIOutput.getValue(UIOutput.java:169) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:67) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
                  at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at java.lang.Thread.run(Thread.java:662) [:1.6.0_25]
              Caused by: java.lang.IllegalArgumentException: View of type class demo.AbstractFacade not found on bean 
                  at org.jboss.as.weld.ejb.SessionObjectReferenceImpl.getBusinessObject(SessionObjectReferenceImpl.java:73) [jboss-as-weld-7.0.0.Final.jar:7.0.0.Final]
                  at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:122) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                  at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:62) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                  at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                  at demo.VehicleFacade$Proxy$_$$_Weld$Proxy$.count(VehicleFacade$Proxy$_$$_Weld$Proxy$.java) [classes:]
                  at demo.WebBean.getVehicleCount(WebBean.java:24) [classes:]
                  at demo.WebBean$Proxy$_$$_WeldClientProxy.getVehicleCount(WebBean$Proxy$_$$_WeldClientProxy.java) [classes:]
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_25]
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_25]
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_25]
                  at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_25]
                  at javax.el.BeanELResolver.getValue(BeanELResolver.java:302) [jboss-el-api_2.2_spec-1.0.0.Final.jar:1.0.0.Final]
                  at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  at org.apache.el.parser.AstValue.getValue(AstValue.java:134) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:187) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
                  at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:55) [weld-core-1.1.2.AS7.jar:2011-07-06 12:26]
                  at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
                  ... 34 more
              
              

               

              Thanks for helping

              • 4. Re: Unable to access no-interface EJB that extends an Abstract Impl
                swd847

                This looks like the underlying cause is https://issues.jboss.org/browse/WELD-921

                 

                I'll look into this and see if there is any way to work around it.

                • 5. Re: Unable to access no-interface EJB that extends an Abstract Impl
                  nikida78

                  This used to work in JBoss 6... so something has broken... hopefully it will get fixed soon.

                  • 6. Re: Unable to access no-interface EJB that extends an Abstract Impl
                    swd847

                    I have fixed this in upstream. For now you have two options to work around it:

                     

                    Override the method in the sub class with a method that just calls super()

                     

                    Build AS7 yourself from upstream until 7.0.1 is out.

                    1 of 1 people found this helpful
                    • 7. Re: Unable to access no-interface EJB that extends an Abstract Impl
                      nikida78

                      Great, thanks!

                      • 8. Re: Unable to access no-interface EJB that extends an Abstract Impl
                        ringerc

                        This looks quite a bit like a bug fixed in Glassfish a while ago (http://java.net/jira/browse/GLASSFISH-13040) . I'm certainly triggering it (or a different bug with the same error, perhaps) the same way. I'm injecting a local no-interface view of a @Stateless EJB that extends an abstract superclass. Method invocations on the local no-interface view proxy generated by Weld result in errors like:

                         

                        15:02:44,265 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) Error Rendering View[/AdEdit.xhtml]: javax.el.ELException: /AdEdit.xhtml @49,108 value="#{adEditController.sections}": java.lang.IllegalArgumentException: View of type class au.com.postnewspapers.classads.persistence.facade.AbstractFacade not found on bean

                         

                        Does it sound like the same issue, or shall I file a separate bug with a test case?

                         

                        I'm building jboss git master to test against at the moment. Unfortunately I'm on an ADSL2+ connection that's been shaped down to 256k due to bandwidth use, so I'll be running that maven first build for quite some time and won't be able to offer any result until it finally finishes downloading dependencies.

                        • 9. Re: Unable to access no-interface EJB that extends an Abstract Impl
                          jaikiran

                          Craig Ringer wrote:

                           

                          I'm building jboss git master to test against at the moment. Unfortunately I'm on an ADSL2+ connection that's been shaped down to 256k due to bandwidth use, so I'll be running that maven first build for quite some time and won't be able to offer any result until it finally finishes downloading dependencies.

                          You can download the nightly build binaries of AS7. See this for more info http://community.jboss.org/thread/167590

                          • 10. Re: Unable to access no-interface EJB that extends an Abstract Impl
                            ringerc

                            Ah, thanks. I should've thought of that. Only an hour to download this way ... and tomorrow I get my civilized 8MBit ADSL2+ back.

                             

                            I've assembled a simple test case that fails on JBoss AS 7 that pretty much confirms I'm hitting the same bug, but I'll test it with the nightly shortly anyway.

                             

                            It strikes me that if this bug made it into AS 7 final, some more test cases are needed around inheritance in EJBs (and probably in CDI managed beans, too). Once I can build AS7 I'll look into writing a patch with some appropriate tests based on variants of my test case.

                            • 11. Re: Unable to access no-interface EJB that extends an Abstract Impl
                              jaikiran

                              Craig Ringer wrote:

                               

                               

                              It strikes me that if this bug made it into AS 7 final, some more test cases are needed around inheritance in EJBs (and probably in CDI managed beans, too). Once I can build AS7 I'll look into writing a patch with some appropriate tests based on variants of my test case.

                              Thanks! That'll really help.

                              • 12. Re: Unable to access no-interface EJB that extends an Abstract Impl
                                swd847

                                I have already added a test for this case when I fixed it in upstream, but more tests are always welcome.

                                • 13. Re: Unable to access no-interface EJB that extends an Abstract Impl
                                  nikida78

                                  Sorry, a noob question here, can I test against the latest nightly build to try you fix? Or do I have to build it myself?

                                  • 14. Re: Unable to access no-interface EJB that extends an Abstract Impl
                                    ringerc

                                    The fix is in the nightly builds. My app deploys against the latest nightly fine, where it failed on AS 7.0.0 .

                                    1 2 Previous Next