title: EJB Container initialization error, could not invoke defineClass
body: <p>My glassfish throws an exception when I try to run.</p>
  
  <blockquote>
    <p>[2018-02-22T17:07:04.135+0100] [glassfish 5.0] [SEVERE] []
    [javax.enterprise.system.core] [tid: _ThreadID=46
    _ThreadName=admin-listener(4)] [timeMillis: 1519315624135] [levelValue: 1000] [[   Exception while loading the app : EJB
    Container initialization error java.lang.RuntimeException: Could not
    invoke defineClass!</p>
  </blockquote>
  
  <p>I uploaded the server log here: <a href="https://pastebin.com/cB0EgG4Y" rel="nofollow noreferrer">https://pastebin.com/cB0EgG4Y</a></p>
  
  <p>UserDao</p>
  
  <pre><code>@Stateless
  class UserDao : Abstract&lt;User&gt;() {
      override fun getEntityClass(): Class&lt;User&gt; {
          return User::class.java
      }
  }
  </code></pre>
  
  <p>Abstract Dao</p>
  
  <pre><code>@Stateless
  abstract class Abstract&lt;T : Model&gt; {
      @PersistenceContext(unitName = "kwetter")
      private lateinit var entityManager: EntityManager
  
      abstract fun getEntityClass(): Class&lt;T&gt;
  
      fun find(id: Int): T {
          return entityManager.find(getEntityClass(), id)
      }
  }
  </code></pre>
  
  <p>Service</p>
  
  <pre><code>@Stateless
  class UserService {
      @Inject private var userDao: UserDao? = null
  
      fun find(id: Int): User {
          return userDao!!.find(id)
      }
  }
  </code></pre>
  
  <p>API endpoint</p>
  
  <pre><code>@Stateless
  @Named
  @Path("/users")
  class Users {
      @Inject private var userService: UserService? = null
  
      @GET
      @Path("/{id}")
      @Produces("application/json")
      fun single(@PathParam("id") id: Int): User {
          return userService!!.find(id)
      }
  }
  </code></pre>