title: How to configure to use EntityListeners in Jboss 7?
body: <p>I already added <code>org.eclipse.persistence</code> module in <code>JBoss 7</code>. I cannot use <code>EntityListeners</code>. <br/>
  If I remove <code>@EntityListeners(IDInterceptor.class)</code> from entity, persist operation is ok.<br/>
  Before an entity is persist, I have to do some operation.</p>
  
  <p><strong>If I test insert method of DAO with <code>Junit</code>, <code>EntityListeners</code> is work.</strong></p>
  
  <p>I use : <code>JBoss 7</code>, <code>Spring 3.5</code> and <code>JPA 2.0 (EcliplseLink 2.5.0)</code></p>
  
  <p>Let me know, How can I use <code>EntityListeners</code> in my web application with <code>JBoss 7</code>?</p>
  
  <p>InsuType.java</p>
  
  <pre><code>@Entity
  @TableGenerator(name = "INSUTYPE_GEN", table = "ID_GEN", pkColumnName = "GEN_NAME", valueColumnName = "GEN_VAL", pkColumnValue = "INSUTYPE_GEN", allocationSize = 10)
  @EntityListeners(IDInterceptor.class)
  public class InsuType implements Serializable {
      @Id
      @GeneratedValue(strategy = GenerationType.TABLE, generator = "INSUTYPE_GEN")
      private String id;
      private String name;
      //getter and setter
  }
  </code></pre>
  
  <p>IDInterceptor.java  </p>
  
  <pre><code>public class IDInterceptor {
      @PrePersist
      public void onPrePersist(Object obj) {
  
      }
  
      //other function
  }
  </code></pre>
  
  <p>InsuTypeDAO.java</p>
  
  <pre><code>@Repository("InsuTypeDAO")
  public class InsuTypeDAO implements IInsuTypeDAO {
      @PersistenceContext
      protected EntityManager em;
  
      @Transactional(propagation = Propagation.REQUIRED)
      public InsuType insert(InsuType insuType) throws DAOException {
          em.persist(insuType);
          return insuType;
      }
  }   
  </code></pre>
  
  <p>If I use <code>@EntityListeners(IDInterceptor.class)</code>, I get the following error</p>
  
  <pre><code>    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:496) [eclipselink-2.5.0.jar:2.5.0.v20130507-3faac2b]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_23]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_23]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_23]
      at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_23]
      at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240) [spring-orm.jar:3.1.
  1.RELEASE]
      at $Proxy57.persist(Unknown Source) at org.ace.insurance.system.common.insutype.persistence.InsuTypeDAO.insert(InsuTypeDAO.java:33) [classes:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_23]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_23]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_23]
      at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_23]
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) [spring-aop.jar:3.1.1.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) [spring-aop.jar:3.1.1.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop.jar:3.1.1.RELEASE]
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) [spring-tx.jar:3.1.1.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop.jar:3.1.1.RELEASE]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) [spring-aop.jar:3.1.1.RELEASE]
      at $Proxy108.insert(Unknown Source) at org.ace.insurance.system.common.insutype.service.InsuTypeService.addNewInsuType(InsuTypeService.java:33) [classes:]
      at org.ace.insurance.web.manage.system.ManageInsuTypeActionBean.addNewInsuType(ManageInsuTypeActionBean.java:52) [classes:]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_23]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_23]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_23]
      at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_23]
      at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]
      at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]
      at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.5.Final.jar:2.0.
  5.Final]
      ... 33 more
  Caused by: java.lang.ClassNotFoundException: javax.enterprise.inject.spi.BeanManager from [Module "org.eclipse.persistence:main" from local module loader @4c5e1
  76f (roots: D:\java\JBoss-7.1.1\modules)]
      at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
      at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
  </code></pre>