1 2 Previous Next 17 Replies Latest reply on Feb 20, 2008 3:55 PM by danielc.roth

    Problem. Code error. ...No entity found for query

    pericles

      Hi all again, ;)


      I have a code problem, I don't know why appears an error in my learning application with Seam.


      This is the error:


      javax.el.ELException: /layout/menu.xhtml @15,26 rendered="#{secureHome.comprovaPermisTrue()}": javax.ejb.EJBTransactionRolledbackException: No entity found for query


      And in line 15, my menu.xhtml have this.


      <s:link view="/UsuarisList.xhtml"
            value="Usuaris List"
            rendered="#{secureHome.comprovaPermisTrue()}"
      propagation="none"/>


      Obviously, I think the error is in secureHome.comprovaPermisTrue method but I don't found any mistake. This is the method:



      public boolean comprovaPermisTrue() {
               
      
           Object o = entityManager.createQuery("SELECT usu FROM Usuaris usu WHERE id=?1").setParameter(1, identity
                         .getUsername())
                         .getSingleResult();
      
           userType = ((Usuaris)objeto).getTipusUsuaris().getId();
      
           if (userType.equalsIgnoreCase("O")) {
           return true;
           }
           else {
              return false;
           }
          
      }



      And I import correctly, I hope, the Query library:



      import javax.persistence.Query;





      Can anybody found my mistake? Thanks a lot.

        • 1. Re: Problem. Code error. ...No entity found for query
          pmuir

          Post the entity and the full stack trace.

          • 2. Re: Problem. Code error. ...No entity found for query
            pericles

            What entity? In fact I don't know what Entity is referenced in the error. :(


            The stack trace is this:


            javax.faces.FacesException: javax.el.ELException: /layout/menu.xhtml @15,26 rendered="#{secureHome.comprovaPermisTrue()}": javax.ejb.EJBTransactionRolledbackException: No entity found for query
                 at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:373)
                 at org.richfaces.renderkit.html.ToolBarRendererBase.encodeChildren(ToolBarRendererBase.java:58)
                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                 at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                 at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                 at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                 at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                 at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                 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:157)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                 at java.lang.Thread.run(Thread.java:619)
            Caused by: javax.el.ELException: /layout/menu.xhtml @15,26 rendered="#{secureHome.comprovaPermisTrue()}": javax.ejb.EJBTransactionRolledbackException: No entity found for query
                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
                 at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:370)
                 ... 48 more
            Caused by: javax.ejb.EJBTransactionRolledbackException: No entity found for query
                 at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
                 at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
                 at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                 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:110)
                 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.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
                 at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
                 at $Proxy349.comprovaPermisTrue(Unknown Source)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                 at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                 at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                 at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
                 at org.javassist.tmp.java.lang.Object_$$_javassist_1.comprovaPermisTrue(Object_$$_javassist_1.java)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
                 at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:273)
                 at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
                 at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                 at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                 at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                 ... 49 more
            Caused by: javax.persistence.NoResultException: No entity found for query
                 at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:82)
                 at es.gematic.gucudo.session.SecureHomeBean.comprovaPermisTrue(SecureHomeBean.java:81)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: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.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                 at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                 at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:597)
                 at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                 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.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                 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)
                 at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                 at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                 ... 90 more


            • 3. Re: Problem. Code error. ...No entity found for query
              christian.bauer

              Read this free book chapter: http://www.manning.com/bauer2/chapter2.pdf

              • 4. Re: Problem. Code error. ...No entity found for query
                pericles

                LOL!


                Well... 69 pages of Java Persistence with Hibernate tutorial?... emm... thanks a lot but... I hope to find an more directly answer than read 69 pages... but, but... thanks. ;)

                • 5. Re: Problem. Code error. ...No entity found for query
                  christian.bauer

                  Well, the short answer is that you don't know what a persistent entity is, or that the query language you are supposed to use is not SQL. That, in fact, you don't seem to know the basics of Java Persistence at all.

                  • 6. Re: Problem. Code error. ...No entity found for query

                    What happens if you try this instead:



                    Object o = entityManager.createQuery("SELECT usu FROM Usuaris usu WHERE usu.username = :username").setParameter("username", identity
                                       .getUsername())
                                       .getSingleResult();



                    • 7. Re: Problem. Code error. ...No entity found for query
                      pericles

                      Ok, well... I go to read it.


                      PD: Any short answer will be wellcome. :)

                      • 8. Re: Problem. Code error. ...No entity found for query
                        pericles

                        Hi, thanks, I prove it in this way:



                                 Object obj = entityManager.createQuery("SELECT usu FROM Usuaris usu WHERE usu.id=?1")
                                 .setParameter(1, identity.getUsername())
                                 .getSingleResult();
                                 
                                 
                                 
                                 this.userType = ((Usuaris)obj).getTipusUsuaris().getId();




                        But it doesn't work.


                        javax.faces.FacesException: javax.el.ELException: /layout/menu.xhtml @15,26 rendered="#{secureHome.comprovaPermisTrue()}": javax.ejb.EJBTransactionRolledbackException: No entity found for query
                             at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:373)
                             at org.richfaces.renderkit.html.ToolBarRendererBase.encodeChildren(ToolBarRendererBase.java:58)
                             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                             at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                             at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                             at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                             at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                             at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                             at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                             at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                             at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                             at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                             at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                             at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                             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:157)
                             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                             at java.lang.Thread.run(Thread.java:619)
                        Caused by: javax.el.ELException: /layout/menu.xhtml @15,26 rendered="#{secureHome.comprovaPermisTrue()}": javax.ejb.EJBTransactionRolledbackException: No entity found for query
                             at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
                             at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:370)
                             ... 48 more
                        Caused by: javax.ejb.EJBTransactionRolledbackException: No entity found for query
                             at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
                             at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
                             at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                             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:110)
                             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.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
                             at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
                             at $Proxy259.comprovaPermisTrue(Unknown Source)
                             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                             at java.lang.reflect.Method.invoke(Method.java:597)
                             at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                             at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                             at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                             at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                             at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
                             at org.javassist.tmp.java.lang.Object_$$_javassist_1.comprovaPermisTrue(Object_$$_javassist_1.java)
                             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                             at java.lang.reflect.Method.invoke(Method.java:597)
                             at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
                             at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:273)
                             at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
                             at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                             at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                             at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                             ... 49 more
                        Caused by: javax.persistence.NoResultException: No entity found for query
                             at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:82)
                             at es.gematic.gucudo.session.SecureHomeBean.comprovaPermisTrue(SecureHomeBean.java:80)
                             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: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.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                             at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
                             at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                             at java.lang.reflect.Method.invoke(Method.java:597)
                             at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                             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.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                             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)
                             at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                             at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                             ... 90 more


                        • 9. Re: Problem. Code error. ...No entity found for query

                          'javax.persistence.NoResultException: No entity found for query' means that you made a query that returned no result. That would mean that the WHERE clause is too restrictive.


                          Please paste the code for Usaris. Does 'id' actually hold the username?

                          • 10. Re: Problem. Code error. ...No entity found for query
                            christian.bauer

                            No, it does not mean no result. It means that there is no mapped entity class of that name.

                            • 11. Re: Problem. Code error. ...No entity found for query

                              Christian: I think you're wrong.


                              This query below gives me a job object back:


                              Job j = (Job) em.createQuery("SELECT j FROM Job j WHERE j.id = :id").setParameter("id", id).getSingleResult();
                              


                              iff I set id to an id that actually exists.


                              If I set Id to an id that does not exist in the database i get:


                              'javax.persistence.NoResultException: No entity found for query'


                              Hence, Job is a mapped entity, but given a query that return no result gives the error message above.


                              • 12. Re: Problem. Code error. ...No entity found for query
                                pericles

                                Christian Bauer wrote on Feb 20, 2008 01:27 PM:


                                No, it does not mean no result. It means that there is no mapped entity class of that name.


                                Oh, I don't mapped it correctly?


                                This is the Entity:



                                import java.util.HashSet;
                                import java.util.Set;
                                import javax.persistence.CascadeType;
                                import javax.persistence.Column;
                                import javax.persistence.Entity;
                                import javax.persistence.FetchType;
                                import javax.persistence.Id;
                                import javax.persistence.JoinColumn;
                                import javax.persistence.ManyToOne;
                                import javax.persistence.OneToMany;
                                import javax.persistence.Table;
                                import org.hibernate.validator.Length;
                                import org.hibernate.validator.NotNull;
                                
                                /**
                                 * Usuaris generated by hbm2java
                                 */
                                @Entity
                                @Table(name = "USUARIS")
                                public class Usuaris implements java.io.Serializable {
                                
                                     private String id;
                                     private TipusUsuaris tipusUsuaris;
                                     private String nom;
                                     private String cognoms;
                                     private String cif;
                                     private Set<Accions> accionses = new HashSet<Accions>(0);
                                     private Set<PermisosDocument> permisosDocuments = new HashSet<PermisosDocument>(
                                               0);
                                     private Set<Signatures> signaturesesForIdUsuariDep = new HashSet<Signatures>(
                                               0);
                                     private Set<PermisosTipologia> permisosTipologias = new HashSet<PermisosTipologia>(
                                               0);
                                     private Set<Signatures> signaturesesForIdUsuari = new HashSet<Signatures>(0);
                                     private Set<Documents> documentses = new HashSet<Documents>(0);
                                
                                     public Usuaris() {
                                     }
                                
                                     public Usuaris(String id) {
                                          this.id = id;
                                     }
                                
                                     public Usuaris(String id, TipusUsuaris tipusUsuaris, String nom,
                                               String cognoms, String cif, Set<Accions> accionses,
                                               Set<PermisosDocument> permisosDocuments,
                                               Set<Signatures> signaturesesForIdUsuariDep,
                                               Set<PermisosTipologia> permisosTipologias,
                                               Set<Signatures> signaturesesForIdUsuari, Set<Documents> documentses) {
                                          this.id = id;
                                          this.tipusUsuaris = tipusUsuaris;
                                          this.nom = nom;
                                          this.cognoms = cognoms;
                                          this.cif = cif;
                                          this.accionses = accionses;
                                          this.permisosDocuments = permisosDocuments;
                                          this.signaturesesForIdUsuariDep = signaturesesForIdUsuariDep;
                                          this.permisosTipologias = permisosTipologias;
                                          this.signaturesesForIdUsuari = signaturesesForIdUsuari;
                                          this.documentses = documentses;
                                     }
                                
                                     @Id
                                     @Column(name = "ID", unique = true, nullable = false)
                                     @NotNull
                                     public String getId() {
                                          return this.id;
                                     }
                                
                                     public void setId(String id) {
                                          this.id = id;
                                     }
                                
                                     @ManyToOne(fetch = FetchType.LAZY)
                                     @JoinColumn(name = "ID_TIPUS")
                                     public TipusUsuaris getTipusUsuaris() {
                                          return this.tipusUsuaris;
                                     }
                                
                                     public void setTipusUsuaris(TipusUsuaris tipusUsuaris) {
                                          this.tipusUsuaris = tipusUsuaris;
                                     }
                                
                                     @Column(name = "NOM", length = 50)
                                     @Length(max = 50)
                                     public String getNom() {
                                          return this.nom;
                                     }
                                
                                     public void setNom(String nom) {
                                          this.nom = nom;
                                     }
                                
                                     @Column(name = "COGNOMS", length = 100)
                                     @Length(max = 100)
                                     public String getCognoms() {
                                          return this.cognoms;
                                     }
                                
                                     public void setCognoms(String cognoms) {
                                          this.cognoms = cognoms;
                                     }
                                
                                     @Column(name = "CIF", length = 9)
                                     @Length(max = 9)
                                     public String getCif() {
                                          return this.cif;
                                     }
                                
                                     public void setCif(String cif) {
                                          this.cif = cif;
                                     }
                                
                                     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "usuaris")
                                     public Set<Accions> getAccionses() {
                                          return this.accionses;
                                     }
                                
                                     public void setAccionses(Set<Accions> accionses) {
                                          this.accionses = accionses;
                                     }
                                
                                     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "usuaris")
                                     public Set<PermisosDocument> getPermisosDocuments() {
                                          return this.permisosDocuments;
                                     }
                                
                                     public void setPermisosDocuments(Set<PermisosDocument> permisosDocuments) {
                                          this.permisosDocuments = permisosDocuments;
                                     }
                                
                                     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "usuarisByIdUsuariDep")
                                     public Set<Signatures> getSignaturesesForIdUsuariDep() {
                                          return this.signaturesesForIdUsuariDep;
                                     }
                                
                                     public void setSignaturesesForIdUsuariDep(
                                               Set<Signatures> signaturesesForIdUsuariDep) {
                                          this.signaturesesForIdUsuariDep = signaturesesForIdUsuariDep;
                                     }
                                
                                     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "usuaris")
                                     public Set<PermisosTipologia> getPermisosTipologias() {
                                          return this.permisosTipologias;
                                     }
                                
                                     public void setPermisosTipologias(Set<PermisosTipologia> permisosTipologias) {
                                          this.permisosTipologias = permisosTipologias;
                                     }
                                
                                     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "usuarisByIdUsuari")
                                     public Set<Signatures> getSignaturesesForIdUsuari() {
                                          return this.signaturesesForIdUsuari;
                                     }
                                
                                     public void setSignaturesesForIdUsuari(
                                               Set<Signatures> signaturesesForIdUsuari) {
                                          this.signaturesesForIdUsuari = signaturesesForIdUsuari;
                                     }
                                
                                     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "usuaris")
                                     public Set<Documents> getDocumentses() {
                                          return this.documentses;
                                     }
                                
                                     public void setDocumentses(Set<Documents> documentses) {
                                          this.documentses = documentses;
                                     }
                                
                                }
                                


                                • 13. Re: Problem. Code error. ...No entity found for query
                                  pericles

                                  In fact, this Entity was generated by Seam Generated Entities, maybe this is important.

                                  • 14. Re: Problem. Code error. ...No entity found for query
                                    christian.bauer

                                    OK, my bad. I didn't realize this is the crappy javax.persistence exception. So yes, the query is returning nothing.


                                    The correct message should be no entity instance found for query, because entity depicts a type, not a value. As an excuse I can only offer that the native Hibernate exception for a missing mapped entity would be can not find entity.

                                    1 2 Previous Next