You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Rahul Thakur <ra...@gmail.com> on 2008/01/12 10:19:43 UTC

ClassNotFoundException: org.apache.openjpa.enhance.InstrumentationFactory

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>

Re: ClassNotFoundException: org.apache.openjpa.enhance.InstrumentationFactory

Posted by Ming Fai Ma <mi...@iugotech.com>.
hey, me too. Need help to build the trunk! :-)

With the following parameters:

mvn.bat install -P jdk1.5 -e


I got the following errors:

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\util\concurrent\Utils.java:[203,22]
sun.misc.Perf is Sun proprietary API and may be removed in a future
release

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingConnection.java:[46,7]
org.apache.openjpa.lib.jdbc.DelegatingConnection is not abstract and
does not override abstract method
createStruct(java.lang.String,java.lang.Object[]) in
java.sql.Connection

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingStatement.java:[37,7]
org.apache.openjpa.lib.jdbc.DelegatingStatement is not abstract and
does not override abstract method isPoolable() in java.sql.Statement

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingResultSet.java:[50,7]
org.apache.openjpa.lib.jdbc.DelegatingResultSet is not abstract and
does not override abstract method
updateNClob(java.lang.String,java.io.Reader) in java.sql.ResultSet

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingPreparedStatement.java:[51,7]
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement is not
abstract and does not override abstract method
setNClob(int,java.io.Reader) in java.sql.PreparedStatement

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingCallableStatement.java:[49,7]
org.apache.openjpa.lib.jdbc.DelegatingCallableStatement is not
abstract and does not override abstract method
setNClob(java.lang.String,java.io.Reader) in
java.sql.CallableStatement

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingDatabaseMetaData.java:[31,7]
org.apache.openjpa.lib.jdbc.DelegatingDatabaseMetaData is not abstract
and does not override abstract method
getFunctionColumns(java.lang.String,java.lang.String,java.lang.String,java.lang.String)
in java.sql.DatabaseMetaData

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\jdbc\DelegatingDataSource.java:[35,7]
org.apache.openjpa.lib.jdbc.DelegatingDataSource is not abstract and
does not override abstract method isWrapperFor(java.lang.Class) in
java.sql.Wrapper

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\util\concurrent\Utils.java:[207,28]
sun.misc.Perf is Sun proprietary API and may be removed in a future
release

D:\Servers\data-hudson\jobs\Open Source -
OpenJPA\workspace\1.0.1\openjpa-lib\src\main\java\org\apache\openjpa\lib\util\concurrent\Utils.java:[210,39]
sun.misc.Perf is Sun proprietary API and may be removed in a future
release


[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:560)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
	at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
	at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
	at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException:
Compilation failure
	at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
	at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
	at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
	at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)

Any devs could help?

regards,
mingfai

On 1/13/08, Rahul Thakur <ra...@gmail.com> wrote:
>
>
> 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* <rahul.thakur.xdev@gmail.com
> > <ma...@gmail.com>> 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>
> >
> >
>

Re: ClassNotFoundException: org.apache.openjpa.enhance.InstrumentationFactory

Posted by Rahul Thakur <ra...@gmail.com>.
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* <rahul.thakur.xdev@gmail.com 
> <ma...@gmail.com>> 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>
>
>

Re: ClassNotFoundException: org.apache.openjpa.enhance.InstrumentationFactory

Posted by Ming Fai Ma <mi...@iugotech.com>.
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 <ra...@gmail.com> 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>
>