Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.0-M3
    • Component/s: kernel
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      As reported in the dev forum [1] InstrumentationFactory.class.getProtectionDomain().getCodeSource() returns null, causing a NPE.

      Caused by: java.lang.NullPointerException
      at org.apache.openjpa.enhance.InstrumentationFactory.getAgentJar(InstrumentationFactory.java:204)
      at org.apache.openjpa.enhance.InstrumentationFactory.access$200(InstrumentationFactory.java:47)
      at org.apache.openjpa.enhance.InstrumentationFactory$1.run(InstrumentationFactory.java:99)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.apache.openjpa.enhance.InstrumentationFactory.getInstrumentation(InstrumentationFactory.java:87)
      at org.apache.openjpa.enhance.PCEnhancerAgent.loadDynamicAgent(PCEnhancerAgent.java:95)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.loadAgent(PersistenceProviderImpl.java:243)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:91)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:119)
      at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:55)
      at javax.persistence.Persistence.createFactory(Persistence.java:172)
      ... 51 more

      [1] http://n2.nabble.com/Error-loading-agent-with-Openjpa2-td3024299.html

      1. OPENJPA-1119.PATCH
        7 kB
        Rick Curtis
      2. OPENJPA-1119-dwoods.patch
        6 kB
        Donald Woods

        Activity

        Hide
        Rick Curtis added a comment -

        Made code change to detect when the ProtectionDomain returns NULL for a code source.

        Show
        Rick Curtis added a comment - Made code change to detect when the ProtectionDomain returns NULL for a code source.
        Hide
        Rick Curtis added a comment -

        Refactored code for a more 'complete' fix. This new patch fixes the NPE, but also does some additional manifest validation.

        If it is determined that the InstrumentationFactory was loaded from a jar file, that jar file is opened up and the manifest is examined. If the InstrumentationFactory is defined as the Agent-Class, we will go ahead and use that as an argument to the attach api. If the InstrumentationFactory isn't defined as the Agent-Class, we will go off and create a temporary file.

        Currently the openjpa-all.xxxx.jar and openjpa-kernal.xx.jar files do not have the InstrumentationFactory defined as the Agent-Class and I will address that issue in OPENJPA-1117. I can hypothesize that the InstrumentationFactory could be loaded from a jar that doesn't have the Agent-Class defined if a user were to repackage OpenJPA and not properly copy the manifest attributes over.

        While testing this patch I uncovered 33 new test failures when running on Sun 1.6. After looking closer at the failures, most of the tests are named TestUnenhancedxxxxx. After looking at the commit comment for OPENJPA-293, it appears that it was known that these tests would fail when using redefinition. Now that it is possible to use redefinition, these tests are failing. Since it appears [1] that we are going to disable support for the redefinition(subclassing) I am going to exclude these failing tests from the build. Three other tests are also failing due to the dynamic enhancer, so I am excluding those tests also.

        I also updated the openjpa-persistence-jdbc/pom.xml and added -XX:MaxPermSize=256m to the test.jvm.arguments to take care of the Sun PermGen OOM problems that I run into when running on Sun 1.6.

        [1]http://n2.nabble.com/VOTE-Turn-off-enhancement-by-subclassing-as-the-default-td1616140.html#a2950000

        Show
        Rick Curtis added a comment - Refactored code for a more 'complete' fix. This new patch fixes the NPE, but also does some additional manifest validation. If it is determined that the InstrumentationFactory was loaded from a jar file, that jar file is opened up and the manifest is examined. If the InstrumentationFactory is defined as the Agent-Class, we will go ahead and use that as an argument to the attach api. If the InstrumentationFactory isn't defined as the Agent-Class, we will go off and create a temporary file. Currently the openjpa-all.xxxx.jar and openjpa-kernal.xx.jar files do not have the InstrumentationFactory defined as the Agent-Class and I will address that issue in OPENJPA-1117 . I can hypothesize that the InstrumentationFactory could be loaded from a jar that doesn't have the Agent-Class defined if a user were to repackage OpenJPA and not properly copy the manifest attributes over. While testing this patch I uncovered 33 new test failures when running on Sun 1.6. After looking closer at the failures, most of the tests are named TestUnenhancedxxxxx. After looking at the commit comment for OPENJPA-293 , it appears that it was known that these tests would fail when using redefinition. Now that it is possible to use redefinition, these tests are failing. Since it appears [1] that we are going to disable support for the redefinition(subclassing) I am going to exclude these failing tests from the build. Three other tests are also failing due to the dynamic enhancer, so I am excluding those tests also. I also updated the openjpa-persistence-jdbc/pom.xml and added -XX:MaxPermSize=256m to the test.jvm.arguments to take care of the Sun PermGen OOM problems that I run into when running on Sun 1.6. [1] http://n2.nabble.com/ VOTE -Turn-off-enhancement-by-subclassing-as-the-default-td1616140.html#a2950000
        Hide
        Michael Dick added a comment -

        Hi Rick,

        Before we commit the patch could we make the perm gen size configurable? 256m doesn't seem to be enough for 64 bit JVMs so it might make sense to user a variable in pom.xml; set the variable to a default value (if we can it'd be neat to set it differently for 64 vs 32 bit jvms automagically), but let the build override it with -Dtest.permgen.size=512m.

        Sorry I didn't try it on 64 bit JVMs until now.

        Show
        Michael Dick added a comment - Hi Rick, Before we commit the patch could we make the perm gen size configurable? 256m doesn't seem to be enough for 64 bit JVMs so it might make sense to user a variable in pom.xml; set the variable to a default value (if we can it'd be neat to set it differently for 64 vs 32 bit jvms automagically), but let the build override it with -Dtest.permgen.size=512m. Sorry I didn't try it on 64 bit JVMs until now.
        Hide
        Rick Curtis added a comment -

        Updated the patch so that the jvm arg -XX:MaxPermSize is configurable via -Dtest.permgen.size=xxxm. I also increased the default value to 512m rather than 256m.

        -Rick

        Show
        Rick Curtis added a comment - Updated the patch so that the jvm arg -XX:MaxPermSize is configurable via -Dtest.permgen.size=xxxm. I also increased the default value to 512m rather than 256m. -Rick
        Hide
        Michael Dick added a comment -

        Thanks Rick. I haven't found a value that works on my 64 bit config with Sun JDK6 (tried up to 1024m which seems extreme). When I find a value that works I'll commit the patch.

        Show
        Michael Dick added a comment - Thanks Rick. I haven't found a value that works on my 64 bit config with Sun JDK6 (tried up to 1024m which seems extreme). When I find a value that works I'll commit the patch.
        Hide
        Donald Woods added a comment -

        Michael, which OS are you seeing OOM for?

        I'm running with the 64bit Sun JDK 1.6 on MacOSX -
        java version "1.6.0_13"
        Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
        Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)

        with the following in o-p-j/pom.xml -
        + <test.jvm.maxpermsize>256m</test.jvm.maxpermsize>
        + <test.jvm.maxheapsize>512m</test.jvm.maxheapsize>

        and MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"

        Show
        Donald Woods added a comment - Michael, which OS are you seeing OOM for? I'm running with the 64bit Sun JDK 1.6 on MacOSX - java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211) Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode) with the following in o-p-j/pom.xml - + <test.jvm.maxpermsize>256m</test.jvm.maxpermsize> + <test.jvm.maxheapsize>512m</test.jvm.maxheapsize> and MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
        Hide
        Michael Dick added a comment -

        It's not actually an OOM, it's a case of running out of perm gen space. I've only see it happen with Linux + Sun JDK6.. Maybe I need to upgrade my JDK (and only with the patch applied).

        $java -version
        java version "1.6.0_13"
        Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
        Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)

        Show
        Michael Dick added a comment - It's not actually an OOM, it's a case of running out of perm gen space. I've only see it happen with Linux + Sun JDK6.. Maybe I need to upgrade my JDK (and only with the patch applied). $java -version java version "1.6.0_13" Java(TM) SE Runtime Environment (build 1.6.0_13-b03) Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
        Hide
        Donald Woods added a comment -

        Updated patch after OPENJPA-1117 commit that works for me w/ Sun 64bit JDK 6 on MacOSX (if you exclude the criteria tests.) Will try running on 64bit Linux before committing.

        Show
        Donald Woods added a comment - Updated patch after OPENJPA-1117 commit that works for me w/ Sun 64bit JDK 6 on MacOSX (if you exclude the criteria tests.) Will try running on 64bit Linux before committing.
        Hide
        Donald Woods added a comment -

        Only seeing the OOM PermGen space on 64bit Sun JDK 6 on Linux (SLES 10 SP 2 on x86_64 in this case)

        Show
        Donald Woods added a comment - Only seeing the OOM PermGen space on 64bit Sun JDK 6 on Linux (SLES 10 SP 2 on x86_64 in this case)

          People

          • Assignee:
            Rick Curtis
            Reporter:
            Rick Curtis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development