6 Replies Latest reply on Feb 7, 2011 10:56 AM by Andrew Geery

    JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found

    Andrew Geery Newbie
      I have an application which runs fine in JBoss 4.2.3 with Seam 2.2.1.Final.

      I was hoping I would be able to take it and run it in JBoss 6.  The application starts without any errors.  However, when I attempt to log in to it (via the jpa-identity-store component), I see the following warning:

      17:38:03,788 WARN  [org.hibernate.hql.QuerySplitter] no persistent classes found for query class: select u from com.acme.Operator u where username = :username
      17:38:03,788 WARN  [org.jboss.seam.security.jaas.SeamLoginModule] Error invoking login method

      Observing the login failure, I attempt to use a named query and I get the following error:

      java.lang.IllegalArgumentException: Named query not found: loadOperatorByUsername

      In both cases, I see log info indicating that both annotations have been processd by Hibernate:

      17:36:26,551 INFO  [org.hibernate.cfg.AnnotationBinder] Binding entity from annotated class: com.acme.Operator
      17:36:26,551 INFO  [org.hibernate.cfg.annotations.QueryBinder] Binding Named query: loadOperatorByUsername => select op from Operator op where op.username = :username

      My web app is a war with my annotated entity classes in one jar and my Seam-related classes in another.  It appears that there is some classloader issue with AS 6 or Seam.  Any ideas?

      Thanks
      Andrew

      PS I also get the error with Seam 2.2.1.CR3
        • 1. Re: JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found
          Marek Novotny Newbie

          Andrew,


          what is the content of war file in war/WEB-INF/lib directory?


          Included jars matter. JBoss AS 6 has got different Hibernate core than Seam and JBoss AS 4.2.3.

          • 2. Re: JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found
            Andrew Geery Newbie

            Hi, Marek


            If the app didn't start up at all, I would understand.  However, it seems strange that, at least according to the log, all of the entities were found and the named queries parsed; that's what makes the errors perplexing. 


            Anyway, here's the list:


            antlr-runtime-3.1.1.jar
            commons-lang-2.5.jar
            core-3.4.2.v883R34x.jar
            drools-api-5.0.1.jar
            drools-compiler-5.0.1.jar
            drools-core-5.0.1.jar
            janino-2.5.15.jar
            jboss-el-1.002.CR5.jar
            jboss-envers-1.2.2.GA-hibernate-3.3.jar
            jboss-seam-2.2.1.Final.jar
            joda-time-1.6.2.jar
            mvel2-2.0.10.jar
            xpp3
            min-1.1.3.4.O.jar
            xstream-1.3.1.jar


            Thanks
            Andrew

            • 3. Re: JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found
              Marek Novotny Newbie

              Ok,
              I can understand your view, anyway there is a situation that JBoss AS 6 is integrated with hibernate 3.6.0.Final and there are incompatible changes between 3.3.x and 3.6.


              I can see that you are using Envers, try to upgrade it to version which is in Hibernate 3.6.0 release. Then if that doesn't help, set up DEBUG log level and paste a full stack trace, please.


              • 4. Re: JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found
                Andrew Geery Newbie
                Removing the envers jar did not help. 

                There is no stack trace when seam security fails to find the Operator class; there's just a warning.  Here's the context:

                2011-01-31 17:13:58,746 DEBUG [org.hibernate.impl.SessionImpl] (http-localhost%2F127.0.0.1-8080-1) opened session at timestamp: 12965120387
                2011-01-31 17:13:58,747 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] (http-localhost%2F127.0.0.1-8080-1) Looking for a JTA transaction to join
                2011-01-31 17:13:58,747 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] (http-localhost%2F127.0.0.1-8080-1) No JTA transaction found
                2011-01-31 17:13:58,755 DEBUG [org.jboss.seam.persistence.ManagedPersistenceContext] (http-localhost%2F127.0.0.1-8080-1) created seam managed persistence context from EntityManagerFactory
                2011-01-31 17:13:58,756 DEBUG [org.jboss.seam.util.Naming] (http-localhost%2F127.0.0.1-8080-1) JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
                2011-01-31 17:13:58,762 WARN  [org.hibernate.hql.QuerySplitter] (http-localhost%2F127.0.0.1-8080-1) no persistent classes found for query class: select u from com.acme.Operator u where username = :username

                Here's the stacktrace from not finding the named query:

                java.lang.IllegalArgumentException: Named query not found: loadOperatorByUsername
                     at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:455)
                     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.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:46)
                     at $Proxy230.createNamedQuery(Unknown Source)
                     at com.myersinfosys.beast.server.session.AuthenticationObserver.loginFailed(AuthenticationObserver.java:69)
                     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:22)
                     at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                     at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.granite.tide.seam.TideInterceptor.aroundInvoke(TideInterceptor.java:170)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
                     at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
                     at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
                     at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                     at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                     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:107)
                     at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
                     at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
                     at com.acme.AuthenticationObserver_$$_javassist_seam_3.loginFailed(AuthenticationObserver_$$_javassist_seam_3.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.seam.util.Reflections.invoke(Reflections.java:22)
                     at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
                     at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
                     at org.jboss.seam.core.Events.raiseEvent(Events.java:85)
                     at org.granite.tide.seam.TideEvents.raiseEvent(TideEvents.java:69)
                     at org.granite.seam21.security.Seam21SecurityService.login(Seam21SecurityService.java:90)
                     at org.granite.messaging.amf.process.AMF3MessageProcessor.processCommandMessage(AMF3MessageProcessor.java:94)
                     at org.granite.messaging.amf.process.AMF3MessageProcessor.process(AMF3MessageProcessor.java:61)
                     at org.granite.messaging.amf.process.AMF0MessageProcessor.process(AMF0MessageProcessor.java:78)
                     at org.granite.messaging.webapp.AMFEndpoint.service(AMFEndpoint.java:73)
                     at org.granite.seam21.FlexFilter.doFilter(FlexFilter.java:242)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                     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:45)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                     at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
                     at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                     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:275)
                     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)
                     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
                     at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)
                     at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)
                     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)
                     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)
                     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.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)
                     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
                     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
                     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)
                     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
                     at java.lang.Thread.run(Thread.java:619)
                • 5. Re: JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found
                  Marek Novotny Newbie

                  hmm, without your source code I can't say anything smarter than have you tried to bundle entity classes and Seam related code to one jar in war?


                  • 6. Re: JBoss 6 & Seam 2.2.1.Final: persistent classes and named queries not found
                    Andrew Geery Newbie
                    I tracked the problem down to this issue: https://issues.jboss.org/browse/JBSEAM-3821

                    Basically, how the PU gets loaded changed starting with AS 5.  What's weird/misleading about the problem is that the AS sees the entities [it reports all of the entities it finds], but Seam cannot. 

                    To fix the problem, it is necessary to set up a JNDI name for the PU in the persistence.xml file, reference this name when you create the persistence:managed-persistence-context in components.xml *and* set the persistence:entity-manager-factory to *not* be installed.

                    Thanks
                    Andrew