JPA ClassFormat Error "There is no code attribute in a method that is not native or abstract in the javax / persistence / Persistence class file"

I get an error from eclipse when I try to call 100% working code. This, for example, works in my netbeans, but not in this eclipse project. The error is absurd, and I'm pretty sure that it is caused by some Maven dependency on the OPEN JPA that I use. Any pointers?

Map<String,String> properties = new HashMap<String,String>();
properties.put(PersistenceUnitProperties.JDBC_PASSWORD, "");
properties.put(PersistenceUnitProperties.JDBC_USER, "root");
properties.put(PersistenceUnitProperties.JDBC_URL, "jdbc:mysql://localhost:3306/mydb");
properties.put(PersistenceUnitProperties.JDBC_DRIVER, "com.mysql.jdbc.Driver");

emf = Persistence.createEntityManagerFactory("Persistentunitname", properties);

The error is in the last line, and the error is:

ClassFormat error "Missing code attribute in a method that is not native or abstract in the javax / persistence / Persistence class file"

+5
source share
3 answers

javaee pom,

 <dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-web-api</artifactId>
  <version>6.0</version>
</dependency>

. JPA javaee .

+10

, pom javaee-api. , . , "" JavaEE.

NetBeans javaee, Eclipse - . , :

<dependency>
   <groupId>org.eclipse.persistence</groupId>
   <artifactId>eclipselink</artifactId>
   <version>2.4.0</version>
   <scope>compile</scope>
</dependency>

javax.persistence .

+3

In general, it is sufficient to download the JavaEE JAR directly from Oracle:

http://www.mkyong.com/maven/how-to-download-j2ee-api-javaee-jar-from-maven/

0
source

All Articles