1 Reply Latest reply on Nov 13, 2012 4:53 PM by Cdelahun-Oracle

    How to Enable Eclipselink Dynamic Weaving in Tomcat?

      I'd like to enable dynamic weaving in Tomcat 7 but all efforts thus far have been unsuccessful. I have been able to do so from a J2SE command-line app.

      JAVA_OPTS="-Xbootclasspath/a:<path to>/javax.persistence_2.0.4.v201112161009.jar -javaagent:<path to>/eclipselink.jar"

      With the persistence jar appended to the boot classpath, I get no errors nor does weaving occur. Google revealed others elsewhere with similar issues.

      I can statically weave if I must but at least for development, dynamic would be much preferred.

      Any suggestions?

        • 1. Re: How to Enable Eclipselink Dynamic Weaving in Tomcat?
          My understanding from http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial was that Tomcat was not a Java EE 5 compatible server. This means that Tomcat isn't creating the EMF for the application, and so there is no way for the provider to register the ClassTransformer used for weaving with the application classloader before it has loaded the application entity classes. Placing the agent and persistence unit on the classpath of the server only registers the transformer with the server classloader, not the classloader that gets used to load the application.

          I don't know anyone to look to far into it or how far they got before deciding just to use static weaving. You might also be able to use Spring with in Tomcat as the JPA container and configure Tomcat to use its custom application classloader - which it can then be instrumented with a transformer for weaving as described here:

          If you are interested, if it works with Spring using a custom classloader it should be possible, but I don't know Tomcat or Spring internals to be of much assistance. If you decide to look into it, see the EclipseLink PersistenceProvider class createContainerEntityManagerFactory method for what containers call to get the transformer to register with the classloader.

          Best Regards,