Enable static weaving in eclipselink

When I run my rcp application that uses jpa, I get the following warning messages:

[EL Info]: 2012-05-23 22:29:26.841--ServerSession(20341825)--EclipseLink, version: Eclipse Persistence Services - 2.3.2.v20111125-r10461 [EL Warning]: 2012-05-23 22:29:27.338--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [infoid] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur. [EL Warning]: 2012-05-23 22:29:27.339--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [groupid] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur. [EL Warning]: 2012-05-23 22:29:27.339--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeeSchedule] for the entity class [class org.company.management.entity.Employee] since weaving was not enabled or did not occur. [EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeescheduleid] for the entity class [class org.company.management.entity.EmployeeScheduleInfo] since weaving was not enabled or did not occur. [EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [scheduleid] for the entity class [class org.company.management.entity.EmployeeSchedule] since weaving was not enabled or did not occur. [EL Warning]: 2012-05-23 22:29:27.34--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employeeid] for the entity class [class org.company.management.entity.EmployeeSchedule] since weaving was not enabled or did not occur. [EL Warning]: 2012-05-23 22:29:27.341--ServerSession(20341825)--Reverting the lazy setting on the OneToOne or ManyToOne attribute [employee] for the entity class [class org.company.management.entity.EmployeeInfo] since weaving was not enabled or did not occur. [EL Info]: 2012-05-23 22:29:27.556--ServerSession(20341825)--bundleresource://29.fwk31583837:2_Management login successful 

And I want to enable lazy loading.

My persistence.xml looks like this:

 <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="Management" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>org.company.management.entity.EmployeeGroup</class> <class>org.company.management.entity.Company</class> <class>org.company.management.entity.Employee</class> <class>org.company.management.entity.Schedule</class> <class>org.company.management.entity.EmployeeInfo</class> <class>org.company.management.entity.EmployeeSchedule</class> <class>org.company.management.entity.EmployeeScheduleInfo</class> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:derby:.cafedb;create=true"/> <property name="javax.persistence.jdbc.password" value="vodbomb"/> <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/> <property name="javax.persistence.jdbc.user" value="root"/> <property name="eclipselink.ddl-generation" value="create-tables" /> </properties> </persistence-unit> </persistence> 

I have an assembly script "build.xml" to do static weaving:

 <project name="Management" basedir="."> <target name="define.task" description="New task definition for toplink static weaving"> <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"> </taskdef> </target> <target name="weaving" description="perform weaving" depends="define.task" <weave source="${basedir}/src/org/company/management/entity" target="${basedir}/src/org/company/management/entity/woven.jar" persistenceinfo="${basedir}/META-INF/persistence.xml"> </weave> </target> </project> 

And I encounter this error when I run ant script "build.xml":

 Buildfile: C:\Users\J\workspace\org.company.management\build.xml define.task: weaving: BUILD FAILED C:\Users\J\workspace\org.company.management\build.xml:13: Exception [EclipseLink-40007] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.StaticWeaveException Exception Description: An exception was thrown while weaving: C:\Users\J\workspace\org.company.management\src\org\company\management\entity Internal Exception: Exception [EclipseLink-40001] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.StaticWeaveException Exception Description: An exception was thrown while trying to open an archive from URL: file:/C:/Users/J/workspace/org.company.management/META-INF/persistence.xml Internal Exception: java.util.zip.ZipException: error in opening zip file Total time: 242 milliseconds 

How to enable static weaving ??? I'm in a mess

+4
source share
5 answers

How to Apply Static Weaving Ant Task with JPA Eclipse-Link in Netbeans?

Combine the question and answer and you get a working example.

+2
source

I think your problem is the source, it should be a bank, not a directory. Try to give him a jar of compiled classes.

Cm,

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

+1
source

Include it in Eclipse using DALI SETTINGS . Please note that I had to turn on Project-> Build Automatically, otherwise it would automatically rebuild the files!

0
source

You are missing the static weaving declaration in your persistance.xml:

 <properties> ... <property name="eclipselink.weaving" value="static"/> ... </properties> 
0
source

You need to have a property in your persistence.xml file

 <property name="eclipselink.weaving" value="static"/> 

You can use the exploded directory structure instead of a jar file if you want.

I had problems when there were spaces in the persistenceinfo location in it, so I moved the persistence.xml file to the location of the class files that I need to weave before I splice them.

0
source

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


All Articles