title: Weblogic JPA 2.1 Hibernate 4 Not Working java.lang.NoSuchMethodError
body: <p>I've run into the classic issue of trying to run a web app on a weblogic server and running into errors because of the weblogic server having old copies of classes.</p>
  
  <p>The main issue I run into is when trying to use JPA 2.1 I get the following issue:</p>
  
  <pre><code>weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
  </code></pre>
  
  <p>The obvious answer here is that it is using the JPA version on the server which does not have that class.</p>
  
  <p>I've set my weblogic.xml file to the following:
      </p>
  
  <pre><code>&lt;wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd"&gt;
  &lt;wls:weblogic-version&gt;12.1.3&lt;/wls:weblogic-version&gt;
  &lt;wls:jsp-descriptor/&gt;
  &lt;wls:debug&gt;true&lt;/wls:debug&gt;
  &lt;/wls:jsp-descriptor&gt;
  &lt;wls:container-descriptor&gt;
  &lt;wls:prefer-web-inf-classes&gt;true&lt;/wls:prefer-web-inf-classes&gt;  
  &lt;/wls:container-descriptor&gt;
  &lt;wls:context-root&gt;DiscoveryPortal&lt;/wls:context-root&gt;
  &lt;/wls:weblogic-web-app&gt;
  </code></pre>
  
  <p>With the key line being:
      prefer-web-inf-classes: true  </p>
  
  <p>This seems to work for some classes but not all.</p>