Copy from:http://tomee.apache.org/javaagent.html
Adding a javaagent
Adding A Java agent is the done via a VM parameter as follows:
java -javaagent:openejb-javaagent-4.6.0.jar _\[other params...](other-params....html)
: Title=need the Javaagent?} The Java agent is only required if using OpenJPA as your persistence provider or if using CMP.}
Maven2
In Maven2-can enable the javaagent for your tests by adding this to your Pom.xml file:
<build> <plugins> <!--This configures the surefire plugin to run your tests with the javaagent enabled- <plugin> <groupId>Org.apache.maven.plugins</groupId> <artifactId>Maven-surefire-plugin</artifactId> <configuration> <forkMode>Pertest</forkMode> <argLine>-javaagent:${project.basedir}/target/openejb-javaagent-4.6.0.jar</argLine> <workingDirectory>${project.basedir}/target</workingDirectory> </configuration> </plugin> <!--this tells Maven-to-copy the Openejb-javaagent jar into your target/directory- <!--where surefire can see it and <plugin> <groupId>Org.apache.maven.plugins</groupId> <artifactId>Maven-dependency-plugin</artifactId> <executions> <execution> <id>Copy</id> <phase>Process-resources</phase> <goals> <goal>Copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>Org.apache.openejb</groupId> <artifactid>openejb-javaagent</artifactid>< Span class= "PLN" > <version>4.6.0</version>< Span class= "PLN" > <outputdirectory>${project.build.directory} </outputdirectory> </artifactitem> </artifactitems> </ Configuration> </execution> </executions> </plugin> < /plugins></BUILD>
Adding a javaagent