Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA - Weaving not enabled while running test cases

I have an application that uses Eclipselink 2.5, and when running the Junit test cases, I always receive 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 a 'weaving' task on my Ant build file like this:

<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 half the size of the compiled jar. But, when I run the tests of the project then I still receive the same warning blah blah blah... since weaving was not enabled or did not occur.

Anybody knows how to remove this warning from my tests?

like image 902
Joe Almore Avatar asked Aug 19 '13 06:08

Joe Almore


2 Answers

I finally solved the situation using dynamic weaving. As I'm using Netbeans 7.3.1, I went to the Project Options | Run | VM options and added this text: -javaagent:C:\eclipselink\jlib\eclipselink.jar, you can change the address to whatever address you have located the eclipselink.jar.

Then I added this line to the persistence.xml:

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

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

like image 137
Joe Almore Avatar answered Oct 09 '22 08:10

Joe Almore


You need to specify 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

like image 45
Chris Avatar answered Oct 09 '22 10:10

Chris