文章出处:http://www.mkyong.com/websphere/websphere-7-javaxpersistenceonetomany-orphanremoval-error/ 

Problem

In Hibernate development, contains a model class with JPA @OneToMany annotation :

    @OneToMany(
    cascade=CascadeType.ALL, 
    fetch = FetchType.LAZY, mappedBy = "user")
    public Set<Debit> getDebits() {
        return this.debits;
    }

When web application is deployed on WebSphere 7, it hit following error message :

Caused by: java.lang.NoSuchMethodError: javax/persistence/OneToMany.orphanRemoval()Z
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1912)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:707)
	... 118 more

P.S hibernate-jpa-2.0-api-1.0.0.Final.jar is included in the library path.

Solution

The OneToMany.orphanRemoval is specified in JPA 2.0, and look like WebSphere 7 contains older JPA library, which is loaded before your hibernate-jpa-2.0-api-1.0.0.Final.jar.

To fix it, put your JPA 2.0 (hibernate-jpa-2.0-api-1.0.0.Final.jar) library in the WebSphere’s highest priority class loader folder, which is under WAS7_FOLDER\AppServer\java\jre\lib\ext. Restart WebSphere server instance to take effect.

Now access WebSphere web console –> Troubleshooting –> Class loader viewer, make sure your library is loaded.

websphere部署 hibernate jpa &  Error 500: javax/persistence/OneToOne.orphanRemoval()Z

Now, WebSphere 7 will always load your Hibernate JPA 2.0 library.

websphere

相关文章:

  • 2022-01-22
  • 2021-07-19
  • 2022-12-23
  • 2021-08-25
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2021-11-29
  • 2021-04-12
  • 2021-07-21
  • 2021-09-10
  • 2022-12-23
相关资源
相似解决方案