JPA - Weaving not included when running test cases

I have an application that uses Eclipselink 2.5, and when I run Junit test cases, I always get this warning:

[EL Warning]: metadata: 2013-08-19 01:14:05.142--ServerSession(14351551)-- Reverting the lazy setting on the OneToOne or ManyToOne attribute [currentTransit] for the entity class [class ......persistent.entity.BPExecutionEntity] since weaving was not enabled or did not occur. 

So, I wrote the weave task in the Ant build file as follows:

 <target name="define.task" description="New task definition for EclipseLink static weaving"> <taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask"/> </target> <target name="weaving" description="perform weaving" depends="define.task"> <weave source="D:\...\dist\${ant.project.name}.jar" target="D:\...\dist\woven-${ant.project.name}.jar" persistenceinfo="D:\...\lib\persistence.jar"> <classpath> </classpath> </weave> </target> 

OK, everything works, and when I compile the code, it generates a woven file the size of the size of the compiled jar. But, when I run the tests of the project, I still get the same warning blah blah blah... since weaving was not enabled or did not occur.

Does anyone know how to remove this warning from my tests?

+3
source share
2 answers

Finally, I solved the situation using dynamic weaving. When I use Netbeans 7.3.1, I went to Project Options | Run | VM options Project Options | Run | VM options Project Options | Run | VM options and added this text: -javaagent:C:\eclipselink\jlib\eclipselink.jar , you can change the address to any address where you found eclipselink.jar.

Then I added this line to persistence.xml :

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

It's all. This configuration allows dynamic weaving to run test cases and removes [EL Warning] Reverting the lazy setting on the OneToOne or ManyToOne attribute...etc.

+2
source

You need to indicate that static weaving is used in your persistence.xml properties. See http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving

"Step 2: Configure persitence.xml" for details

+2
source

All Articles