title: Error on creating custom log4j Appender
body: <p>I'm trying to create a custom Appender that will persist logs to the database using JPA.</p>
  
  <p>The thing is that I'm using <code>PersistenceContext</code> attribute like this</p>
  
  <pre><code>package com.foobar.logging;
  
  import com.foobar.model.SysLog;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  import org.apache.log4j.AppenderSkeleton;
  import org.apache.log4j.MDC;
  import org.apache.log4j.spi.LoggingEvent;
  import javax.ejb.Stateless;
  
  @Stateless
  public class LogManager extends AppenderSkeleton {
  
      @PersistenceContext(unitName = "primary")
      private EntityManager em;
  
      @Override
      protected void append(LoggingEvent le) {
          SysLog log = new SysLog();
          log.setDescripcion(le.getMessage().toString());
          if (MDC.get("IdUsuario") != null) {
              log.setIdUsuario(MDC.get("IdUsuario").toString());
          }
          log.setSysAccionLog(null);
  
          this.em.persist(log);
      }
  
      @Override
      public void close() {
      }
  
      @Override
      public boolean requiresLayout() {
          return false;
      }
  
  }
  </code></pre>
  
  <p>Now when I'm deploying the WAR to JBoss AS 7.1, it fails, and I get the error:</p>
  
  <p><code>java.lang.VerifyError: class com.foobar.logging.LogManager$Proxy$_$$_Weld$Proxy$ overrides final method getName.()Ljava/lang/String;</code></p>
  
  <p>How can I use CDI to inject my EntityManager inside an AppenderSkeleton?  Has anyone accomplished JPA persistance in an AppenderSkeleton using CDI?</p>
  
  <p>I also tried not using CDI, but since every other object in my app uses it (JAX-RS classes), it collapses.</p>