4 Replies Latest reply on Jan 5, 2014 3:43 AM by Yazik KP

    Envers classloading problem (Jboss7 second instance from quartz)

    Tom Smith Newbie

      Ok, this will be extremely wired but I hope you can get through my problem:

       

      I have a fully working jboss7 ejb3 application with envers revisioning. The application is running without problems and is registering it's hibernate sessionFactory in jndi at startup.

       

      From this application there is a MailQueueJob started as Quartz job. This job tries to send generated mails asynchronous.

      Envers seems to use a different class loader in the job and fails to load my class.

       

       

      This job is getting its sessionfactory through jndi, opens a new session and requests the UserTransaction from jboss jndi:

       

      initCtx = new InitialContext();

      tx = (UserTransaction)initCtx.lookup("java:jboss/UserTransaction");

       

       

      from this sqlSession several criteriaQueries are started. no problems.

       

      The following block fails. It should read out the latest revision from given invoice.

       

      AuditReader reader = AuditReaderFactory.get(sqlSession);

      Number revisionNumber = reader.getRevisions(Invoice.class, mail.getInvoice().getId()).get(0);

                                                                          

      Invoice oldInvoice = reader.find(Invoice.class, mail.getInvoice().getId(), revisionNumber);

       

       

       

      14:42:41,559 ERROR [stderr] (DefaultQuartzScheduler_Worker-3) org.hibernate.envers.exception.AuditException: org.hibernate.envers.exception.AuditException: java.lang.ClassNotFoundException: test.entities.billing.Invoice from [Module "org.jboss.as.server:main" from local module loader @77eaf8 (roots: c:\Users\admin\Documents\jboss7\modules)]

       

      14:42:41,559 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:92)

      14:42:41,559 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.entities.EntityInstantiator.addInstancesFromVersionsEntities(EntityInstantiator.java:112)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:109)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.query.impl.AbstractAuditQuery.getSingleResult(AbstractAuditQuery.java:106)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.reader.AuditReaderImpl.find(AuditReaderImpl.java:121)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.reader.AuditReaderImpl.find(AuditReaderImpl.java:96)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at test.jobs.MailQueueJob.execute(MailQueueJob.java:155)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.quartz.core.JobRunShell.run(JobRunShell.java:213)

      14:42:41,575 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557)

      14:42:41,590 ERROR [stderr] (DefaultQuartzScheduler_Worker-3) Caused by: org.hibernate.envers.exception.AuditException: java.lang.ClassNotFoundException: test.entities.billing.Invoice from [Module "org.jboss.as.server:main" from local module loader @77eaf8 (roots: c:\Users\admin\Documents\jboss7\modules)]

      14:42:41,590 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.tools.reflection.ReflectionTools.loadClass(ReflectionTools.java:55)

      14:42:41,590 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.entities.EntityInstantiator.createInstanceFromVersionsEntity(EntityInstantiator.java:89)

      14:42:41,590 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   ... 8 more

      14:42:41,606 ERROR [stderr] (DefaultQuartzScheduler_Worker-3) Caused by: java.lang.ClassNotFoundException: test.entities.billing.Invoice from [Module "org.jboss.as.server:main" from local module loader @77eaf8 (roots: c:\Users\admin\Documents\jboss7\modules)]

      14:42:41,606 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

      14:42:41,606 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

      14:42:41,606 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

      14:42:41,622 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

      14:42:41,622 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

      14:42:41,622 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   at org.hibernate.envers.tools.reflection.ReflectionTools.loadClass(ReflectionTools.java:53)

      14:42:41,622 ERROR [stderr] (DefaultQuartzScheduler_Worker-3)   ... 9 more