2 Replies Latest reply on Jul 12, 2010 4:46 AM by hamide saadatmanesh

    Seam & Hibernate, Listeners and Interceptors dont work...

    Florian Haupt Newbie

      Hi,


      i am working on an project using Seam and Hibernate. I need to react on changes in my entities, so i decided to use Hibernate Listeners or Interceptors. The situation is:


      persistence.xml:


      <persistence-unit name="xyz" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:/xyzDatasource</jta-data-source>
        <jar-file>xyz-model.jar</jar-file>
        
        <class>de.xyz.entity.SomeEntity</class>
        ...
      
        <properties>
          ...
          <property name="hibernate.ejb.interceptor" value="de.xyz.entity.interceptors.TestInterceptor"/>
          ...
        </properties>
      </persistence-unit>
      



      SomeEntity.java:


      @Entity
      @EntityListeners(value = { de.xyz.entity.listener.TestListener.class })
      @Table(name = "SomeTable")
      @Audited
      @Indexed
      public class SomeEntity {
        ...
      }
      



      For me, everything looks fine and should work. When publishing my project on JBosss i get the following errors:


      11:56:14,065 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=xyz-ear.ear/xyz-persistence.jar#xyz state=Create
      javax.persistence.PersistenceException: Unable to create instance of de.xyz.entity.listener.TestListener as a listener of beanClass
           at org.hibernate.ejb.event.CallbackResolver.resolveCallback(CallbackResolver.java:143)
           at org.hibernate.ejb.event.EntityCallbackHandler.addCallback(EntityCallbackHandler.java:94)
           at org.hibernate.ejb.event.EntityCallbackHandler.add(EntityCallbackHandler.java:40)
           at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:181)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854)
           at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425)
           at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131)
           at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)
           at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)
           at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:241)
           at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109)
           at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70)
           at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)
           at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)
           at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)
           at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
           at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
           at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)
           at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)
           at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
           at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
           at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
           at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:362)
           at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
           at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
           at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
           at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
           at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.IllegalAccessException: Class org.hibernate.ejb.event.CallbackResolver can not access a member of class de.xyz.entity.listener.TestListener with modifiers ""
           at sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
           at java.lang.Class.newInstance0(Unknown Source)
           at java.lang.Class.newInstance(Unknown Source)
           at org.hibernate.ejb.event.CallbackResolver.resolveCallback(CallbackResolver.java:140)
           ... 62 more
      



      Same problem for the interceptor. Any idea, why JBoss doesnt find the classes for interceptors and/or listeners?