7 Replies Latest reply on Dec 14, 2004 12:40 PM by ulfreich

    Hibernate.har in myHibernateEar.ear 'no persistent classes'

    beyarecords Novice

      Hi,
      I am deploying an Hibernate.har file from within an .ear file as follows:

      myHibernateEar.ear:
      -META-INF/application.xml,jboss-app.xml
      -hibernate.har/test/*.class,*.hbm.xml
      -hibernate.har/META-INF/hibernate-service.xml
      -hibernate.har/hibernate.cfg.xml

      jboss-app.xml:

      <?xml version="1.0"?>
      
      <jboss-app>
       <loader-repository>hibernate:loader=myHibernateEar.ear</loader-repository>
       <module>
       <har>hibernate.har</har>
       </module>
      </jboss-app>
      


      application.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <application>
       <display-name>beyarecords</display-name>
       <description>beyarecords</description>
      
       <module>
       <connector>hibernate.har</connector>
       </module>
      
      </application>
      


      for which I get the following message in the logs:

      02:03:33,611 INFO [EARDeployer] Init J2EE application: file:/Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/
      02:03:33,820 INFO [Environment] Hibernate 2.1.5
      02:03:33,830 INFO [Environment] hibernate.properties not found
      02:03:33,835 INFO [Environment] using CGLIB reflection optimizer
      02:03:33,859 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/Artist.hbm.xml
      02:03:34,037 INFO [Binder] Mapping class: test.Artist -> artisttbl
      02:03:34,249 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/ArtistImages.hbm.xml
      02:03:34,265 INFO [Binder] Mapping class: test.ArtistImages -> artistimagestbl
      02:03:34,272 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/Order.hbm.xml
      02:03:34,297 INFO [Binder] Mapping class: test.Order -> orderstbl
      02:03:34,345 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/OrderItem.hbm.xml
      02:03:34,376 INFO [Binder] Mapping class: test.OrderItem -> orderitemstbl
      02:03:34,378 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/Stock.hbm.xml
      02:03:34,399 INFO [Binder] Mapping class: test.Stock -> stocktbl
      02:03:34,408 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/StockImages.hbm.xml
      02:03:34,422 INFO [Binder] Mapping class: test.StockImages -> stockimagestbl
      02:03:34,423 INFO [Configuration] Mapping file: /Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/hibernate.har/test/User.hbm.xml
      02:03:34,461 INFO [Binder] Mapping class: test.User -> usertbl
      02:03:34,467 INFO [Binder] Mapping collection: test.User.ArtistChoice -> choicetbl
      02:03:34,468 INFO [Configuration] processing one-to-many association mappings
      02:03:34,469 INFO [Binder] Mapping collection: test.Order.OrderItems -> orderitemstbl
      02:03:34,470 INFO [Binder] Mapping collection: test.Stock.StockImages -> stockimagestbl
      02:03:34,472 INFO [Configuration] processing one-to-one association property references
      02:03:34,472 INFO [Configuration] processing foreign key constraints
      02:03:34,567 INFO [Dialect] Using dialect: net.sf.hibernate.dialect.PostgreSQLDialect
      02:03:34,572 INFO [SettingsFactory] Use outer join fetching: true
      02:03:34,587 INFO [NamingHelper] JNDI InitialContext properties:{}
      02:03:34,596 INFO [DatasourceConnectionProvider] Using datasource: java:/PostgresDS
      02:03:34,600 INFO [TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
      02:03:34,602 INFO [NamingHelper] JNDI InitialContext properties:{}
      02:03:34,606 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
      02:03:34,607 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      02:03:34,608 INFO [NamingHelper] JNDI InitialContext properties:{}
      02:03:34,610 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
      02:03:34,611 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
      02:03:34,774 INFO [SettingsFactory] Use scrollable result sets: true
      02:03:34,774 INFO [SettingsFactory] Use JDBC3 getGeneratedKeys(): false
      02:03:34,775 INFO [SettingsFactory] Optimize cache for minimal puts: false
      02:03:34,775 INFO [SettingsFactory] echoing all SQL to stdout
      02:03:34,776 INFO [SettingsFactory] Query language substitutions: {}
      02:03:34,776 INFO [SettingsFactory] cache provider: net.sf.ehcache.hibernate.Provider
      02:03:34,786 INFO [Configuration] instantiating and configuring caches
      02:03:34,824 WARN [Configurator] No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/Library/jboss-4.0.0/server/default/lib/ehcache-1.0.jar!/ehcache-failsafe.xml

      But when I runs the following code:

      InitialContext ctx = new InitialContext();
      transaction = (UserTransaction)ctx.lookup("java:/UserTransaction");
      transaction.begin();

      session = HibernateContext.getSession("java:/hibernate/SessionFactory");
      //Get User details
      query = session.createQuery("from test.User as user where user.UserName=:username and user.UserPassword=:password")
      .setString("username",username)
      .setString("password",password);
      user = (User) query.uniqueResult();

      transaction.commit();

      I now get the following error message in the logs:

      02:05:17,430 WARN [QueryTranslator] no persistent classes found for query class: from test.User as user where user.UserName=:username and user.UserPassword=:password

      As I already have a test/*.class, test/*.hbm.xml defined in the ear document, as can be seen in the log read out, what am I missing here?

      regards


      Andrew

        • 1. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
          Dave Smith Newbie

          I have found that classes and jar files with the hibernate package need to go out side the scope of the .har file. So put your .hbm.xml in the ha4r and the class inside a jar at the ear level not the .har.

          • 2. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
            beyarecords Novice

            rimmeraj,
            I tried your suggestion but got mapping exceptions because the persistent classes could not be found. Apart from being able to use managed transactions, what are the benefits of running hibernate behind an ejb? Is there any performance/operational benefit? If not, i'm going to use hibernate.har in the deploy directory as all ejb configuration types I have tried do not work.

            many thanks

            Andrew

            • 3. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
              beyarecords Novice

              the error that I should have mentioned in my last post was:

              MBeans waiting for other MBeans:
              ObjectName: jboss.har:service=Hibernate
              state: FAILED
              I Depend On: jboss.jca:service=RARDeployer
              jboss.jca:name=PostgresDS,service=LocalTxCM

              Depends On Me: net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: persistent class [test.Artist] not found

              MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
              ObjectName: jboss.har:service=Hibernate
              state: FAILED
              I Depend On: jboss.jca:service=RARDeployer
              jboss.jca:name=PostgresDS,service=LocalTxCM

              many thanks

              Andrew

              • 4. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
                Dave Smith Newbie

                If you look in the server.log does the .har get deployed before the jars in the ear ?
                I personally do not use an ear but the jars get deployed before my .har file.

                • 5. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
                  beyarecords Novice

                  Ah...!,
                  I think I may be completely missing the point of ejb here. As you know my initial intention was to be able to use hibernatecontext.getSession() which you can only use behind an ejb?, so my understanding was that i would have to run my application within an ear! Ok let's start again, how do I run my code behind an ejb? Can you show me the code required?


                  many thanks

                  Andrew

                  • 6. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
                    beyarecords Novice

                    Here is the reading I was getting from the logs which would suggest that the ear was being deployed before the classes:

                    16:54:12,522 INFO [EARDeployer] Init J2EE application: file:/Library/jboss-4.0.0/server/default/deploy/myHibernateEar.ear/
                    16:54:14,509 ERROR [Hibernate] Starting failed jboss.har:service=Hibernate
                    net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: persistent class [test.Artist] not found
                    at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:191)
                    at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:421)
                    at net.sf.hibernate.cfg.Configuration.addDirectory(Configuration.java:418)
                    at org.jboss.hibernate.jmx.Hibernate.buildSessionFactory(Hibernate.java:463)
                    at org.jboss.hibernate.jmx.Hibernate.startService(Hibernate.java:444)
                    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
                    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
                    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
                    at $Proxy0.start(Unknown Source)
                    at org.jboss.system.ServiceController.start(ServiceController.java:416)
                    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    at $Proxy4.start(Unknown Source)
                    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
                    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:935)
                    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:927)
                    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:927)
                    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:746)
                    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
                    at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:119)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    at $Proxy8.deploy(Unknown Source)
                    at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
                    at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:481)
                    at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
                    at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
                    at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:271)
                    at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:221)
                    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                    at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
                    at $Proxy0.start(Unknown Source)
                    at org.jboss.system.ServiceController.start(ServiceController.java:416)
                    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:324)
                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    at $Proxy4.start(Unknown Source)
                    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
                    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:935)
                    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:746)
                    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:709)
                    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:693)
                    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:324)
                    at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
                    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                    at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:119)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                    at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
                    at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                    at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
                    at $Proxy5.deploy(Unknown Source)
                    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:396)
                    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:293)
                    at org.jboss.Main.boot(Main.java:151)
                    at org.jboss.Main$1.run(Main.java:405)
                    at java.lang.Thread.run(Thread.java:552)

                    many thanks


                    Andrew

                    • 7. Re: Hibernate.har in myHibernateEar.ear 'no persistent class
                      ulfreich Newbie

                      You know what could work? switch from EhCache to HashtableCache for the hibernate service. I'm having a similar problem, and it seems it's because ehcache may be shared among applications (isolation not working for it), then cache would be the same for all apps.

                      Did you get a solution for this? (using multiple hibernate/ehcache apps deployed as ears)