aspose file tools*
The moose likes Object Relational Mapping and the fly likes JPA file accessed from different .ear files deployed on weblogic server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA file accessed from different .ear files deployed on weblogic server" Watch "JPA file accessed from different .ear files deployed on weblogic server" New topic
Author

JPA file accessed from different .ear files deployed on weblogic server

chandr prakash
Ranch Hand

Joined: Jan 29, 2011
Posts: 32
I am writing a application in which following JPA file,will be accessed from different application.
To do this i created .jar file of following java file and added in classpath of server.



I created testclient.jar(entity.library.TestJPA.class) and added this jar in classpath of weblogic server.(I can see entry of jar in classpath of weblogic server.)

I am accessing this JPA file from .ear module.

My persistence.xml



But getting some error while deploying on weblogic server



After debugging i found that when i remove following line



Then test1.ear file is successfully deployed,But if i remove <jar-file> tag in persistence.xml then how i will access TestJPA class.I dont want to bundle this TestJPA class in each .jar file deployed on weblogic server.

I have to access this TestJPA.class file from multiple session bean of.jar files deployed on weblogic server.

Approach 1 is i deploy TestJPA.class with each .jar file deployed on weblogic server.But i dont want this approach.
If anyone know any better way to handle this?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
The jar file must be in the same classpath as the persistence unit (in the ear) to use the <jar-file> tag.

You can still put your jar on the server's classpath, but instead of using <jar-file> just list each of the classes in the persistence.xml using <class>.

As a trick, you could also put it in the ear as well, the class will still be on the root classpath the same, the jar will just be used to get the list of classes.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
chandr prakash
Ranch Hand

Joined: Jan 29, 2011
Posts: 32
@James Sutherland...Very Very Thankx for reply

As suggested by you i used <class> tag in persistence.xml and ears were deployed on server successfully.

I created two ears test.ear and test1.ear....

test.ear is updating some vaue(Updating studentName corresponding to studentId) in database table using TestJPA class with following persistence.xml (TestJPA class is added in weblogic server's classpath.)



The value is succesfully updated in table successfully. I can see the value in database table by sql-query on sqlplus.

From test1.ear i accessed same database-table value using TestJPA class with following persistence.xml (Selecting all rows from student_tables table)



But i am getting my previous database table values. I am not able to access database values updated by test.ear module.

After debugging i found that when i redeploy test1.ear then only i can retrieve updated values. What can be possible reason ? Please reply!
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
By default EclipseLink enables a shared cache.

Do disable the shared cache see,

http://wiki.eclipse.org/EclipseLink/FAQ/How_to_disable_the_shared_cache%3F

http://en.wikibooks.org/wiki/Java_Persistence/Caching
chandr prakash
Ranch Hand

Joined: Jan 29, 2011
Posts: 32
Thankx ! My query is resolved.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA file accessed from different .ear files deployed on weblogic server