You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Adam Hardy <ad...@cyberspaceroad.com> on 2009/02/06 16:05:27 UTC

enhancement roadblock

I need to enhance the entities in my current project because otherwise with 
'fall-back' enhancement, the core functionality of the application cannot be 
run, due to StackOverflowErrors (because of the large number of unenhanced 
entities that OpenJPA has to deal with, according to JIRA and the mailing list 
archives).

I'm running Java 1.6.0_12 so I think I'm right in saying that the runtime 
enhancement used by OpenJPA on the unenhanced entities will be Java 6 class 
retransformation - but it's causing the issue above.

I have tried specifying the javaagent as a JVM option, but I have some problems 
with this in the web server. I'm using tomcat and it looks like I have to put my 
complete webapp into tomcat shared directory so that the enhancement process has 
the classes available at boot.

My entity beans have a fair amount of encapsulated business logic so there are a 
fair number of external utility classes and jar dependencies.

Is there a way to configure the javaagent on a per-website basis for tomcat?

Secondly I have configured the openjpa-maven-plugin so that it launches the 
PCEnhancer during my maven build, but the x*?!"@ app doesn't run with the 
build-time enhanced classes.

It just hangs while loading the webapp, when Spring tries to load the managers 
(the transaction-wrapped business tier). That's both during integration testing 
with JUnit and when deployed in tomcat.

I think that sums up my current situation. Can anyone suggest a way forward?

regards
Adam

Re: enhancement roadblock

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Yes I was attempting to enhance the entity superclass which is in a jar - from 
the framework project. The implementation project depends on the framework 
project for stuff like common superclasses (not just JPA stuff).

I hadn't thought about where the enhanced class would be written to - I just 
assumed it would get put in the output directory. But I guess that's the output 
stream throwing the exception - blast!

OK, so I'll have to copy that superclass into each project that uses it, no big 
deal.



Kevin Sutter on 06/02/09 18:59, wrote:
> First thing that jumped out at me...  Are you attempting to enhance classes
> that are contained within a jar?  We can't write enhanced classes back out
> to a jar file.  The classes have to be enhanced outside of a jar and then
> re-packaged.  Maybe you already realized this and are working around it, but
> the error message sort of indicated the use of classes within a jar file...
> 
> I've also asked another member of the team to dive into your question.  He's
> developing a lot of experience with the various means of enhancement (maven,
> ant, command line, eclipse, etc).  Unfortunately, I think he is out this
> afternoon...
> 
> Kevin
> 
> On Fri, Feb 6, 2009 at 12:12 PM, Adam Hardy <ad...@cyberspaceroad.com>wrote:
> 
>> I am concentrating now on getting build-time enhancement working.
>>
>> I thought I'd try with the maven-antrun-plugin using the config shown
>> (copied from the list here) but I get this error - the offending class is an
>> entity superclass which is in the jar in the error message. Java knows
>> exactly which jar it is in, yet can't find it so I guess I've missed a
>> simple piece of the config.
>>
>>   [java] Caused by: java.io.FileNotFoundException:
>> file:/home/java/m2-repo/org/permacode/atomic/0.0.1-SNAPSHOT/atomic-0.0.1-SNAPSHOT.jar!/org/permacode/atomic/domain/AtomicEntity.class
>> (No such file or directory)
>>     [java]     at java.io.FileOutputStream.open(Native Method)
>>     [java]     at
>> java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>>     [java]     at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
>>     [java]     at serp.bytecode.BCClass.write(BCClass.java:179)
>>     [java]     at
>> org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:593)
>>
>>
>> This is the PCEnhancer launch config:
>>
>>
>>      <plugin>
>>        <artifactId>maven-antrun-plugin</artifactId>
>>        <executions>
>>          <execution>
>>            <phase>process-classes</phase>
>>            <configuration>
>>              <tasks>
>>                <path id="cp">
>>                  <path refid="maven.test.classpath" />
>>                  <path refid="maven.compile.classpath" />
>>                  <path refid="maven.runtime.classpath" />
>>                  <path refid="maven.dependency.classpath" />
>>                </path>
>>                <fileset id="enhance.path.ref" dir=".">
>>                  <include
>>
>> name="${build.outputDirectory}/org/permacode/patternrepo/domain/entity/*.class"
>> />
>>                  <include
>>
>> name="${build.testOutputDirectory}/org/permacode/patternrepo/domain/entity/*.class"
>> />
>>                </fileset>
>>                <echo message="Enhancing classes...." />
>>                <java classname="org.apache.openjpa.enhance.PCEnhancer"
>>                  classpathref="cp" dir="${build.outputDirectory}"
>>                  fork="true">
>>                  <arg line="-properties
>> META-INF/persistence.xml#OpenJpaJDBC" />
>>                </java>
>>                <echo message="Enhancing classes for OpenJPA done!" />
>>              </tasks>
>>            </configuration>
>>            <goals>
>>              <goal>run</goal>
>>            </goals>
>>          </execution>
>>        </executions>
>>      </plugin>
>>
>> It seems I might need to reference the entity bean in the fileset
>> 'enhance.path.ref' but I'm not sure how to include a jar with a class in
>> there.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Kevin Sutter on 06/02/09 15:45, wrote:
>>
>>> Hi Adam,
>>> You are right in your thinking not to use the "fall back" enhancement
>>> processing for production use.  It was meant as an easy "out of the box"
>>> experience for simple apps.  It was not meant for production use.  All of
>>> this has been documented in our forums and JIRAs (which you have already
>>> found).
>>>
>>> We are doing more investigation into the Java 6 class redefinition
>>> support.
>>> This doesn't seem to be 100% complete either, at least for some scenarios.
>>>
>>> So, the best bet (and most proven) is to stick with standard
>>> PCEnhancement.
>>> This can be done in several ways -- statically during build, or
>>> dynamically
>>> via the -javaagent approach or tied into the classloader of a suitable
>>> EJB3
>>> container.
>>>
>>> In the WebSphere environment, the classloader enhancement process is tied
>>> into both the EJB and Web Containers (same Java EE runtime
>>> implementation).
>>> But, it doesn't sound like this linkage is provided by Tomcat.  I have no
>>> direct experience with Tomcat -- just reading your note below.
>>>
>>> So, it sounds like your best approach is to do the enhancement during the
>>> build process.  If you are experiencing un-enhanced entities at runtime,
>>> then either your build-time enhancement is not working, or your packaged
>>> application isn't picking up the enhanced classes, or you accidentally
>>> have
>>> non-enhanced entities also available via your Tomcat environment.
>>>
>>> Because we don't want our WebSphere customers to accidentally use the
>>> "fall
>>> back" enhancement, we actually turn this off for OpenJPA within WebSphere.
>>> You can do this with this property in your persistence.xml file:
>>>
>>> openjpa.RuntimeUnenhancedClasses = warn
>>>
>>> By default, this is set to "supported".  Another value is "unsupported",
>>> which just detects the problem a little earlier.  By using "warn", you
>>> still
>>> won't fall into the "fall back" enhancement and you will get some more
>>> helpful messages concerning the entities that have not been enhanced.
>>>
>>> I don't have a specific, complete answer to your situation.  But, maybe if
>>> you can experiment a bit with the above information and provide some more
>>> details, we can help get your environment working to your expectations.
>>> Good luck!
>>>
>>> Thanks,
>>> Kevin
>>>
>>> On Fri, Feb 6, 2009 at 9:05 AM, Adam Hardy <adam.sql@cyberspaceroad.com
>>>> wrote:
>>>  I need to enhance the entities in my current project because otherwise
>>>> with
>>>> 'fall-back' enhancement, the core functionality of the application cannot
>>>> be
>>>> run, due to StackOverflowErrors (because of the large number of
>>>> unenhanced
>>>> entities that OpenJPA has to deal with, according to JIRA and the mailing
>>>> list archives).
>>>>
>>>> I'm running Java 1.6.0_12 so I think I'm right in saying that the runtime
>>>> enhancement used by OpenJPA on the unenhanced entities will be Java 6
>>>> class
>>>> retransformation - but it's causing the issue above.
>>>>
>>>> I have tried specifying the javaagent as a JVM option, but I have some
>>>> problems with this in the web server. I'm using tomcat and it looks like
>>>> I
>>>> have to put my complete webapp into tomcat shared directory so that the
>>>> enhancement process has the classes available at boot.
>>>>
>>>> My entity beans have a fair amount of encapsulated business logic so
>>>> there
>>>> are a fair number of external utility classes and jar dependencies.
>>>>
>>>> Is there a way to configure the javaagent on a per-website basis for
>>>> tomcat?
>>>>
>>>> Secondly I have configured the openjpa-maven-plugin so that it launches
>>>> the
>>>> PCEnhancer during my maven build, but the x*?!"@ app doesn't run with the
>>>> build-time enhanced classes.
>>>>
>>>> It just hangs while loading the webapp, when Spring tries to load the
>>>> managers (the transaction-wrapped business tier). That's both during
>>>> integration testing with JUnit and when deployed in tomcat.
>>>>
>>>> I think that sums up my current situation. Can anyone suggest a way
>>>> forward?


Re: [Resolved] enhancement roadblock - but with a bug

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
ok, here it is:

https://issues.apache.org/jira/browse/OPENJPA-914



Michael Dick on 09/02/09 14:08, wrote:
> Hi Adam,
> 
> The issue caused you more than enough pain - please go ahead and open a JIRA
> issue. I can't promise that we'll have it fixed immediately but we should do
> a better job here.
> 
> -mike
> 
> On Mon, Feb 9, 2009 at 7:19 AM, Adam Hardy <ad...@cyberspaceroad.com>wrote:
> 
>> After a frustrating time building a test project to isolate what I thought
>> was a new issue, I discovered that there was nothing wrong with my project,
>> I had just  forgotten to add one entity class to the PCEnhancer command
>> during my build-time enhancement routine.
>>
>> So the class was unenhanced.
>>
>> With RuntimeUnenhancedClasses set to unsupported, instead of receiving a
>> "cannot run with unenhanced classes" error, OpenJPA threw the exceptions
>> below.
>>
>> I think this definitely qualifies as a bug - OpenJPA is throwing the wrong
>> exception. It definitely misled me for a while.
>>
>> Shall I open a JIRA for it?
>>
>>
>> Regards
>> Adam
>>
>>
>> Adam Hardy on 08/02/09 23:46, wrote:
>>
>>> Following on from my initial response, I copied the superclass into the
>>> same project so that the enhancer can process the class file properly.
>>>
>>> It looks like I'm taking the scenic route around all the OpenJPA issues
>>> right now.
>>>
>>> I hit this problem with enhanced files that doesn't happen with the
>>> unenhanced.
>>>
>>> I carefully set the property openjpa.RuntimeUnenhancedClasses=unsupported
>>> so I can be certain I am running with the enhanced classes.
>>>
>>> So with build-time enhancement, I get stacktraces of exceptions as
>>> follows, although it's not clear which is the original cause:
>>>
>>> Caused by: java.lang.IllegalStateException: No registered metadata for
>>> type "class org.permacode.patternrepo.domain.entity.CollatedRun".
>>>        at
>>> org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
>>>
>>> NestedThrowables:
>>> <openjpa-1.2.0-r422266:683325 fatal user error>
>>> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type
>>> "org.permacode.patternrepo.domain.entity.TestAnalysis" due to previous
>>> errors resolving related type
>>> "org.permacode.patternrepo.domain.entity.CollatedRun".
>>>        at
>>> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731)
>>>
>>>
>>> <openjpa-1.2.0-r422266:683325 fatal user error>
>>> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type
>>> "org.permacode.patternrepo.domain.entity.Weighting" due to previous errors
>>> resolving related type
>>> "org.permacode.patternrepo.domain.entity.CollatedRun".
>>>        at
>>> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731)
>>>
>>>
>>> <openjpa-1.2.0-r422266:683325 fatal user error>
>>> org.apache.openjpa.persistence.ArgumentException: Attempt to map
>>> "org.permacode.patternrepo.domain.entity.CollatedRun.portfolio" failed: the
>>> owning entity is not mapped.
>>>        at
>>> org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:547)
>>>
>>> java.lang.IllegalStateException: No registered metadata for type "class
>>> org.permacode.patternrepo.domain.entity.CollatedRun".        at
>>> org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
>>>
>>>
>>> I figure that the "no registered metadata for type ..." must be the
>>> original since it appears first and last. It runs fine unenhanced, so what
>>> can it be? Do enhanced entities only work with annotations? These entities
>>> are all mapped via xml.
>>>
>>
> 


Re: [Resolved] enhancement roadblock - but with a bug

Posted by Michael Dick <mi...@gmail.com>.
Hi Adam,

The issue caused you more than enough pain - please go ahead and open a JIRA
issue. I can't promise that we'll have it fixed immediately but we should do
a better job here.

-mike

On Mon, Feb 9, 2009 at 7:19 AM, Adam Hardy <ad...@cyberspaceroad.com>wrote:

> After a frustrating time building a test project to isolate what I thought
> was a new issue, I discovered that there was nothing wrong with my project,
> I had just  forgotten to add one entity class to the PCEnhancer command
> during my build-time enhancement routine.
>
> So the class was unenhanced.
>
> With RuntimeUnenhancedClasses set to unsupported, instead of receiving a
> "cannot run with unenhanced classes" error, OpenJPA threw the exceptions
> below.
>
> I think this definitely qualifies as a bug - OpenJPA is throwing the wrong
> exception. It definitely misled me for a while.
>
> Shall I open a JIRA for it?
>
>
> Regards
> Adam
>
>
> Adam Hardy on 08/02/09 23:46, wrote:
>
>> Following on from my initial response, I copied the superclass into the
>> same project so that the enhancer can process the class file properly.
>>
>> It looks like I'm taking the scenic route around all the OpenJPA issues
>> right now.
>>
>> I hit this problem with enhanced files that doesn't happen with the
>> unenhanced.
>>
>> I carefully set the property openjpa.RuntimeUnenhancedClasses=unsupported
>> so I can be certain I am running with the enhanced classes.
>>
>> So with build-time enhancement, I get stacktraces of exceptions as
>> follows, although it's not clear which is the original cause:
>>
>> Caused by: java.lang.IllegalStateException: No registered metadata for
>> type "class org.permacode.patternrepo.domain.entity.CollatedRun".
>>        at
>> org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
>>
>> NestedThrowables:
>> <openjpa-1.2.0-r422266:683325 fatal user error>
>> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type
>> "org.permacode.patternrepo.domain.entity.TestAnalysis" due to previous
>> errors resolving related type
>> "org.permacode.patternrepo.domain.entity.CollatedRun".
>>        at
>> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731)
>>
>>
>> <openjpa-1.2.0-r422266:683325 fatal user error>
>> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type
>> "org.permacode.patternrepo.domain.entity.Weighting" due to previous errors
>> resolving related type
>> "org.permacode.patternrepo.domain.entity.CollatedRun".
>>        at
>> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731)
>>
>>
>> <openjpa-1.2.0-r422266:683325 fatal user error>
>> org.apache.openjpa.persistence.ArgumentException: Attempt to map
>> "org.permacode.patternrepo.domain.entity.CollatedRun.portfolio" failed: the
>> owning entity is not mapped.
>>        at
>> org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:547)
>>
>> java.lang.IllegalStateException: No registered metadata for type "class
>> org.permacode.patternrepo.domain.entity.CollatedRun".        at
>> org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
>>
>>
>> I figure that the "no registered metadata for type ..." must be the
>> original since it appears first and last. It runs fine unenhanced, so what
>> can it be? Do enhanced entities only work with annotations? These entities
>> are all mapped via xml.
>>
>
>

[Resolved] enhancement roadblock - but with a bug

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
After a frustrating time building a test project to isolate what I thought was a 
new issue, I discovered that there was nothing wrong with my project, I had just 
  forgotten to add one entity class to the PCEnhancer command during my 
build-time enhancement routine.

So the class was unenhanced.

With RuntimeUnenhancedClasses set to unsupported, instead of receiving a "cannot 
run with unenhanced classes" error, OpenJPA threw the exceptions below.

I think this definitely qualifies as a bug - OpenJPA is throwing the wrong 
exception. It definitely misled me for a while.

Shall I open a JIRA for it?


Regards
Adam


Adam Hardy on 08/02/09 23:46, wrote:
> Following on from my initial response, I copied the superclass into the 
> same project so that the enhancer can process the class file properly.
> 
> It looks like I'm taking the scenic route around all the OpenJPA issues 
> right now.
> 
> I hit this problem with enhanced files that doesn't happen with the 
> unenhanced.
> 
> I carefully set the property 
> openjpa.RuntimeUnenhancedClasses=unsupported so I can be certain I am 
> running with the enhanced classes.
> 
> So with build-time enhancement, I get stacktraces of exceptions as 
> follows, although it's not clear which is the original cause:
> 
> Caused by: java.lang.IllegalStateException: No registered metadata for 
> type "class org.permacode.patternrepo.domain.entity.CollatedRun".
>         at 
> org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
> 
> NestedThrowables:
> <openjpa-1.2.0-r422266:683325 fatal user error> 
> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type 
> "org.permacode.patternrepo.domain.entity.TestAnalysis" due to previous 
> errors resolving related type 
> "org.permacode.patternrepo.domain.entity.CollatedRun".
>         at 
> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731) 
> 
> 
> <openjpa-1.2.0-r422266:683325 fatal user error> 
> org.apache.openjpa.persistence.ArgumentException: Unable to resolve type 
> "org.permacode.patternrepo.domain.entity.Weighting" due to previous 
> errors resolving related type 
> "org.permacode.patternrepo.domain.entity.CollatedRun".
>         at 
> org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731) 
> 
> 
> <openjpa-1.2.0-r422266:683325 fatal user error> 
> org.apache.openjpa.persistence.ArgumentException: Attempt to map 
> "org.permacode.patternrepo.domain.entity.CollatedRun.portfolio" failed: 
> the owning entity is not mapped.
>         at 
> org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:547)
> 
> java.lang.IllegalStateException: No registered metadata for type "class 
> org.permacode.patternrepo.domain.entity.CollatedRun".        at 
> org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
> 
> 
> I figure that the "no registered metadata for type ..." must be the 
> original since it appears first and last. It runs fine unenhanced, so 
> what can it be? Do enhanced entities only work with annotations? These 
> entities are all mapped via xml.


Re: enhancement roadblock

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Following on from my initial response, I copied the superclass into the same 
project so that the enhancer can process the class file properly.

It looks like I'm taking the scenic route around all the OpenJPA issues right now.

I hit this problem with enhanced files that doesn't happen with the unenhanced.

I carefully set the property openjpa.RuntimeUnenhancedClasses=unsupported so I 
can be certain I am running with the enhanced classes.

So with build-time enhancement, I get stacktraces of exceptions as follows, 
although it's not clear which is the original cause:

Caused by: java.lang.IllegalStateException: No registered metadata for type 
"class org.permacode.patternrepo.domain.entity.CollatedRun".
         at org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)

NestedThrowables:
<openjpa-1.2.0-r422266:683325 fatal user error> 
org.apache.openjpa.persistence.ArgumentException: Unable to resolve type 
"org.permacode.patternrepo.domain.entity.TestAnalysis" due to previous errors 
resolving related type "org.permacode.patternrepo.domain.entity.CollatedRun".
         at 
org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731)

<openjpa-1.2.0-r422266:683325 fatal user error> 
org.apache.openjpa.persistence.ArgumentException: Unable to resolve type 
"org.permacode.patternrepo.domain.entity.Weighting" due to previous errors 
resolving related type "org.permacode.patternrepo.domain.entity.CollatedRun".
         at 
org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:731)

<openjpa-1.2.0-r422266:683325 fatal user error> 
org.apache.openjpa.persistence.ArgumentException: Attempt to map 
"org.permacode.patternrepo.domain.entity.CollatedRun.portfolio" failed: the 
owning entity is not mapped.
         at 
org.apache.openjpa.jdbc.meta.MappingInfo.assertTable(MappingInfo.java:547)

java.lang.IllegalStateException: No registered metadata for type "class 
org.permacode.patternrepo.domain.entity.CollatedRun".        at 
org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)


I figure that the "no registered metadata for type ..." must be the original 
since it appears first and last. It runs fine unenhanced, so what can it be? Do 
enhanced entities only work with annotations? These entities are all mapped via 
xml.





Kevin Sutter on 06/02/09 18:59, wrote:
> First thing that jumped out at me...  Are you attempting to enhance classes
> that are contained within a jar?  We can't write enhanced classes back out
> to a jar file.  The classes have to be enhanced outside of a jar and then
> re-packaged.  Maybe you already realized this and are working around it, but
> the error message sort of indicated the use of classes within a jar file...
> 
> I've also asked another member of the team to dive into your question.  He's
> developing a lot of experience with the various means of enhancement (maven,
> ant, command line, eclipse, etc).  Unfortunately, I think he is out this
> afternoon...
> 
> Kevin
> 
> On Fri, Feb 6, 2009 at 12:12 PM, Adam Hardy <ad...@cyberspaceroad.com>wrote:
> 
>> I am concentrating now on getting build-time enhancement working.
>>
>> I thought I'd try with the maven-antrun-plugin using the config shown
>> (copied from the list here) but I get this error - the offending class is an
>> entity superclass which is in the jar in the error message. Java knows
>> exactly which jar it is in, yet can't find it so I guess I've missed a
>> simple piece of the config.
>>
>>   [java] Caused by: java.io.FileNotFoundException:
>> file:/home/java/m2-repo/org/permacode/atomic/0.0.1-SNAPSHOT/atomic-0.0.1-SNAPSHOT.jar!/org/permacode/atomic/domain/AtomicEntity.class
>> (No such file or directory)
>>     [java]     at java.io.FileOutputStream.open(Native Method)
>>     [java]     at
>> java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>>     [java]     at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
>>     [java]     at serp.bytecode.BCClass.write(BCClass.java:179)
>>     [java]     at
>> org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:593)
>>
>>
>> This is the PCEnhancer launch config:
>>
>>
>>      <plugin>
>>        <artifactId>maven-antrun-plugin</artifactId>
>>        <executions>
>>          <execution>
>>            <phase>process-classes</phase>
>>            <configuration>
>>              <tasks>
>>                <path id="cp">
>>                  <path refid="maven.test.classpath" />
>>                  <path refid="maven.compile.classpath" />
>>                  <path refid="maven.runtime.classpath" />
>>                  <path refid="maven.dependency.classpath" />
>>                </path>
>>                <fileset id="enhance.path.ref" dir=".">
>>                  <include
>>
>> name="${build.outputDirectory}/org/permacode/patternrepo/domain/entity/*.class"
>> />
>>                  <include
>>
>> name="${build.testOutputDirectory}/org/permacode/patternrepo/domain/entity/*.class"
>> />
>>                </fileset>
>>                <echo message="Enhancing classes...." />
>>                <java classname="org.apache.openjpa.enhance.PCEnhancer"
>>                  classpathref="cp" dir="${build.outputDirectory}"
>>                  fork="true">
>>                  <arg line="-properties
>> META-INF/persistence.xml#OpenJpaJDBC" />
>>                </java>
>>                <echo message="Enhancing classes for OpenJPA done!" />
>>              </tasks>
>>            </configuration>
>>            <goals>
>>              <goal>run</goal>
>>            </goals>
>>          </execution>
>>        </executions>
>>      </plugin>
>>
>> It seems I might need to reference the entity bean in the fileset
>> 'enhance.path.ref' but I'm not sure how to include a jar with a class in
>> there.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Kevin Sutter on 06/02/09 15:45, wrote:
>>
>>> Hi Adam,
>>> You are right in your thinking not to use the "fall back" enhancement
>>> processing for production use.  It was meant as an easy "out of the box"
>>> experience for simple apps.  It was not meant for production use.  All of
>>> this has been documented in our forums and JIRAs (which you have already
>>> found).
>>>
>>> We are doing more investigation into the Java 6 class redefinition
>>> support.
>>> This doesn't seem to be 100% complete either, at least for some scenarios.
>>>
>>> So, the best bet (and most proven) is to stick with standard
>>> PCEnhancement.
>>> This can be done in several ways -- statically during build, or
>>> dynamically
>>> via the -javaagent approach or tied into the classloader of a suitable
>>> EJB3
>>> container.
>>>
>>> In the WebSphere environment, the classloader enhancement process is tied
>>> into both the EJB and Web Containers (same Java EE runtime
>>> implementation).
>>> But, it doesn't sound like this linkage is provided by Tomcat.  I have no
>>> direct experience with Tomcat -- just reading your note below.
>>>
>>> So, it sounds like your best approach is to do the enhancement during the
>>> build process.  If you are experiencing un-enhanced entities at runtime,
>>> then either your build-time enhancement is not working, or your packaged
>>> application isn't picking up the enhanced classes, or you accidentally
>>> have
>>> non-enhanced entities also available via your Tomcat environment.
>>>
>>> Because we don't want our WebSphere customers to accidentally use the
>>> "fall
>>> back" enhancement, we actually turn this off for OpenJPA within WebSphere.
>>> You can do this with this property in your persistence.xml file:
>>>
>>> openjpa.RuntimeUnenhancedClasses = warn
>>>
>>> By default, this is set to "supported".  Another value is "unsupported",
>>> which just detects the problem a little earlier.  By using "warn", you
>>> still
>>> won't fall into the "fall back" enhancement and you will get some more
>>> helpful messages concerning the entities that have not been enhanced.
>>>
>>> I don't have a specific, complete answer to your situation.  But, maybe if
>>> you can experiment a bit with the above information and provide some more
>>> details, we can help get your environment working to your expectations.
>>> Good luck!
>>>
>>> Thanks,
>>> Kevin
>>>
>>> On Fri, Feb 6, 2009 at 9:05 AM, Adam Hardy <adam.sql@cyberspaceroad.com
>>>> wrote:
>>>  I need to enhance the entities in my current project because otherwise
>>>> with
>>>> 'fall-back' enhancement, the core functionality of the application cannot
>>>> be
>>>> run, due to StackOverflowErrors (because of the large number of
>>>> unenhanced
>>>> entities that OpenJPA has to deal with, according to JIRA and the mailing
>>>> list archives).
>>>>
>>>> I'm running Java 1.6.0_12 so I think I'm right in saying that the runtime
>>>> enhancement used by OpenJPA on the unenhanced entities will be Java 6
>>>> class
>>>> retransformation - but it's causing the issue above.
>>>>
>>>> I have tried specifying the javaagent as a JVM option, but I have some
>>>> problems with this in the web server. I'm using tomcat and it looks like
>>>> I
>>>> have to put my complete webapp into tomcat shared directory so that the
>>>> enhancement process has the classes available at boot.
>>>>
>>>> My entity beans have a fair amount of encapsulated business logic so
>>>> there
>>>> are a fair number of external utility classes and jar dependencies.
>>>>
>>>> Is there a way to configure the javaagent on a per-website basis for
>>>> tomcat?
>>>>
>>>> Secondly I have configured the openjpa-maven-plugin so that it launches
>>>> the
>>>> PCEnhancer during my maven build, but the x*?!"@ app doesn't run with the
>>>> build-time enhanced classes.
>>>>
>>>> It just hangs while loading the webapp, when Spring tries to load the
>>>> managers (the transaction-wrapped business tier). That's both during
>>>> integration testing with JUnit and when deployed in tomcat.
>>>>
>>>> I think that sums up my current situation. Can anyone suggest a way
>>>> forward?


Re: enhancement roadblock

Posted by Kevin Sutter <kw...@gmail.com>.
First thing that jumped out at me...  Are you attempting to enhance classes
that are contained within a jar?  We can't write enhanced classes back out
to a jar file.  The classes have to be enhanced outside of a jar and then
re-packaged.  Maybe you already realized this and are working around it, but
the error message sort of indicated the use of classes within a jar file...

I've also asked another member of the team to dive into your question.  He's
developing a lot of experience with the various means of enhancement (maven,
ant, command line, eclipse, etc).  Unfortunately, I think he is out this
afternoon...

Kevin

On Fri, Feb 6, 2009 at 12:12 PM, Adam Hardy <ad...@cyberspaceroad.com>wrote:

> I am concentrating now on getting build-time enhancement working.
>
> I thought I'd try with the maven-antrun-plugin using the config shown
> (copied from the list here) but I get this error - the offending class is an
> entity superclass which is in the jar in the error message. Java knows
> exactly which jar it is in, yet can't find it so I guess I've missed a
> simple piece of the config.
>
>   [java] Caused by: java.io.FileNotFoundException:
> file:/home/java/m2-repo/org/permacode/atomic/0.0.1-SNAPSHOT/atomic-0.0.1-SNAPSHOT.jar!/org/permacode/atomic/domain/AtomicEntity.class
> (No such file or directory)
>     [java]     at java.io.FileOutputStream.open(Native Method)
>     [java]     at
> java.io.FileOutputStream.<init>(FileOutputStream.java:179)
>     [java]     at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
>     [java]     at serp.bytecode.BCClass.write(BCClass.java:179)
>     [java]     at
> org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:593)
>
>
> This is the PCEnhancer launch config:
>
>
>      <plugin>
>        <artifactId>maven-antrun-plugin</artifactId>
>        <executions>
>          <execution>
>            <phase>process-classes</phase>
>            <configuration>
>              <tasks>
>                <path id="cp">
>                  <path refid="maven.test.classpath" />
>                  <path refid="maven.compile.classpath" />
>                  <path refid="maven.runtime.classpath" />
>                  <path refid="maven.dependency.classpath" />
>                </path>
>                <fileset id="enhance.path.ref" dir=".">
>                  <include
>
> name="${build.outputDirectory}/org/permacode/patternrepo/domain/entity/*.class"
> />
>                  <include
>
> name="${build.testOutputDirectory}/org/permacode/patternrepo/domain/entity/*.class"
> />
>                </fileset>
>                <echo message="Enhancing classes...." />
>                <java classname="org.apache.openjpa.enhance.PCEnhancer"
>                  classpathref="cp" dir="${build.outputDirectory}"
>                  fork="true">
>                  <arg line="-properties
> META-INF/persistence.xml#OpenJpaJDBC" />
>                </java>
>                <echo message="Enhancing classes for OpenJPA done!" />
>              </tasks>
>            </configuration>
>            <goals>
>              <goal>run</goal>
>            </goals>
>          </execution>
>        </executions>
>      </plugin>
>
> It seems I might need to reference the entity bean in the fileset
> 'enhance.path.ref' but I'm not sure how to include a jar with a class in
> there.
>
>
>
>
>
>
>
>
>
>
> Kevin Sutter on 06/02/09 15:45, wrote:
>
>> Hi Adam,
>> You are right in your thinking not to use the "fall back" enhancement
>> processing for production use.  It was meant as an easy "out of the box"
>> experience for simple apps.  It was not meant for production use.  All of
>> this has been documented in our forums and JIRAs (which you have already
>> found).
>>
>> We are doing more investigation into the Java 6 class redefinition
>> support.
>> This doesn't seem to be 100% complete either, at least for some scenarios.
>>
>> So, the best bet (and most proven) is to stick with standard
>> PCEnhancement.
>> This can be done in several ways -- statically during build, or
>> dynamically
>> via the -javaagent approach or tied into the classloader of a suitable
>> EJB3
>> container.
>>
>> In the WebSphere environment, the classloader enhancement process is tied
>> into both the EJB and Web Containers (same Java EE runtime
>> implementation).
>> But, it doesn't sound like this linkage is provided by Tomcat.  I have no
>> direct experience with Tomcat -- just reading your note below.
>>
>> So, it sounds like your best approach is to do the enhancement during the
>> build process.  If you are experiencing un-enhanced entities at runtime,
>> then either your build-time enhancement is not working, or your packaged
>> application isn't picking up the enhanced classes, or you accidentally
>> have
>> non-enhanced entities also available via your Tomcat environment.
>>
>> Because we don't want our WebSphere customers to accidentally use the
>> "fall
>> back" enhancement, we actually turn this off for OpenJPA within WebSphere.
>> You can do this with this property in your persistence.xml file:
>>
>> openjpa.RuntimeUnenhancedClasses = warn
>>
>> By default, this is set to "supported".  Another value is "unsupported",
>> which just detects the problem a little earlier.  By using "warn", you
>> still
>> won't fall into the "fall back" enhancement and you will get some more
>> helpful messages concerning the entities that have not been enhanced.
>>
>> I don't have a specific, complete answer to your situation.  But, maybe if
>> you can experiment a bit with the above information and provide some more
>> details, we can help get your environment working to your expectations.
>> Good luck!
>>
>> Thanks,
>> Kevin
>>
>> On Fri, Feb 6, 2009 at 9:05 AM, Adam Hardy <adam.sql@cyberspaceroad.com
>> >wrote:
>>
>>  I need to enhance the entities in my current project because otherwise
>>> with
>>> 'fall-back' enhancement, the core functionality of the application cannot
>>> be
>>> run, due to StackOverflowErrors (because of the large number of
>>> unenhanced
>>> entities that OpenJPA has to deal with, according to JIRA and the mailing
>>> list archives).
>>>
>>> I'm running Java 1.6.0_12 so I think I'm right in saying that the runtime
>>> enhancement used by OpenJPA on the unenhanced entities will be Java 6
>>> class
>>> retransformation - but it's causing the issue above.
>>>
>>> I have tried specifying the javaagent as a JVM option, but I have some
>>> problems with this in the web server. I'm using tomcat and it looks like
>>> I
>>> have to put my complete webapp into tomcat shared directory so that the
>>> enhancement process has the classes available at boot.
>>>
>>> My entity beans have a fair amount of encapsulated business logic so
>>> there
>>> are a fair number of external utility classes and jar dependencies.
>>>
>>> Is there a way to configure the javaagent on a per-website basis for
>>> tomcat?
>>>
>>> Secondly I have configured the openjpa-maven-plugin so that it launches
>>> the
>>> PCEnhancer during my maven build, but the x*?!"@ app doesn't run with the
>>> build-time enhanced classes.
>>>
>>> It just hangs while loading the webapp, when Spring tries to load the
>>> managers (the transaction-wrapped business tier). That's both during
>>> integration testing with JUnit and when deployed in tomcat.
>>>
>>> I think that sums up my current situation. Can anyone suggest a way
>>> forward?
>>>
>>> regards
>>> Adam
>>>
>>>
>>
>

Re: enhancement roadblock

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
I am concentrating now on getting build-time enhancement working.

I thought I'd try with the maven-antrun-plugin using the config shown (copied 
from the list here) but I get this error - the offending class is an entity 
superclass which is in the jar in the error message. Java knows exactly which 
jar it is in, yet can't find it so I guess I've missed a simple piece of the config.

    [java] Caused by: java.io.FileNotFoundException: 
file:/home/java/m2-repo/org/permacode/atomic/0.0.1-SNAPSHOT/atomic-0.0.1-SNAPSHOT.jar!/org/permacode/atomic/domain/AtomicEntity.class 
(No such file or directory)
      [java]     at java.io.FileOutputStream.open(Native Method)
      [java]     at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
      [java]     at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
      [java]     at serp.bytecode.BCClass.write(BCClass.java:179)
      [java]     at 
org.apache.openjpa.enhance.PCEnhancer.record(PCEnhancer.java:593)


This is the PCEnhancer launch config:


       <plugin>
         <artifactId>maven-antrun-plugin</artifactId>
         <executions>
           <execution>
             <phase>process-classes</phase>
             <configuration>
               <tasks>
                 <path id="cp">
                   <path refid="maven.test.classpath" />
                   <path refid="maven.compile.classpath" />
                   <path refid="maven.runtime.classpath" />
                   <path refid="maven.dependency.classpath" />
                 </path>
                 <fileset id="enhance.path.ref" dir=".">
                   <include
 
name="${build.outputDirectory}/org/permacode/patternrepo/domain/entity/*.class" />
                   <include
 
name="${build.testOutputDirectory}/org/permacode/patternrepo/domain/entity/*.class" 
/>
                 </fileset>
                 <echo message="Enhancing classes...." />
                 <java classname="org.apache.openjpa.enhance.PCEnhancer"
                   classpathref="cp" dir="${build.outputDirectory}"
                   fork="true">
                   <arg line="-properties META-INF/persistence.xml#OpenJpaJDBC" />
                 </java>
                 <echo message="Enhancing classes for OpenJPA done!" />
               </tasks>
             </configuration>
             <goals>
               <goal>run</goal>
             </goals>
           </execution>
         </executions>
       </plugin>

It seems I might need to reference the entity bean in the fileset 
'enhance.path.ref' but I'm not sure how to include a jar with a class in there.









Kevin Sutter on 06/02/09 15:45, wrote:
> Hi Adam,
> You are right in your thinking not to use the "fall back" enhancement
> processing for production use.  It was meant as an easy "out of the box"
> experience for simple apps.  It was not meant for production use.  All of
> this has been documented in our forums and JIRAs (which you have already
> found).
> 
> We are doing more investigation into the Java 6 class redefinition support.
> This doesn't seem to be 100% complete either, at least for some scenarios.
> 
> So, the best bet (and most proven) is to stick with standard PCEnhancement.
> This can be done in several ways -- statically during build, or dynamically
> via the -javaagent approach or tied into the classloader of a suitable EJB3
> container.
> 
> In the WebSphere environment, the classloader enhancement process is tied
> into both the EJB and Web Containers (same Java EE runtime implementation).
> But, it doesn't sound like this linkage is provided by Tomcat.  I have no
> direct experience with Tomcat -- just reading your note below.
> 
> So, it sounds like your best approach is to do the enhancement during the
> build process.  If you are experiencing un-enhanced entities at runtime,
> then either your build-time enhancement is not working, or your packaged
> application isn't picking up the enhanced classes, or you accidentally have
> non-enhanced entities also available via your Tomcat environment.
> 
> Because we don't want our WebSphere customers to accidentally use the "fall
> back" enhancement, we actually turn this off for OpenJPA within WebSphere.
> You can do this with this property in your persistence.xml file:
> 
> openjpa.RuntimeUnenhancedClasses = warn
> 
> By default, this is set to "supported".  Another value is "unsupported",
> which just detects the problem a little earlier.  By using "warn", you still
> won't fall into the "fall back" enhancement and you will get some more
> helpful messages concerning the entities that have not been enhanced.
> 
> I don't have a specific, complete answer to your situation.  But, maybe if
> you can experiment a bit with the above information and provide some more
> details, we can help get your environment working to your expectations.
> Good luck!
> 
> Thanks,
> Kevin
> 
> On Fri, Feb 6, 2009 at 9:05 AM, Adam Hardy <ad...@cyberspaceroad.com>wrote:
> 
>> I need to enhance the entities in my current project because otherwise with
>> 'fall-back' enhancement, the core functionality of the application cannot be
>> run, due to StackOverflowErrors (because of the large number of unenhanced
>> entities that OpenJPA has to deal with, according to JIRA and the mailing
>> list archives).
>>
>> I'm running Java 1.6.0_12 so I think I'm right in saying that the runtime
>> enhancement used by OpenJPA on the unenhanced entities will be Java 6 class
>> retransformation - but it's causing the issue above.
>>
>> I have tried specifying the javaagent as a JVM option, but I have some
>> problems with this in the web server. I'm using tomcat and it looks like I
>> have to put my complete webapp into tomcat shared directory so that the
>> enhancement process has the classes available at boot.
>>
>> My entity beans have a fair amount of encapsulated business logic so there
>> are a fair number of external utility classes and jar dependencies.
>>
>> Is there a way to configure the javaagent on a per-website basis for
>> tomcat?
>>
>> Secondly I have configured the openjpa-maven-plugin so that it launches the
>> PCEnhancer during my maven build, but the x*?!"@ app doesn't run with the
>> build-time enhanced classes.
>>
>> It just hangs while loading the webapp, when Spring tries to load the
>> managers (the transaction-wrapped business tier). That's both during
>> integration testing with JUnit and when deployed in tomcat.
>>
>> I think that sums up my current situation. Can anyone suggest a way
>> forward?
>>
>> regards
>> Adam
>>
> 


Re: enhancement roadblock

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Adam,
You are right in your thinking not to use the "fall back" enhancement
processing for production use.  It was meant as an easy "out of the box"
experience for simple apps.  It was not meant for production use.  All of
this has been documented in our forums and JIRAs (which you have already
found).

We are doing more investigation into the Java 6 class redefinition support.
This doesn't seem to be 100% complete either, at least for some scenarios.

So, the best bet (and most proven) is to stick with standard PCEnhancement.
This can be done in several ways -- statically during build, or dynamically
via the -javaagent approach or tied into the classloader of a suitable EJB3
container.

In the WebSphere environment, the classloader enhancement process is tied
into both the EJB and Web Containers (same Java EE runtime implementation).
But, it doesn't sound like this linkage is provided by Tomcat.  I have no
direct experience with Tomcat -- just reading your note below.

So, it sounds like your best approach is to do the enhancement during the
build process.  If you are experiencing un-enhanced entities at runtime,
then either your build-time enhancement is not working, or your packaged
application isn't picking up the enhanced classes, or you accidentally have
non-enhanced entities also available via your Tomcat environment.

Because we don't want our WebSphere customers to accidentally use the "fall
back" enhancement, we actually turn this off for OpenJPA within WebSphere.
You can do this with this property in your persistence.xml file:

openjpa.RuntimeUnenhancedClasses = warn

By default, this is set to "supported".  Another value is "unsupported",
which just detects the problem a little earlier.  By using "warn", you still
won't fall into the "fall back" enhancement and you will get some more
helpful messages concerning the entities that have not been enhanced.

I don't have a specific, complete answer to your situation.  But, maybe if
you can experiment a bit with the above information and provide some more
details, we can help get your environment working to your expectations.
Good luck!

Thanks,
Kevin

On Fri, Feb 6, 2009 at 9:05 AM, Adam Hardy <ad...@cyberspaceroad.com>wrote:

> I need to enhance the entities in my current project because otherwise with
> 'fall-back' enhancement, the core functionality of the application cannot be
> run, due to StackOverflowErrors (because of the large number of unenhanced
> entities that OpenJPA has to deal with, according to JIRA and the mailing
> list archives).
>
> I'm running Java 1.6.0_12 so I think I'm right in saying that the runtime
> enhancement used by OpenJPA on the unenhanced entities will be Java 6 class
> retransformation - but it's causing the issue above.
>
> I have tried specifying the javaagent as a JVM option, but I have some
> problems with this in the web server. I'm using tomcat and it looks like I
> have to put my complete webapp into tomcat shared directory so that the
> enhancement process has the classes available at boot.
>
> My entity beans have a fair amount of encapsulated business logic so there
> are a fair number of external utility classes and jar dependencies.
>
> Is there a way to configure the javaagent on a per-website basis for
> tomcat?
>
> Secondly I have configured the openjpa-maven-plugin so that it launches the
> PCEnhancer during my maven build, but the x*?!"@ app doesn't run with the
> build-time enhanced classes.
>
> It just hangs while loading the webapp, when Spring tries to load the
> managers (the transaction-wrapped business tier). That's both during
> integration testing with JUnit and when deployed in tomcat.
>
> I think that sums up my current situation. Can anyone suggest a way
> forward?
>
> regards
> Adam
>