JPA プロジェクトを動的 Web プロジェクトの jar として使用しています。
プロジェクトのある時点で、java.lang.ClassNotFoundException: javax.persistence.Persistenceエラーが発生します。
operation = RepositoryFactory.getRepositoryFactory()
.getUserRepository().add(feedbackverantwoordelijke);
public boolean add(User user) {
EntityManagerFactory emf = HibernateRepositoryFactory
.getEntityManagerFactory();
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
User tempUser = null;
try {
// checking if the entity is already in the repository
if (user.getId() != null) {
tempUser = em.find(User.class, user.getId());
//delete
System.out.println(user.getId());
//
}
// if no persist the entity
if (tempUser == null) {
em.persist(user);
} else {
// if so, get the differences and persist them
tempUser.setPassword(user.getPassword());
tempUser.setUserName(user.getUserName());
tempUser = em.merge(user);
}
} catch (Exception e) {
logging.error("Deze melding trad op bij het toevoegen van een user"
+ " :" + e);
}
tx.commit();
em.close();
emf.close();
return true;
}
注 : Feedbackverantwoordelijke extends User
これは、私のJPAプロジェクト内から完璧に機能します。しかし、動的 Web プロジェクトの JPA jar からこれを呼び出すと、エラーが発生します。
動的 Web プロジェクトでこれを実行すると、jar が見つからないようです。通常、すべての jar は JPA プロジェクトにあり、JPA プロジェクトですべての CRUD 操作を実行できますか??
動的 Web プロジェクトにいくつかの jar をロードする必要がありますか?? もしそうなら、それらを WEB-INF/lib フォルダーに配置する必要がありますか??
また、JPA プロジェクトと Web メール jar で joda-time jar を使用しています。これらの jar も動的 Web プロジェクトに配置する必要があります。
お返事ありがとうございます