title: OpenJPA 2.1.1 enhancement problem on Glassfish 3.1.1
body: <p>My problem is this exception:</p>
  
  <pre><code>Caused by: &lt;openjpa-2.1.1-r422266:1148538 nonfatal user error&gt; org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
  </code></pre>
  
  <p>I'm trying to get an very simple java application with jsf and jpa running, but there seems to be a problem with the enhancement of my entities. As far as I know, tries OpenJPA to enhance my entities at runtime, which are listet in the <code>persistence.xml</code>, however there is no agent to do this. The keyword for this is: <code>Enhancing at Runtime</code>, right?</p>
  
  <p>I thought the enhancement will automatically done by the application server at deployment? How can I configure this?</p>
  
  <p>My exactly environment: </p>
  
  <ul>
  <li>Glassfish 3.1.1</li>
  <li>Derby, which is integrated in Glassfish</li>
  <li>OpenJPA 2.1.1</li>
  <li>Mojarra JSF 2.1.3</li>
  </ul>
  
  <p><strong>Update #1:</strong></p>
  
  <p>After some comments I've added the following lines to my <code>persistence.xml</code>:</p>
  
  <pre><code>&lt;property name="openjpa.DynamicEnhancementAgent" value="false"/&gt;
  &lt;property name="openjpa.RuntimeUnenhancedClasses" value="supported" /&gt;
  </code></pre>
  
  <p>It works now, but OpenJPA throw this warning:</p>
  
  <pre><code>SEVERE: 52  myApp  WARN   [http-thread-pool-8080(5)] openjpa.Enhance - Creating subclass for "[class myApp.model.entities.AbstractEntity, class myApp.model.entities.Post]". 
  This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.
  </code></pre>
  
  <p>I think this can't be the solution.</p>
  
  <p><strong>Update #2:</strong></p>
  
  <p>Refer to fvu's answer, I've tried to define the <code>-javaagent</code> jvm parameter in the <code>domain.xml</code> and over the web admin console. After a restart appeared the problem again.</p>
  
  <p><strong>Update #3:</strong></p>
  
  <p>Refer to update #2, I've played a bit around. There must be thrown an error, when the <code>-javaagent</code> parameter is used, but the file is missing, right?. Yes, there it is:</p>
  
  <pre><code>Waiting for domain1 to start .Command start-domain failed.
  Error starting domain domain1.
  The server exited prematurely with exit code 1.
  Before it died, it produced the following output:
  
  Error occurred during initialization of VM
  agent library failed to init: instrument
  Error opening zip file or JAR manifest missing : /tmp/openjpa.jar
  </code></pre>
  
  <p>If I copying the agent to this location, this error doesn't appear, but openjpa could still not enhance my entities!</p>