分享

WebSphere 7 & javax/persistence/OneToMany.orp...

 旭龙 2013-01-22

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.

JPA2-On-WAS7

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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多