0
JPA 및 Derby 프로젝트 시작에 문제가 있습니다.JPA java.lang.ClassFormatError 문제
Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/Persistence
내 Main.java
은 다음과 같습니다 : 나는 다음과 같은 오류가
public class Main {
private static final String PERSISTENCE_UNIT_NAME = "customers";
private static EntityManagerFactory factory;
public static void main(String[] args) {
factory = Persistence.createEntityManagerFactory("todos");
EntityManager em = factory.createEntityManager();
Query q = em.createQuery("select t from CUSTOMER t");
List<Customer> customerList = q.getResultList();
for (Customer customer : customerList) {
System.out.println(customer);
}
System.out.println("Size: " + customerList.size());
em.getTransaction().begin();
Customer customer = new Customer();
customer.setCity("Warsaw");
customer.setCountry("USA");
customer.setName("John");
customer.setStreet("Street");
em.persist(customer);
em.getTransaction().commit();
em.close();
}
}
내 persistence.xml
:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="todos" transaction-type="RESOURCE_LOCAL">
<class>b.model.Product</class>
<class>b.model.Book</class>
<class>b.model.Movie</class>
<class>b.model.Customer</class>
<class>b.model.Order</class>
<class>b.model.OrderElement</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:derby://localhost:1527/baza;create=true" />
</properties>
</persistence-unit>
</persistence>
내 프로젝트 2 종속성이 있습니다
- derbyclient-을 10.12.1.1.jar
- JavaEE 어플-API-6.0.jar 내가 잘못 뭐하는 거지에
어떤 아이디어?
I는 다음과 같이 정의 (고객 등) 모든 모델 클래스를 가지고 :
이것은 당신의 WAR 내부의 JavaEE 어플-API 항아리를 포장하여 대부분의 아마 발생@Data
@Entity(name = "CUSTOMER")
public class Customer {
@Id
@Column(name = "CUSTOMER_ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private long customerId;
@Column(name = "NAME")
private String name;
@Column(name = "SURNAME")
private String surname;
@Column(name = "STREET")
private String street;
@Column(name = "CITY")
private String city;
@Column(name = "ZIP_CODE")
private String zipCode;
@Column(name = "COUNTRY")
private String country;
@OneToMany(mappedBy="customer",targetEntity=Order.class, fetch= FetchType.EAGER)
private Collection orders;
}