OpenJPA
  1. OpenJPA
  2. OPENJPA-1811

Dynamic load of enhancer agent on Mac OS X fails

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.1.0
    • Component/s: Enhance, UnenhancedClasses
    • Labels:
      None
    • Environment:
      Mac

      Description

      Splitting out this item from OPENJPA-1804.
      The dynamic loading of the enhancer agent on Mac OS X w/ Java 1.6.0 fails due to the packaging differences on the Mac, where instead of a tools.jar, there is a 1.6.0/Classes/classes.jar that we should be using instead.

        Issue Links

          Activity

          Hide
          Donald Woods added a comment -

          Before fix -
          768 db TRACE [main] openjpa.Enhance - org.apache.openjpa.enhance.InstrumentationFactorygetInstrumentation() _disabled: _inst:null_dynamicallyInstall:true
          768 db TRACE [main] openjpa.Enhance - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – couldn't find /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar
          769 db WARN [main] openjpa.Enhance - Creating subclass for "[class openjpatest.Group, class openjpatest.Organization, class openjpatest.AddressBook]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.

          After fix -
          64 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.getInstrumentation() _inst:null _dynamicallyInstall:true
          66 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – couldn't find default /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar
          66 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – found /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar
          . . .
          1537 db INFO [main] openjpa.Enhance - Creating subclass and redefining methods for "[class openjpatest.Group, class openjpatest.Organization]". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.

          Show
          Donald Woods added a comment - Before fix - 768 db TRACE [main] openjpa.Enhance - org.apache.openjpa.enhance.InstrumentationFactorygetInstrumentation() _disabled: _inst:null_dynamicallyInstall:true 768 db TRACE [main] openjpa.Enhance - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – couldn't find /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar 769 db WARN [main] openjpa.Enhance - Creating subclass for " [class openjpatest.Group, class openjpatest.Organization, class openjpatest.AddressBook] ". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead. After fix - 64 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.getInstrumentation() _inst:null _dynamicallyInstall:true 66 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – couldn't find default /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar 66 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – found /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar . . . 1537 db INFO [main] openjpa.Enhance - Creating subclass and redefining methods for " [class openjpatest.Group, class openjpatest.Organization] ". This means that your application will be less efficient than it would if you ran the OpenJPA enhancer.
          Hide
          Donald Woods added a comment -

          Committed revision 1000209.

          Show
          Donald Woods added a comment - Committed revision 1000209.
          Hide
          Willis Blackburn added a comment -

          Thanks for fixing this!

          I noticed that the log message says that OpenJPA will still produce subclasses for the attach API enhancer. Is the attach API enhancer unable to actually modify the classes being loaded?

          Show
          Willis Blackburn added a comment - Thanks for fixing this! I noticed that the log message says that OpenJPA will still produce subclasses for the attach API enhancer. Is the attach API enhancer unable to actually modify the classes being loaded?
          Hide
          Willis Blackburn added a comment -

          Definitely confused by log message 1537 since the docs say that the log message will be:

          OpenJPA dynamically loaded the class enhancer. Any classes that were not enhanced at build time will be enhanced when they are loaded by the JVM.

          Show
          Willis Blackburn added a comment - Definitely confused by log message 1537 since the docs say that the log message will be: OpenJPA dynamically loaded the class enhancer. Any classes that were not enhanced at build time will be enhanced when they are loaded by the JVM.
          Hide
          Donald Woods added a comment -

          This is due to the persistence.xml not listing all of the classes. The Javaagent loaded enhancer and Dynamically loaded enhancer behave the same, in that when a <class> list is provided, then only those classes will get pre-enhanced.
          http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_enhance_runtime
          Section 2.3 - "If you declare a persistent class list, OpenJPA will only search for metadata for classes in that list. "
          I'll add the same note to Section 2.4 using OPENJPA-1804.

          Once I added the other 2 classes to the persistence.xml so they were all listed -
          <class>openjpatest.AddressBook</class>
          <class>openjpatest.Group</class>
          <class>openjpatest.Organization</class>
          <class>openjpatest.EmailAddress</class>
          <class>openjpatest.HostName</class>
          then your expected behavior appears -
          . . .
          79 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.getInstrumentation() _inst:null _dynamicallyInstall:true
          82 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – couldn't find default /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar
          83 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – found /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar
          . . .
          210 db TRACE [main] openjpa.MetaData - Found 5 classes with metadata in 7 milliseconds.
          216 db TRACE [main] openjpa.MetaData - Clearing metadata repository "org.apache.openjpa.meta.MetaDataRepository@761eec35".
          707 db INFO [main] openjpa.Runtime - OpenJPA dynamically loaded the class enhancer. Any classes that were not enhanced at build time will be enhanced when they are loaded by the JVM.
          . . .
          1588 db WARN [main] openjpa.Enhance - An exception was thrown while attempting to perform class file transformation on "openjpatest/Group":
          <openjpa-2.1.0-SNAPSHOT-r422266:999559M fatal user error> org.apache.openjpa.util.MetaDataException: Errors encountered while resolving metadata. See nested exceptions for details.
          . . .
          Caused by: <openjpa-2.1.0-SNAPSHOT-r422266:999559M nonfatal user error> org.apache.openjpa.util.MetaDataException: No metadata was found for type "class java.lang.Object". The class is not enhanced.
          . . .

          Show
          Donald Woods added a comment - This is due to the persistence.xml not listing all of the classes. The Javaagent loaded enhancer and Dynamically loaded enhancer behave the same, in that when a <class> list is provided, then only those classes will get pre-enhanced. http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_enhance_runtime Section 2.3 - "If you declare a persistent class list, OpenJPA will only search for metadata for classes in that list. " I'll add the same note to Section 2.4 using OPENJPA-1804 . Once I added the other 2 classes to the persistence.xml so they were all listed - <class>openjpatest.AddressBook</class> <class>openjpatest.Group</class> <class>openjpatest.Organization</class> <class>openjpatest.EmailAddress</class> <class>openjpatest.HostName</class> then your expected behavior appears - . . . 79 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.getInstrumentation() _inst:null _dynamicallyInstall:true 82 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – couldn't find default /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/tools.jar 83 db TRACE [main] openjpa.Runtime - org.apache.openjpa.enhance.InstrumentationFactory.findToolsJar() – found /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar . . . 210 db TRACE [main] openjpa.MetaData - Found 5 classes with metadata in 7 milliseconds. 216 db TRACE [main] openjpa.MetaData - Clearing metadata repository "org.apache.openjpa.meta.MetaDataRepository@761eec35". 707 db INFO [main] openjpa.Runtime - OpenJPA dynamically loaded the class enhancer. Any classes that were not enhanced at build time will be enhanced when they are loaded by the JVM. . . . 1588 db WARN [main] openjpa.Enhance - An exception was thrown while attempting to perform class file transformation on "openjpatest/Group": <openjpa-2.1.0-SNAPSHOT-r422266:999559M fatal user error> org.apache.openjpa.util.MetaDataException: Errors encountered while resolving metadata. See nested exceptions for details. . . . Caused by: <openjpa-2.1.0-SNAPSHOT-r422266:999559M nonfatal user error> org.apache.openjpa.util.MetaDataException: No metadata was found for type "class java.lang.Object". The class is not enhanced. . . .
          Hide
          Michael Dick added a comment -

          Closing issue which has been resolved for some time. If you believe the issue is not resolved please reopen or open a new issue.

          Show
          Michael Dick added a comment - Closing issue which has been resolved for some time. If you believe the issue is not resolved please reopen or open a new issue.

            People

            • Assignee:
              Donald Woods
              Reporter:
              Willis Blackburn
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development