Concurrency problem when trying to delete in jpa

I have 2 EARs 1_EAR and 2_EAR (they have websearvices and other code). Now I have 1 DB_prj project that is used to interact with the database. Now all projects 1_EAR, 2_EAR, DB_prj have persistence.xml in their corresponding meta -inf. Now only 1_EAR and 2_EAR have web.xml. 2_EAR is a new project developed by our team. 1_EAr works fine. Now, when I try to delete any record using the class developed that I posted in 2_EAR, my code freezes and time. To delete a record, I call the API from DB_prj, which works fine when called from 1_EAR.In web.xml from 1_EAR and 2_EAR I have in common. web.xml 1_EAR has many other things that are not in web.xml 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>

Can someone help me in solving this problem? The above code, which I posted in web.xml 2_EAR, after somone answered my @ problem with JNDI

+3
source share
1 answer

My bet will be your EAR # 2 to allow context through JNDI, but the context has been linked to EAR # 1 with EAR # 1 classloader; therefore, somewhere deep in the stomach of the persistence API you are likely to get a ClassCastException because the class, although it has the same name and package, was loaded by another class loader.

My point is that two EARs must have different JNDI names for their duration units. From your post they look the same.

( , / , , .)

0

Source: https://habr.com/ru/post/1784243/


All Articles