openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: enhancement roadblock
Date Fri, 06 Feb 2009 18:59:19 GMT
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 <adam.sql@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
>>>
>>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message