openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <michael.d.d...@gmail.com>
Subject Re: can I run without enhancements?
Date Tue, 28 Oct 2008 22:20:47 GMT
Hi Angel,

One way to enhance within eclipse is to define your own ant builder
(basically an ant script that runs after the normal eclipse build). The ant
script can use the PCEnhancer ant task to enhance your entities. This
approach is mentioned in a white paper written by our own Kevin Sutter and
Roland Barcia [1]. The article was written with AST but much of it will
apply to normal Eclipse too.

The ant script in the example looks like this :

<project name="enahnceJPA">
<target name="enhance">
  <!-- define the openjpac task; this can be done at the top of the    -->
  <!-- build.xml file, so it will be available for all targets      -->
  <taskdef name="openjpac"
classname="org.apache.openjpa.ant.PCEnhancerTask"/>

  <openjpac>
  	<config propertiesFile="./META-INF/persistence.xml"/>
    <fileset dir=".">
    <include name="**/com/ibm/persistence/ejb3/order/entity/*.java" />
    </fileset>
  </openjpac>
</target>

</project>

Unfortunately it uses relative paths for the location of persistence.xml,
and the root location where the .java files are located, so you'll have to
modify them a bit. There might be build in properties that you can use to
make it a bit more portable.

If you use maven & the maven eclipse plugin you could have maven enhance the
entities for you with Rahul's maven plugin (or via the antrun plugin).

Another approach is to manually run the enhancer after you build in Eclipse,
but before you run Roller. I'm not sure this is an acceptable trade off for
you. It looks like you want enhancement to occur automagically during the
build.

Hope this helps, or at least gets you started.
-mike

[1]
http://www.ibm.com/developerworks/websphere/techjournal/0612_barcia/0612_barcia.html

On Tue, Oct 28, 2008 at 3:14 PM, Angel Vera <gunfus@yahoo.com> wrote:

> Kevin,
>
> I didn't have time to look into this until now, thanks for all the help so
> far. I still have a few more question, hope you don't mind :).
>
> I am running with Tomcat using OpenJPA as a provider, I am not exactly sure
> how it is set in the web project, but I am positive as I have seen the .jar
> in the Web project /lib directory.
>
> I recall having tried the -javaagent from the Launch Configuration vm
> arguments section, but I wasn't able to get it working. I get a
> "Unrecognized option: -javaagent". I haven't had the time to investigate the
> problem from a Eclipse/WTP point of view, maybe this is something that is
> not supported or a simple bug.
>
> Another option that you mentioned for this problem was to run the
> PCEnhancer as part of the build of eclipse, how did you enable this part?
> Can you fill in the details?
>
> > o  Run the PCEnhancer process on your entity classes during your
> > build/packaging step.  Running this within Eclipse is not that difficult
> --
> > I do this quite often.  I just setup a separate Run definition to run the
> > PCEnhancer against the project that contains my entity classes and I pass
> > in
> > the persistence.xml file that defines my persistence unit.  If you don't
> > have a large number of classes to enhance, you could also just pass in
> the
> > names of the entity classes that you want enhanced.
>
>
>
>
> ________________________________
> From: Kevin Sutter <kwsutter@gmail.com>
> To: users@openjpa.apache.org
> Sent: Wednesday, October 1, 2008 9:16:44 AM
> Subject: Re: can I run without enhancements?
>
> The Java EE Container needs to support EJB3.  Tomcat by itself probably
> does
> not support this.  You need something like WebSphere's EJB3 support or
> Geronimo's OpenEJB support to be able to plug the JPA provider into.  Both
> of these options (WebSphere and Geronimo) have OpenJPA as their default JPA
> provider.  But, EJB3 contracts require the ability to plug in alternate
> providers, if desired.
>
> So, from the information you have provided thus far, it doesn't sound like
> your environment would support the JPA provider plugin capability.
>
> As far as passing in the -javaagent parameter, on the Run.. panel, there is
> a tab for specifying program arguments and jvm arguments.  The -javaagent
> parameter would go into the jvm argument section.
>
> Hope this helps.
> Kevin
>
> On Tue, Sep 30, 2008 at 8:04 PM, Angel Vera <gunfus@yahoo.com> wrote:
>
> > HI Kevin,
> >
> > I am running inside of the JEE container, I am running "Roller" (which
> has
> > a a fair amount of JPA objects), but the enhacement is not happening on
> the
> > fly.
> >
> > Perhaps you can fill me in in option 2.
> >
> > I tried to use the -javaagent but I didn't find a way of passing this
> > argument to the JVM that Eclipse/WTP is using to launch tomcat.
> >
> > Here are the first 3 lines of my exception, if that helps:
> >
> >
> >
> >
> >
> > ----- Original Message ----
> > From: Kevin Sutter <kwsutter@gmail.com>
> > To: users@openjpa.apache.org
> > Sent: Tuesday, September 30, 2008 9:12:11 AM
> > Subject: Re: can I run without enhancements?
> >
> > Angel,
> > There is a "fallback enhancement" process that uses sub-classing, but
> > previous appends to the forums indicate that this is not a
> production-ready
> > process.  This is really meant for the simple "out of the box"
> applications
> > for demonstration purposes.  Real applications should use some type of
> byte
> > code enhancement to get the best results.
> >
> > Methods of performing the byte code enhancement:
> >
> > o  If running within a Java EE Container environment, let the OpenJPA
> > provider tie into the container's classloading mechanism and the
> > enhancement
> > will happen on the fly when the entity classes are loaded into memory.
> >
> > o  Run the PCEnhancer process on your entity classes during your
> > build/packaging step.  Running this within Eclipse is not that difficult
> --
> > I do this quite often.  I just setup a separate Run definition to run the
> > PCEnhancer against the project that contains my entity classes and I pass
> > in
> > the persistence.xml file that defines my persistence unit.  If you don't
> > have a large number of classes to enhance, you could also just pass in
> the
> > names of the entity classes that you want enhanced.
> >
> > o  Another alternative is to use the -javaagent option on the JVM
> > invocation
> > and pass in the OpenJPA jar file.  This ties into the JVM's classloading
> > mechanism much like the Java EE Container described above.  When the
> entity
> > classes are loaded into the JVM, they will be enhanced on the fly.  I use
> > this mechanism within Eclipse as well.
> >
> > Hope this helps,
> > Kevin
> >
> > On Mon, Sep 29, 2008 at 8:35 PM, Angel Vera <gunfus@yahoo.com> wrote:
> >
> > > I am trying to debug an roller (a blog application) which I am running
> > > inside of eclipse, but I have no easy way of running the JPAEnhancer.
> > >
> > >
> > >
> > > ----- Original Message ----
> > > From: Andrei Tchijov <andrei@tchijov.com>
> > > To: users@openjpa.apache.org
> > > Sent: Monday, September 29, 2008 8:50:58 PM
> > > Subject: Re: can I run without enhancements?
> > >
> > > Just curious, are you trying to figure out the way to profile JPA
> > > Application?
> > >
> > > I was wondering about the same question when I was trying
> > > (unsuccessfully) to profile my JPA App.
> > >
> > > On Sep 29, 2008, at 20:36 , Angel Vera wrote:
> > >
> > > > Is it possible to run a JPA application wihtout the JPA enhancer and
> > > > wihtout enhancing the classes?
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________________________________________
> > > > Get the name you've always wanted @ymail.com or @rocketmail.com! Go
> > > > to http://ca.promos.yahoo.com/jacko/
> > >
> > >
> > >
> __________________________________________________________________
> > > Looking for the perfect gift? Give the gift of Flickr!
> > >
> > > http://www.flickr.com/gift/
> >
> >
> >
> >       __________________________________________________________________
> > Instant Messaging, free SMS, sharing photos and more... Try the new
> Yahoo!
> > Canada Messenger at http://ca.beta.messenger.yahoo.com/
> >
>
>
>
>      __________________________________________________________________
> Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your
> favourite sites. Download it now at
> http://ca.toolbar.yahoo.com.
>

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