You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Rolf Schumacher <ma...@august.de> on 2009/03/25 01:34:05 UTC

has not been enhanced

I'm working successfully on my first jpa project,
using netbeans, maven and openjpa.

Now I added another entity class by applying the generator from the pull
down menu of a package "New/Entity Classes from Database ..."

It generated two entity classes because the key has multiple colums:
Entity and EntityPK.

When I built the project again I get the error:

"The type "class EntityPK" has not been enhanced."

And the build stops.

I looked in the documentation for "enhancement" and found it to be an
important subject but was not able to understand why a class shall be
enhanced in order for the project to get built.

Before I added this entity to the other 5 - one with a primary key class
as well - I didn't had this problem and everything worked smooth. Now I
got stuck.

What shall I look into to overcome this problem?

Rolf

p.s. When I ran the maven goal openjpa:enhance an exception occurs while
parsing a non-entity class, telling me that a class can not be found
that I provide at runtime. Honestly, I do not know what I was doing here.


Re: has not been enhanced

Posted by Kevin Sutter <kw...@gmail.com>.
Lots of topics, Rolf.  Not sure where to begin...

First off, I'm glad that you are past your original problems and are now
making progress.  Start with the good news...

I'll try to answer your other questions inline...

On Wed, Mar 25, 2009 at 12:23 PM, Rolf Schumacher <ma...@august.de>wrote:

> Thank you, Kevin
>
> took only a quarter to understand (if I did). I like short explanations.
>
> Let me repeat:
>
> - enhanced classes provide services to openjpa classes at runtime
> - therefore enhancement is needed for an openjpa project to run
>  (it's recommended to avoid "sub-classing" (what's that??))


Sub-classing is another mechanism for hooking the JPA runtime into the
Entity classes.  You can also think of it as proxy classes.  Some type of
wrapper to intercept the calls into the Entities so that the JPA runtime can
provide the necessary functionality.  Some JPA providers only support the
sub-classing approach.  But, most of the JPA providers (like OpenJPA)
require the byte-code enhancement processing for better performance and
control.  Albeit, this introduces another processing step...


>
> - it's recommended to use -javaagent:....PCEnhancerTask
>  (that is executed in the same context and prior to the main class)
>  with the executing jvm, in order to enhance the classes at load-time


Yes, that is correct.  Of course, if you are running within an application
server, the JPA runtime is normally hooked into the Container's classloading
mechanism.  This allows us to get a hold of the Entity classes before they
actually loaded, do the dynamic enhancement, and then hand them back to the
Container for final loading and definition.


>
>
> I experimented a bit with Ricks explanation and found my error. Thank you.
>
> Obviously (I'm far from sure about it) the openjpa maven plugin or the
> openjpa environment takes care about enhancement or sub-classing. My
> error was caused different:
>
> In my data model I have two multi-key tables.
> They need an extra class in order to represent the primary key.
> The openjpa maven plugin or netbeans (I don't know either) automatically
> extends the persistence.xml with the class name, but not with the
> classname of the primary keys.
> I use the details of the key of only one of them.
> Therefore I had to manually extend the persistence.xml by the class name
> of that primary key (TimesheetCommentPK in my case).


Interesting.  So, the tooling that was used to automatically create or
update the persistence.xml file was forgetting about your extra PK classes.
Thus, they were not being enhanced, and you were hitting this problem.  I'm
not a netbeans user, so I will leave that exercise up to you to follow up
on.


>
> I can omit the other primary key class name from persistence.xml as long
> as I do not need details of that multi-field key.
>
> Now my tests are running as expected. Maybe with sub-classing - how to
> check? Or does the maven plug-in take care of enhancements?


I don't believe the maven plugin takes care of the enhancement processing.
Pinaki recently posted about providing an Eclipse plugin that will
automatically do the enhancing.

Bottom line:  Avoid the sub-classing approach.  Eventually, you will hit one
of the real limitations of this approach and you'll be back asking about
enhancement.  Bite the bullet and figure out how to enhance your classes
either at build time or dynamically via the container or javaagent.


>
> ==================
>
> What do you think about this solution to testing with enhancement
> omitting sub-classing?:
>
> Put "new PCEnhancerTask();" as the first statement in setUpClass of
> Junit test?
>
> And for running an application:
>
> Put "new PCEnhancerTask();" as the first statement in main(String[] args)?


Sorry, I do not follow this example.  The PCEnhancerTask is an ant task.
It's meant for usage within an ant script.  Maybe there's a way to get this
to work directly from a JUnit test, but that was not the intended usage.

Kevin


>
> Rolf
>
> Kevin Sutter wrote:
> > Rolf,
> > Your "build" is also executing a main called App, which calls Bill.  So,
> the
> > enhancement processing that is being requested is due to the OpenJPA
> > runtime, not the normal compile, build, and packaging phase.
> >
> > For optimum performance, OpenJPA uses byte-code weaving, or enhancement,
> on
> > the Entity classes.  This process inserts some specific byte-codes into
> the
> > Entity classes which help OpenJPA with processing of the Persistence
> > Contexts and the associated Entities.
> >
> > The first message in your log indicates that you are not performing the
> > enhancement process.  Without this enhancement process, we fall back to
> an
> > Entity sub-classing approach.  Not only does this approach not perform
> very
> > well, there are several known issues with this sub-classing.  The main
> idea
> > of sub-classing was to provide an initial, easy out-of-box experience for
> > OpenJPA users.  Unfortunately, due to some of the limitations of this
> > approach, our users almost immediately hit a roadblock.
> >
> > Rick has provided a good write-up on Enhancement on our Persistence blog:
> >
> http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
> >
> > Hopefully this will give a bit more background.  Take a read through this
> > and then post back when you have more questions.  Thanks for your
> interest
> > in OpenJPA!
> >
> > Kevin
> >
> > On Wed, Mar 25, 2009 at 3:41 AM, Rolf Schumacher <mailinglist@august.de
> >wrote:
> >
> >
> >> thank you for your answer, Rick
> >>
> >> you'll find the persistence.xml here:
> http://apache.pastebin.com/m4a91654f
> >> the highlighted class is that one that netbeans has introduced when it
> >> generated it from the table TIMESHEET_COMMENT in the database eHour.
> >>
> >> you'll find the Java stack dump here:
> http://apache.pastebin.com/m7641c82f
> >> it happens when I try to build the maven project with netbeans build
> >>
> >> you'll find the pom.xml here: http://apache.pastebin.com/m6f437735
> >>
> >> I mentioned running openjpa:enhance
> >> the Java stackdump you can find here:
> http://apache.pastebin.com/m2da3ff7d
> >>
> >>
> >>
> >> Rick Curtis wrote:
> >>
> >>> Can we get some more info? Your persistence.xml file along with the
> >>>
> >> actual error message would be a good start.
> >>
> >>> -Rick
> >>>
> >>>
> >>> I'm working successfully on my first jpa project,
> >>> using netbeans, maven and openjpa.
> >>>
> >>> Now I added another entity class by applying the generator from the
> pull
> >>> down menu of a package "New/Entity Classes from Database ..."
> >>>
> >>> It generated two entity classes because the key has multiple colums:
> >>> Entity and EntityPK.
> >>>
> >>> When I built the project again I get the error:
> >>>
> >>> "The type "class EntityPK" has not been enhanced."
> >>>
> >>> And the build stops.
> >>>
> >>> I looked in the documentation for "enhancement" and found it to be an
> >>> important subject but was not able to understand why a class shall be
> >>> enhanced in order for the project to get built.
> >>>
> >>> Before I added this entity to the other 5 - one with a primary key
> class
> >>> as well - I didn't had this problem and everything worked smooth. Now I
> >>> got stuck.
> >>>
> >>> What shall I look into to overcome this problem?
> >>>
> >>> Rolf
> >>>
> >>> p.s. When I ran the maven goal openjpa:enhance an exception occurs
> while
> >>> parsing a non-entity class, telling me that a class can not be found
> >>> that I provide at runtime. Honestly, I do not know what I was doing
> here.
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> >
>

Re: has not been enhanced

Posted by Rolf Schumacher <ma...@august.de>.
Thank you, Kevin

took only a quarter to understand (if I did). I like short explanations.

Let me repeat:

- enhanced classes provide services to openjpa classes at runtime
- therefore enhancement is needed for an openjpa project to run
  (it's recommended to avoid "sub-classing" (what's that??))
- it's recommended to use -javaagent:....PCEnhancerTask
  (that is executed in the same context and prior to the main class)
  with the executing jvm, in order to enhance the classes at load-time

I experimented a bit with Ricks explanation and found my error. Thank you.

Obviously (I'm far from sure about it) the openjpa maven plugin or the
openjpa environment takes care about enhancement or sub-classing. My
error was caused different:

In my data model I have two multi-key tables.
They need an extra class in order to represent the primary key.
The openjpa maven plugin or netbeans (I don't know either) automatically
extends the persistence.xml with the class name, but not with the
classname of the primary keys.
I use the details of the key of only one of them.
Therefore I had to manually extend the persistence.xml by the class name
of that primary key (TimesheetCommentPK in my case).

I can omit the other primary key class name from persistence.xml as long
as I do not need details of that multi-field key.

Now my tests are running as expected. Maybe with sub-classing - how to
check? Or does the maven plug-in take care of enhancements?

==================

What do you think about this solution to testing with enhancement
omitting sub-classing?:

Put "new PCEnhancerTask();" as the first statement in setUpClass of
Junit test?

And for running an application:

Put "new PCEnhancerTask();" as the first statement in main(String[] args)?

Rolf

Kevin Sutter wrote:
> Rolf,
> Your "build" is also executing a main called App, which calls Bill.  So, the
> enhancement processing that is being requested is due to the OpenJPA
> runtime, not the normal compile, build, and packaging phase.
>
> For optimum performance, OpenJPA uses byte-code weaving, or enhancement, on
> the Entity classes.  This process inserts some specific byte-codes into the
> Entity classes which help OpenJPA with processing of the Persistence
> Contexts and the associated Entities.
>
> The first message in your log indicates that you are not performing the
> enhancement process.  Without this enhancement process, we fall back to an
> Entity sub-classing approach.  Not only does this approach not perform very
> well, there are several known issues with this sub-classing.  The main idea
> of sub-classing was to provide an initial, easy out-of-box experience for
> OpenJPA users.  Unfortunately, due to some of the limitations of this
> approach, our users almost immediately hit a roadblock.
>
> Rick has provided a good write-up on Enhancement on our Persistence blog:
> http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html
>
> Hopefully this will give a bit more background.  Take a read through this
> and then post back when you have more questions.  Thanks for your interest
> in OpenJPA!
>
> Kevin
>
> On Wed, Mar 25, 2009 at 3:41 AM, Rolf Schumacher <ma...@august.de>wrote:
>
>   
>> thank you for your answer, Rick
>>
>> you'll find the persistence.xml here: http://apache.pastebin.com/m4a91654f
>> the highlighted class is that one that netbeans has introduced when it
>> generated it from the table TIMESHEET_COMMENT in the database eHour.
>>
>> you'll find the Java stack dump here: http://apache.pastebin.com/m7641c82f
>> it happens when I try to build the maven project with netbeans build
>>
>> you'll find the pom.xml here: http://apache.pastebin.com/m6f437735
>>
>> I mentioned running openjpa:enhance
>> the Java stackdump you can find here: http://apache.pastebin.com/m2da3ff7d
>>
>>
>>
>> Rick Curtis wrote:
>>     
>>> Can we get some more info? Your persistence.xml file along with the
>>>       
>> actual error message would be a good start.
>>     
>>> -Rick
>>>
>>>
>>> I'm working successfully on my first jpa project,
>>> using netbeans, maven and openjpa.
>>>
>>> Now I added another entity class by applying the generator from the pull
>>> down menu of a package "New/Entity Classes from Database ..."
>>>
>>> It generated two entity classes because the key has multiple colums:
>>> Entity and EntityPK.
>>>
>>> When I built the project again I get the error:
>>>
>>> "The type "class EntityPK" has not been enhanced."
>>>
>>> And the build stops.
>>>
>>> I looked in the documentation for "enhancement" and found it to be an
>>> important subject but was not able to understand why a class shall be
>>> enhanced in order for the project to get built.
>>>
>>> Before I added this entity to the other 5 - one with a primary key class
>>> as well - I didn't had this problem and everything worked smooth. Now I
>>> got stuck.
>>>
>>> What shall I look into to overcome this problem?
>>>
>>> Rolf
>>>
>>> p.s. When I ran the maven goal openjpa:enhance an exception occurs while
>>> parsing a non-entity class, telling me that a class can not be found
>>> that I provide at runtime. Honestly, I do not know what I was doing here.
>>>
>>>
>>>
>>>
>>>
>>>       
>
>   

Re: has not been enhanced

Posted by Kevin Sutter <kw...@gmail.com>.
Rolf,
Your "build" is also executing a main called App, which calls Bill.  So, the
enhancement processing that is being requested is due to the OpenJPA
runtime, not the normal compile, build, and packaging phase.

For optimum performance, OpenJPA uses byte-code weaving, or enhancement, on
the Entity classes.  This process inserts some specific byte-codes into the
Entity classes which help OpenJPA with processing of the Persistence
Contexts and the associated Entities.

The first message in your log indicates that you are not performing the
enhancement process.  Without this enhancement process, we fall back to an
Entity sub-classing approach.  Not only does this approach not perform very
well, there are several known issues with this sub-classing.  The main idea
of sub-classing was to provide an initial, easy out-of-box experience for
OpenJPA users.  Unfortunately, due to some of the limitations of this
approach, our users almost immediately hit a roadblock.

Rick has provided a good write-up on Enhancement on our Persistence blog:
http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html

Hopefully this will give a bit more background.  Take a read through this
and then post back when you have more questions.  Thanks for your interest
in OpenJPA!

Kevin

On Wed, Mar 25, 2009 at 3:41 AM, Rolf Schumacher <ma...@august.de>wrote:

> thank you for your answer, Rick
>
> you'll find the persistence.xml here: http://apache.pastebin.com/m4a91654f
> the highlighted class is that one that netbeans has introduced when it
> generated it from the table TIMESHEET_COMMENT in the database eHour.
>
> you'll find the Java stack dump here: http://apache.pastebin.com/m7641c82f
> it happens when I try to build the maven project with netbeans build
>
> you'll find the pom.xml here: http://apache.pastebin.com/m6f437735
>
> I mentioned running openjpa:enhance
> the Java stackdump you can find here: http://apache.pastebin.com/m2da3ff7d
>
>
>
> Rick Curtis wrote:
> > Can we get some more info? Your persistence.xml file along with the
> actual error message would be a good start.
> >
> > -Rick
> >
> >
> > I'm working successfully on my first jpa project,
> > using netbeans, maven and openjpa.
> >
> > Now I added another entity class by applying the generator from the pull
> > down menu of a package "New/Entity Classes from Database ..."
> >
> > It generated two entity classes because the key has multiple colums:
> > Entity and EntityPK.
> >
> > When I built the project again I get the error:
> >
> > "The type "class EntityPK" has not been enhanced."
> >
> > And the build stops.
> >
> > I looked in the documentation for "enhancement" and found it to be an
> > important subject but was not able to understand why a class shall be
> > enhanced in order for the project to get built.
> >
> > Before I added this entity to the other 5 - one with a primary key class
> > as well - I didn't had this problem and everything worked smooth. Now I
> > got stuck.
> >
> > What shall I look into to overcome this problem?
> >
> > Rolf
> >
> > p.s. When I ran the maven goal openjpa:enhance an exception occurs while
> > parsing a non-entity class, telling me that a class can not be found
> > that I provide at runtime. Honestly, I do not know what I was doing here.
> >
> >
> >
> >
> >
>

Re: has not been enhanced

Posted by Rolf Schumacher <ma...@august.de>.
thank you for your answer, Rick

you'll find the persistence.xml here: http://apache.pastebin.com/m4a91654f
the highlighted class is that one that netbeans has introduced when it
generated it from the table TIMESHEET_COMMENT in the database eHour.

you'll find the Java stack dump here: http://apache.pastebin.com/m7641c82f
it happens when I try to build the maven project with netbeans build

you'll find the pom.xml here: http://apache.pastebin.com/m6f437735

I mentioned running openjpa:enhance
the Java stackdump you can find here: http://apache.pastebin.com/m2da3ff7d



Rick Curtis wrote:
> Can we get some more info? Your persistence.xml file along with the actual error message would be a good start.
>
> -Rick
>
>
> I'm working successfully on my first jpa project,
> using netbeans, maven and openjpa.
>
> Now I added another entity class by applying the generator from the pull
> down menu of a package "New/Entity Classes from Database ..."
>
> It generated two entity classes because the key has multiple colums:
> Entity and EntityPK.
>
> When I built the project again I get the error:
>
> "The type "class EntityPK" has not been enhanced."
>
> And the build stops.
>
> I looked in the documentation for "enhancement" and found it to be an
> important subject but was not able to understand why a class shall be
> enhanced in order for the project to get built.
>
> Before I added this entity to the other 5 - one with a primary key class
> as well - I didn't had this problem and everything worked smooth. Now I
> got stuck.
>
> What shall I look into to overcome this problem?
>
> Rolf
>
> p.s. When I ran the maven goal openjpa:enhance an exception occurs while
> parsing a non-entity class, telling me that a class can not be found
> that I provide at runtime. Honestly, I do not know what I was doing here.
>
>
>
>
>   

Re: has not been enhanced

Posted by Rick Curtis <cu...@gmail.com>.
Can we get some more info? Your persistence.xml file along with the actual error message would be a good start.

-Rick


I'm working successfully on my first jpa project,
using netbeans, maven and openjpa.

Now I added another entity class by applying the generator from the pull
down menu of a package "New/Entity Classes from Database ..."

It generated two entity classes because the key has multiple colums:
Entity and EntityPK.

When I built the project again I get the error:

"The type "class EntityPK" has not been enhanced."

And the build stops.

I looked in the documentation for "enhancement" and found it to be an
important subject but was not able to understand why a class shall be
enhanced in order for the project to get built.

Before I added this entity to the other 5 - one with a primary key class
as well - I didn't had this problem and everything worked smooth. Now I
got stuck.

What shall I look into to overcome this problem?

Rolf

p.s. When I ran the maven goal openjpa:enhance an exception occurs while
parsing a non-entity class, telling me that a class can not be found
that I provide at runtime. Honestly, I do not know what I was doing here.




-- 
View this message in context: http://n2.nabble.com/has-not-been-enhanced-tp2529973p2530260.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.