WebSphere 7 & Javax/Persistence/OneToMany.OrphanRemoval() Error

文章出处: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.

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

websphere部署 hibernate jpa & Error 500: javax/persistence/OneToOne.orphanRemoval()Z的更多相关文章

  1. java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z

    我现在用的是hibernate3.6final,出现了下面这个异常:(当我使用@ManyToOne时,不会出现异常,而且用@ManyToMany也正常) Caused by: java.lang.No ...

  2. 异常:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z/Caused by: java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreign

    Spring3.0 + Hibernate3.5:启动服务器报:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany. ...

  3. 异常:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z

    Spring3.0 + Hibernate3.5:启动服务器报:Caused by: java.lang.NoSuchMethodError: javax.persistence.OneToMany. ...

  4. webSphere 部署项目时,访问报错:Error 500: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet【我】

    前提: 一个普通maven项目,在本地用Tomcat运行没有任何问题,但是放到 webSphere  测试环境上,访问时就报如下错误: Error 500: javax.servlet.Servlet ...

  5. 项目部署错误 HTTP Error 500.19 - Internal Server Error

    HTTP Error 500.19 - Internal Server Error配置错误: 不能在此路径中使用此配置节.如果在父级别上锁定了该节,便会出现这种情况.锁定是默认设置的 (overrid ...

  6. java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()

    原因:hibernate-jpa-2.0-api-1.0.0.Final.jar.ejb3-persistence.jar中的javax.persistence与javaEE 5 Librares中的 ...

  7. JPA使用指南 javax.persistence的注解配置

    @SuppressWarnings("serial") @Entity @Table(name="T_X") public class X implements ...

  8. JPA使用指南 javax.persistence的注解配置讲解

    转自http://67566894.iteye.com/blog/659829 示例 @SuppressWarnings("serial") @Entity @Table(name ...

  9. Hibernate+JPA (EntityMange讲解)

    近年来ORM(Object-Relational Mapping)对象关系映射,即实体对象和数据库表的映射)技术市场人声音鼎沸,异常热闹, Sun在充分吸收现有的优秀ORM框架设计思想的基础上,制定了 ...

随机推荐

  1. Could not establish trust relationship for the SSL/TLS secure channel 问题解决方法

    最近在写一个跟第三方对接的数据同步服务,在本地都没有问题,今天放到生产环境测试报错: System.Net.WebException: The underlying connection was cl ...

  2. python中金额计算的小问题

    由于二进制对浮点运算存在精度问题,所以一些浮点计算经常会出现以下情况: # -*- coding: utf-8 -*- a = 1 b = 0.9 print(a-b) 结果: 0.099999999 ...

  3. SQL查询四舍五入 解决方法

    方法1: SELECT CAST('123.456' as decimal) 将会得到 123(小数点后面的将会被省略掉). 如果希望得到小数点后面的两位. 则需要把上面的改为 SELECT CAST ...

  4. 【Ubuntu 16】网络配置文件

    之前使用图形化NetworkManager配置静态IP,但在/etc/network/interfaces中找不到静态IP的配置信息,让人不解. 今天在网上看到网友的一则文章,知道了在/etc/Net ...

  5. Win10个性化设置

    Win10个性化设置.. ---------------------- Capture001-我的桌面 ---------------------- Win10设置任务栏的颜色 ----------- ...

  6. 9.19.3 反射和Properties(重要)

    dbinfo.properties文件中的内容:     driver oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@192.168.1. ...

  7. JavaScript对象遍历

    一.对象是数组: var arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]; //each遍历: $.each(arr,function (index,value) { alert( ...

  8. thinkjs—控制器方法名不能大写

    async updateInfoAction(){ ... } 上面的接口如果通过ajax访问,就会报404的错误.原因似乎在于访问updateInfo时,会自动转化成小写,而小写的updateinf ...

  9. 原生Jdbc操作Mysql数据库开发步骤

    原生Jdbc操作Mysql数据库开发步骤 原生的Jdbc就是指,不使用任何框架,仅用java.sql包下的方法实现数据库查询等的操作. 下面是开发步骤:        1.导入数据库驱动包       ...

  10. Mysql数据库索引

    今天,我们来讲讲Mysql数据库的索引的一些东西,想必大家都知道索引能干吗?必然是查找数据表的时候,查找的速度快啊,尤其是那些几百万行的数据库,不建立索引,你是想考验用户的耐心吗?Mysql有多种存储 ...