I am hazarding a guess here that the InstrumentationFactory is to do with enhancement of JPA entities. I thought, for some reason, that the JPA entities were no longer required to be enhanced (or is that with the 1.1.0-SNAPSHOT).

Anyway, I have tried building the trunk for OpenJPA from scratch to see if I could use the 1.1.0-SNAPSHOT jars, but I the build fails. Are any OpenJPA devs tuned in to this thread who can provide some inputs?

Thanks,
Rahul


Ming Fai Ma wrote:
hi,

I got exactly the same problem. My version is 1.1.0 snapshot on 2008-01-12, running JBoss 4.2.2 on JDK 6. By looking at the issue in debug mode, it looks like Sun's InstrumentationImpl tries to lookup the InstrumentationFactory at a top level classloader, but the OpenJPA library is available only in a bottom level one (inside JBoss UnifiedClassloader)

I just did a quick test to put the InstrumentationFactory package as a jar to the JRE/lib/ext and I can get rid of the exception. And I also did a debug trace and i found the exception is thrown from the following piece of code:
org.apache.openjpa.enhance.InstrumentationFactory
vm.getClass().getMethod("loadAgent", new Class[] { String.class }).
            invoke(vm, new Object[] { agentPath });  // exception!

Not sure what would be the impact but I've patched the InstrumentationFactory so that when it creates the temporary jar, it writes the InstrumentationFactory class as well. The modified InstrumentationFactory is attached.

What exactly is the InstrumentationFactory about?

regards,
mingfai


Reference:

    private static String getAgentJar() throws IOException {
File file = File.createTempFile(InstrumentationFactory.class.getName (),
                ".jar");
        file.deleteOnExit();

ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(file));
        zout.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));

PrintWriter writer = new PrintWriter(new OutputStreamWriter(zout));

        writer
                .println("Agent-Class: "
                        + InstrumentationFactory.class.getName ());
        writer.println("Can-Redefine-Classes: true");
        writer.println("Can-Retransform-Classes: true");
        writer.flush();

        zout.closeEntry();

String strFilename = "org/apache/openjpa/enhance/InstrumentationFactory.class";
        zout.putNextEntry(new ZipEntry(strFilename));

InputStream in = InstrumentationFactory.class.getResourceAsStream("/"
                + strFilename);
        copy(in, zout);
        zout.close();

        return file.getAbsolutePath ();
    }

On 1/12/08, *Rahul Thakur* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi,

    I am using OpenJPA 1.0.1 for a web application. When the web
    application
    starts up (Tomcat 6), the server logs show the stack trace below.

    The trace is not really helpful as that class is there in the JAR
    under
    WEB-INF/lib directory, and google'ing didn't help either; so I am not
    sure where to start investigating into this now :-(

    Appreciate any pointers.

    Thanks in advance,
    Rahul

    <snip>
    DEBUG ArrayConverter -     No conversion required, value is already a
    java.net.URL[]
    INFO  StartupServlet - DTO <--> JPA entity registration completed!
    DEBUG StoreModule - Configuring module:
    com.google.code.cisx.store.StoreModule
    java.lang.ClassNotFoundException:
    org.apache.openjpa.enhance.InstrumentationFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass (ClassLoader.java:251)
        at
    
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:280)
        at
    
sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java
    :348)
    12/01/2008 22:15:30 org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    </snip>


Reply via email to