openjpa-dev mailing list archives

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

    [ https://issues.apache.org/jira/browse/OPENJPA-429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546047
] 

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 = resource.read(b, 0, b.length)) != -1;
                bout.write(b, 0, n))
                ;
            byte[] classBytes = bout.toByteArray();
            if (isAnnotation(classBytes))
                return Class.forName(name, resolve, getClass().
                    getClassLoader());

            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();
        parser.setEnvClassLoader(envLoader);
        parser.setMode(mode);
        parser.parse(cls);

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.

Thanks,
Kevin

> Recent changes have caused problems building with IBM JDK
> ---------------------------------------------------------
>
>                 Key: OPENJPA-429
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-429
>             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:  http://www.nabble.com/build-error-with-trunk-tf4733970.html
> 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
org.apache.openjpa.enhance.TestEnhancementConfiguration".
> 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(ClassLoader.java:228)
>         at java.lang.ClassLoader.defineClass(ClassLoader.java:163)
>         at org.apache.openjpa.lib.util.TemporaryClassLoader.loadClass(TemporaryClassLoader.java:78)
>         at org.apache.openjpa.lib.util.TemporaryClassLoader.loadClass(TemporaryClassLoader.java:44)
>         at com.ibm.oti.reflect.AnnotationHelper.getReturnValueFromEntry(NativeMethod)
>         at com.ibm.oti.reflect.AnnotationHelper.access$000(AnnotationHelper.java:14)
>         at com.ibm.oti.reflect.AnnotationHelper$AnnotationInvocationHandler.invoke(AnnotationHelper.java:104)
>         at $Proxy27.value(Unknown Source)
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseReadOnly(AnnotationPersistenceMetaDataParser.java:1145)
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseMemberAnnotations(AnnotationPersistenceMetaDataParser.java:1105)
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parseClassAnnotations(AnnotationPersistenceMetaDataParser.java:606)
>         at org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.parse(AnnotationPersistenceMetaDataParser.java:351)
>         at org.apache.openjpa.persistence.PersistenceMetaDataFactory.load(PersistenceMetaDataFactory.java:229)
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaDataInternal(MetaDataRepository.java:470)
>         at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:290)
>         at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:240)
>         at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4344)
>         at org.apache.openjpa.ant.PCEnhancerTask.executeOn(PCEnhancerTask.java:89)
>         at org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172)
>         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
>         at org.apache.tools.ant.Task.perform(Task.java:364)
>         at org.apache.tools.ant.Target.execute(Target.java:341)
>         at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
>         at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:443)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
>         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:334)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:272)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:615)
>         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)
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [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.


Mime
View raw message