Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353606

Summary: weaving fails in server for application managed persistence units
Product: z_Archived Reporter: James Sutherland <jamesssss>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: gordon.yorke, michael.f.obrien
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
fix to revert lazy one-to-ones if weaving did not occur
none
additional fix to patch to avoid changing mappings when weaving none

Description James Sutherland CLA 2011-08-02 11:32:00 EDT
In WebLogic and WebSphere if a persistent unit is used as application managed it does not find the container managed unit, so fails to enable weaving.

The reason is the URL that is given by the server and computed from the resource are different (one is zip: one is file:).
Comment 1 James Sutherland CLA 2011-08-02 11:33:43 EDT
Fixed in two parts, first record that are in container and assume weaving can be done for any persistence units.

Second, fix the zip: protocol urls to instead use file:.
Comment 2 James Sutherland CLA 2011-08-02 11:40:29 EDT
svn commit trunk/ 2.3.1 - Bug#353606 - Weaving fails in server for application managed

https://bugs.eclipse.org/bugs/show_bug.cgi?id=353606

Fixes an issue that weaving is not enabled in the server if an application managed persistence unit is used.
Issue was the persistence unit URL was different for container vs application.

Changes:
- Changed PersistenceUnitProcessor to process zip: protocol URLs and convert them to file:.
- Added a flag to JavaSECMPInitializer to set if in the server and allow weaving with no agent.
- test case in JPA EntityManager test suite to check session is that same for container vs application managed persistence units.
Comment 3 James Sutherland CLA 2011-08-02 13:50:04 EDT
forgot to get patch, so here is the change,


Index: C:/Engineering/EclipseLink/svn/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java
===================================================================
--- C:/Engineering/EclipseLink/svn/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java	(revision 9268)
+++ C:/Engineering/EclipseLink/svn/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/deployment/PersistenceUnitProcessor.java	(revision 9817)
@@ -159,6 +159,15 @@
             JarURLConnection conn =
                     JarURLConnection.class.cast(pxmlURL.openConnection());
             result = conn.getJarFileURL();
+        } else if("zip".equals(protocol)) { // NOI18N
+            // e.g. zip:/tmp/a_ear/b.jar!/META-INF/persistence.xml
+            // stolen from java.net.JarURLConnection.parseSpecs method
+            String spec = pxmlURL.getFile();
+            int separator = spec.lastIndexOf("!/");
+            if (separator == -1) {
+                separator = spec.length() - 1;
+            }
+            result = new URL("file", "", spec.substring(0, separator++));
         // mkeith - add bundle protocol cases
         } else if ("bundleentry".equals(protocol)) {           
             result = new URL("bundleentry://" + pxmlURL.getAuthority());
Comment 4 James Sutherland CLA 2011-09-14 10:48:30 EDT
fixed
Comment 5 James Sutherland CLA 2011-09-20 09:02:18 EDT
Fix is causing issue with static deployment (jar in on servers classpath so can't be weaved)
Comment 6 James Sutherland CLA 2011-09-20 09:03:25 EDT
Created attachment 203678 [details]
fix to revert lazy one-to-ones if weaving did not occur
Comment 7 James Sutherland CLA 2011-09-20 10:24:56 EDT
SVN 2.3.1,trunk commit: Bug#353606 - weaving fails in server

 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=353606

 

Fix to revert lazy in mapping's initialize if the class was not weaved.

The previous fixed cause errors to occur for static libraries that do not allow weaving when deployed in the server.

 

Code review: Gord

 

Changes:

- changed ForeignReferenceMapping to revert weaved indirection if the class was not weaved, and log a warning. 

- changed ObjectAccessor to never disable LAZY.
Comment 8 Gordon Yorke CLA 2011-09-20 11:06:18 EDT
The patch also includes the changes in revision : https://fisheye2.atlassian.com/changelog/eclipselink?cs=9867
Comment 9 James Sutherland CLA 2011-09-21 11:24:51 EDT
Created attachment 203784 [details]
additional fix to patch to avoid changing mappings when weaving
Comment 10 James Sutherland CLA 2011-09-27 08:19:59 EDT
fixed
Comment 11 Eclipse Webmaster CLA 2022-06-09 10:33:24 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink