openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <>
Subject [jira] Commented: (OPENJPA-429) Recent changes have caused problems building with IBM JDK
Date Tue, 27 Nov 2007 23:28:43 GMT


Kevin Sutter commented on OPENJPA-429:

Making some progress on this Issue, but still don't have it nailed.  I have determined that
this problem only exists with the IBM JDK because the UpdateAction enum class is not loaded
until it is used by the IBM JDK.  With the Sun JDK, the UpdateAction enum is loaded when the
ReadOnly annotation is loaded.  Thus, we avoid this whole path.

When the UpdateAction enum is attempted to be loaded (using the IBM JDK), we are using the
TemporaryClassLoader because that is set on the Parser.  The use of the TCL for this loading
is causing a problem when attempting to defineClass via this code snippet:

        String resourceName = name.replace('.', '/') + ".class";
        InputStream resource = getResourceAsStream(resourceName);
        if (resource == null)
            throw new ClassNotFoundException(name);

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        byte[] b = new byte[1024];
        try {
            for (int n = 0; (n =, 0, b.length)) != -1;
                bout.write(b, 0, n))
            byte[] classBytes = bout.toByteArray();
            if (isAnnotation(classBytes))
                return Class.forName(name, resolve, getClass().

            try {
                return defineClass(name, classBytes, 0, classBytes.length);
            } catch (SecurityException e) {
                // possible prohibited package: defer to the parent
                return super.loadClass(name, resolve);
        } catch (IOException ioe) {
            // defer to the parent
            return super.loadClass(name, resolve);

The call to defineClass ends up with the ClassFormatError.

I found the "magic" option on the PCEnhancer to turn off the use of the TCL (-tcl false) and
the ClassFormatError goes away.  :-)

The TCL is set on the parser in the load() method of the PersistenceMetaDataFactory:

        AnnotationPersistenceMetaDataParser parser = getAnnotationParser();

I've run out of time today, but if somebody could explain why this "magic" option of turning
off the TCL exists, maybe it will help me with determining the source of our problem with
the IBM JDK.  Normal usage of the TCL seems to work just fine, but using it to load this enum
class seems to blow chunks.  Any ideas for further debugging would be appreciated.


> Recent changes have caused problems building with IBM JDK
> ---------------------------------------------------------
>                 Key: OPENJPA-429
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: build / infrastructure
>    Affects Versions: 1.1.0
>            Reporter: Kevin Sutter
>            Assignee: Kevin Sutter
> This started on the dev mailing list:
> Trunk (1.1.0) is not building with the IBM JDK.  It is building okay with the Sun JDK.
 It's not always consistent, but an example call stack is as follows:
> 2000  test  WARN   [main] openjpa.Enhance - Type "class org.apache.openjpa.enhance.TestEnhancementConfiguration"
has no metadata; enhancing as persistence aware. If you intended for "class org.apache.openjpa.enhance.TestEnhancementConfiguration"
to be persistence-capable, then this means that OpenJPA could not find any metadata for "class
> This can happen if the directory containing your metadata is not in your CLASSPATH, or
if your metadata files are not named properly. See the documentation on metadata placement
for more information.
> java.lang.ClassFormatError
>         at java.lang.ClassLoader.defineClassImpl(Native Method)
>         at java.lang.ClassLoader.defineClass(
>         at java.lang.ClassLoader.defineClass(
>         at org.apache.openjpa.lib.util.TemporaryClassLoader.loadClass(
>         at org.apache.openjpa.lib.util.TemporaryClassLoader.loadClass(
>         at
>         at$000(
>         at$AnnotationInvocationHandler.invoke(
>         at $Proxy27.value(Unknown Source)
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseReadOnly(
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseMemberAnnotations(
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseClassAnnotations(
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parse(
>         at org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaData(
>         at org.apache.openjpa.enhance.PCEnhancer.<init>(
>         at
>         at org.apache.openjpa.ant.PCEnhancerTask.executeOn(
>         at org.apache.openjpa.lib.ant.AbstractTask.execute(
>         at
>         at
>         at
>         at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(
>         at org.apache.maven.plugin.antrun.AntRunMojo.execute(
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(
>         at org.apache.maven.DefaultMaven.doExecute(
>         at org.apache.maven.DefaultMaven.execute(
>         at org.apache.maven.cli.MavenCli.main(
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
>         at java.lang.reflect.Method.invoke(
>         at org.codehaus.classworlds.Launcher.launchEnhanced(
>         at org.codehaus.classworlds.Launcher.launch(
>         at org.codehaus.classworlds.Launcher.mainWithExitCode(
>         at org.codehaus.classworlds.Launcher.main(
> [INFO]
> ------------------------------------------------------------------------
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Error executing ant tasks
> Embedded error: java.lang.ClassFormatError

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message