尝试在jpa中删除时的并发问题 [英] concurrency problem when trying to delete in jpa

查看:229
本文介绍了尝试在jpa中删除时的并发问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个EAR 1_EAR和2_EAR(这些有websearvices和其他代码)。现在我有1个项目DB_prj用于与database交互。现在所有项目1_EAR,2_EAR,DB_prj在各自的meta中都有一个persistence.xml -inf folder.Now只有1_EAR和2_EAR有web.xml。 2_EAR是由我们的团队开发的新项目。 1_EA工作正常。现在我尝试使用开发的类删除任何记录,我放置在2_EAR我的代码挂起并超时。要删除一条记录我从DB_prj调用API,从1_EAR.In中调用它工作正常1_EAR和2_EAR我有一个共同点。 1_EAR的web.xml还包含2_EAR的web.xml中不存在的许多其他内容。

I have 2 EARs 1_EAR and 2_EAR (these has websearvices and other code).Now i have 1 project DB_prj that is used for interacting with database.Now all projects 1_EAR,2_EAR, DB_prj have a persistence.xml in their respective meta-inf folder.Now only 1_EAR and 2_EAR have web.xml in it. 2_EAR is a new project which is developed by our team. 1_EAr is working fine.Now when i try to delete any record by using class developed which i placed in 2_EAR my code hangs and times out.To delete a record i call API from DB_prj which works fine when called from 1_EAR.In web.xml of 1_EAR and 2_EAR i have following in common. web.xml of 1_EAR has many other things whic are not present in web.xml of 2_EAR.

<persistence-context-ref>
 <persistence-context-ref-name>persistence/XYZPersist</persistence-context-ref-name>
 <persistence-unit-name>XYZPersist</persistence-unit-name>
 </persistence-context-ref>

任何人都可以帮我解决这个问题吗?上面的代码我放在web.xml中在somone回复我的帖子后2_EAR @ JNDI问题

Can any one help me in solving this problem?The above code i had placed in web.xml of 2_EAR after somone answered my post @ problem with JNDI

推荐答案

我的赌注是你的EAR#2通过JNDI解析上下文,但是上下文被EAR#1绑定,带有EAR#1类加载器;因此,在持久性API的腹部某处,您可能会得到一个ClassCastException,因为该类虽然具有相同的名称和包,却由不同的类加载器加载。

My bet would be your EAR#2 resolves context via JNDI, but the context was bound by EAR#1, with EAR#1 classloader; therefore somewhere deep in the belly of persistence API you probably get a ClassCastException because the class, though has the same name and package, was loaded by a different class loader.

My重点是两个EAR的持久性单元应该有不同的JNDI名称。从你的帖子看起来它们是相同的。

My point is that two EARs should have different JNDI names for their persistence units. From your post it looks they are the same.

(实际上,提及插入/更新工作正常与我的假设相矛盾,但谁知道。)

(Actually, the mention that insert/update works fine contradicts my hypothesis, but who knows.)

这篇关于尝试在jpa中删除时的并发问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆