You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by Balázs Zsoldos <ba...@everit.biz> on 2012/05/27 22:04:13 UTC

OpenJPA class enhancing and bundle starting order

Hi,

I checked the OpenJPA-OSGI possibilities and the following question came
into my mind:

- Is it a requirement for OpenJPA that the OpenJPA bundle has to start
before the one that contains Entity classes?

I know in live OSGI containers admins can play with start levels however it
makes life very hard if we have to always think in which order we want to
start our bundles. I did not have these problems with EclipseLink and
Hibernate (I had different ones :)).

Is there any possibility that OpenJPA-OSGI relationship will be enhanced
somewhen in the way that no start ordering will matter and nor OpenJPA
specific compilation neither javaagent usage will be necessary?

Regards,
Balazs Zsoldos
Software Architect
Mobile: +36-70/594-92-34

Everit Kft.
https://www.everit.biz

Re: OpenJPA class enhancing and bundle starting order

Posted by David Jencks <da...@yahoo.com>.
I haven't looked at this particular code in quite a while, but I would expect you'd only get this error if some of your application code managed to load the unenhanced class not through jpa before aries had a chance to install the class weaver.

You are running with an osgi 4.3 framework so runtime weaving works?  And you have all the necessary aries bits for this to work installed (not that I know exactly which ones they are)?

thanks
david jencks

On May 27, 2012, at 2:05 PM, Balázs Zsoldos wrote:

> Hi,
> 
> thanks for the quick response. However I was interested in a slightly different question. I had the following specific exception:
> 
> <openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
> 
> If the Entity bundle is started before the JPA container picks it up OpenJPA will not really work. I found an interesting paragraph in the documentation of Gemini-JPA that is a hack to solve this problem at http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics. It refreshes the entity bundle if it is already resolved when Gemini JPA Container picks it up. Well it sounds a bit sick but at least it may work... Does the aries container do tricks like this?
> 
> This is not that urgent to me as I was on EclipseLink before until I found out that it cannot handle more difficult SQL queries. Hibernate could however it uses solutions (storing the classes in static maps as cache). A couple of days ago someone on this mail list (or the dev one) noted that OpenJPA is more OSGI friendly that is why I thought it would be worthy to have a look on it.
> 
> Regards,
> Balazs Zsoldos
> Software Architect
> Mobile: +36-70/594-92-34
> 
> Everit Kft.
> https://www.everit.biz
> 
> 
> 
> 
> On Sun, May 27, 2012 at 10:30 PM, James Carman <ja...@carmanconsulting.com> wrote:
> If you're using Aries' JPA support, then it won't start up an entity
> manager for your bundle until a JPA provider (like OpenJPA) is
> available for it.
> 
> On Sun, May 27, 2012 at 4:04 PM, Balázs Zsoldos
> <ba...@everit.biz> wrote:
> > Hi,
> >
> > I checked the OpenJPA-OSGI possibilities and the following question came
> > into my mind:
> >
> > - Is it a requirement for OpenJPA that the OpenJPA bundle has to start
> > before the one that contains Entity classes?
> >
> > I know in live OSGI containers admins can play with start levels however it
> > makes life very hard if we have to always think in which order we want to
> > start our bundles. I did not have these problems with EclipseLink and
> > Hibernate (I had different ones :)).
> >
> > Is there any possibility that OpenJPA-OSGI relationship will be enhanced
> > somewhen in the way that no start ordering will matter and nor OpenJPA
> > specific compilation neither javaagent usage will be necessary?
> >
> > Regards,
> > Balazs Zsoldos
> > Software Architect
> > Mobile: +36-70/594-92-34
> >
> > Everit Kft.
> > https://www.everit.biz
> >
> >
> 


Re: OpenJPA class enhancing and bundle starting order

Posted by David Jencks <da...@yahoo.com>.
Hi,

I think that if you have the classes in a bundle different from the bundle containing the persistence.xml runtime enhancement is unlikely to work reliably.  Whether you can get anything else to work is to me an open question.

I'd like to suggest that since the user already has to modify their bundle to list the classes in the persistence.xml it might be simpler all around to just have them pull in the classes too (e.g. using bnd) and not import them from anywhere else.  I think this is likely to work much more reliably than any multi-bundle approach and if you only have a few classes per module it won't make a significant size difference.

thanks
david jencks

On May 28, 2012, at 9:49 PM, Balázs Zsoldos wrote:

> Hi,
> 
> thanks for the tips. My use case is really different from ordinary ones. We develop OSS modules that can be re-used in different projects. A good example is authorization where there are about 3-4 Entity classes only. When someone wants to use the the authorization solution and works with the same technology stack (JPA-OSGI) the only thing that he has to do is take the classes into his/her PU. This means the following in practice:
> 
> We have bundle AUEntity that contains entity classes for the Authorization. We have bundle LOCEntity that contains Entity classes for Localization. If someone has an APP_PU bundle that contains the persistence.xml file all he has to do is to import the packages from the first two Entity bundles and list the classes from them. After that in the application code authorization and localization extensions can be used. A very important feature is that when someone writes a JPA Criteria Query it can be extended with authorization checks by one Util function call.
> 
> There may be multiple applications that use the same Entity bundles for their PU. These applications may use different Persistence Providers. For example if App1 loads the entity jar with Hibernate and App2 uses OpenJPA I will meet the problem that App1 already loaded the classes and OpenJPA cannot enhance them.
> 
> I think I will check the compile time enhancement. The following questions came into my mind:
> Shall import-package used for a bundle that has OpenJPA compile time enhancement?
> If an Entity class is enhanced by OpenJPA, can it be used in multiple Persistence Units?
> A class enhanced by OpenJPA can be used with other technologies like Hibernate?
> An enhanced class needs OpenJPA present in the runtime even if we use it with a different provider like Hibernate or EclipseLink? Practically if import-package is necessary, could it be optional?
> If anybody knows the answer to these questions please let me know! I think I will have to read a bit about the enhancement of OpenJPA what it does exactly and how it does it.
> 
> Thanks and regards,
> Balazs Zsoldos
> 
> 
> 
> On Mon, May 28, 2012 at 2:47 AM, James Carman <jc...@carmanconsulting.com> wrote:
> Is compile-time enhancement not an option?
> 
> Sent from tablet device.  Please excuse typos and brevity.
> 
> On May 27, 2012 5:06 PM, "Balázs Zsoldos" <ba...@everit.biz> wrote:
> Hi,
> 
> thanks for the quick response. However I was interested in a slightly different question. I had the following specific exception:
> 
> <openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
> 
> If the Entity bundle is started before the JPA container picks it up OpenJPA will not really work. I found an interesting paragraph in the documentation of Gemini-JPA that is a hack to solve this problem at http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics. It refreshes the entity bundle if it is already resolved when Gemini JPA Container picks it up. Well it sounds a bit sick but at least it may work... Does the aries container do tricks like this?
> 
> This is not that urgent to me as I was on EclipseLink before until I found out that it cannot handle more difficult SQL queries. Hibernate could however it uses solutions (storing the classes in static maps as cache). A couple of days ago someone on this mail list (or the dev one) noted that OpenJPA is more OSGI friendly that is why I thought it would be worthy to have a look on it.
> 
> Regards,
> Balazs Zsoldos
> Software Architect
> Mobile: +36-70/594-92-34
> 
> Everit Kft.
> https://www.everit.biz
> 
> 
> 
> 
> On Sun, May 27, 2012 at 10:30 PM, James Carman <ja...@carmanconsulting.com> wrote:
> If you're using Aries' JPA support, then it won't start up an entity
> manager for your bundle until a JPA provider (like OpenJPA) is
> available for it.
> 
> On Sun, May 27, 2012 at 4:04 PM, Balázs Zsoldos
> <ba...@everit.biz> wrote:
> > Hi,
> >
> > I checked the OpenJPA-OSGI possibilities and the following question came
> > into my mind:
> >
> > - Is it a requirement for OpenJPA that the OpenJPA bundle has to start
> > before the one that contains Entity classes?
> >
> > I know in live OSGI containers admins can play with start levels however it
> > makes life very hard if we have to always think in which order we want to
> > start our bundles. I did not have these problems with EclipseLink and
> > Hibernate (I had different ones :)).
> >
> > Is there any possibility that OpenJPA-OSGI relationship will be enhanced
> > somewhen in the way that no start ordering will matter and nor OpenJPA
> > specific compilation neither javaagent usage will be necessary?
> >
> > Regards,
> > Balazs Zsoldos
> > Software Architect
> > Mobile: +36-70/594-92-34
> >
> > Everit Kft.
> > https://www.everit.biz
> >
> >
> 
> 


Re: OpenJPA class enhancing and bundle starting order

Posted by Balázs Zsoldos <ba...@everit.biz>.
Hi,

I would like to thank for David and for the answer. My questions may seem
to be a bit silly however I have a strong reason why I ask them. I develop
several re-usable bundles where multiple applications may use the same util
classes and the same entity classes.

An example:

Authorization takes place in only three tables: Resource, Permission and
PermissionInheritance. Permission may be defined between two resources and
a resource that inherits from another resource will get the parent's
permissions. Anything can be a resource. A user, a car, any item in an
application. Why is this good? It is good because queries created with JPA
Criteria API can be enhanced with util functions to contain permission
checks. Any FROM or JOIN part of the query can be automatically extended by
taking the same query snippet to the WHERE part and the difficulties of
query enhancement is hidden from developers. There are other use cases like
this (e.g. localization).

What happens here?

I have application A and application B. Both of them use the Entity classes
from PermissionManagement and both of them use the Permission-core bundle
to have the query enhancement as well. If I copy the classes from
PermissionEntity to AEntity and BEntity bundle as well I will not be able
to use the Util functions from permission-core as it will not know the
entity classes and more importantly the static metamodels. Therefore we
have several Entity bundles that contain reusable Entity classes and one
PersistenceUnit bundle for each application. Normally the PersistenceUnit
bundle contains only a persistence.xml, some application related Entity
classes and some import-package wiring to the re-usable entity bundles.

We worked first with EclipseLink under Glassfish (it was already there so
we used it) with Aries JPA Container and it worked. However EclipseLink
fails on more complex Criteria Queries as it generates wrong native SQL.
Therefore we moved to Hibernate with Aries JPA Container and I created our
own Hibernate bundle and adapter (like Eclipselink adapter in aries-jpa
project). It seems to work and it can handle more complex queries as well.

A couple of day ago here someone said that OpenJPA fits much more to the
OSGI word so I tried to use it. However it seemed to me that I will meet
some problems because of this weaving stuff and that is why I am not sure
that I can use it with our use-cases.

My problem with weaving is that I do not thing it is OSGI friendly at all.
Somewhere I read that a bundle is not well written if the start order of
the bundles matter. When weaving is used it means that it has to be a java
agent or the bundle that does the weaving has to start first for sure. I
think agent stuff should be used only for generating coverage reports or
attaching a profiler but not for technologies that run inside an
application. Compile time enhancement may be better a bit but that raised
my questions: Can I use an enhanced class with other PersistenceProviders?
OpenJPA has to be in the OSGI container if the classes are enhanced at
compile time but other Persistence Provider is used by the application?...

I saw that a draft came out about OSGI-Subsystems but the draft spec was
not really clear to me at some parts. I see that Aries developers take a
lot of energy of implementing it. I have the feeling that subsystems is
something like going back to WAR and EAR file development (long deploy
time, robust applications) but within an OSGI container. I am not sure if
two application needs the same Entity logic they should both deploy it
under their subsystems but they should reuse the same entity bundle in
their persistence units.

Well the last two chapters is only my opinion and I am not even sure I am
not wrong :). I would be very happy if someone convinced me about the
opposite.

Balazs Zsoldos


On Wed, May 30, 2012 at 7:26 PM, Harald Wellmann <ha...@gmx.de>wrote:

> Am 29.05.2012 06:49, schrieb Balázs Zsoldos:
>
>>
>>  * Shall import-package used for a bundle that has OpenJPA compile time
>>    enhancement?
>>
>
> For the model classes, or for the additional package dependencies added by
> the enhancer? If the framework supports weaving hooks, the additional
> dependencies should be added automagically.
>
>   * If an Entity class is enhanced by OpenJPA, can it be used in
>>    multiple Persistence Units?
>>
>
> Are you trying to follow the OSGi Enterprise JPA spec, or just rolling
> your own OSGi + JPA environment? The spec requires all model classes of a
> persistence unit to be in the same persistence bundle.
>
> I tried using entity classes from multiple bundles with OpenJPA, which may
> or may not work, depending on the context. For some join queries containing
> more than one class name, I sometimes had classloader errors.
>
>   * A class enhanced by OpenJPA can be used with other technologies like
>>    Hibernate?
>>
>
> OpenJPA bytecode enhancement creates a compile-time and run-time
> dependency of the enhanced bytecode on OpenJPA. I.e. you cannot compile
> MyDAO.java on top of mymodel.jar containing your enhanced entity model
> without OpenJPA on the classpath.
>
>
>   * An enhanced class needs OpenJPA present in the runtime even if we
>>
>>    use it with a different provider like Hibernate or EclipseLink?
>>    Practically if import-package is necessary, could it be optional?
>>
>
> Hmm, never tried that. But even if Hibernate or Eclipselink could deal
> with or ignore the enhanced bytecode, I suspect some other services might
> get confused by two persistence providers in the system.
>
>
>
>> If anybody knows the answer to these questions please let me know! I
>> think I will have to read a bit about the enhancement of OpenJPA what it
>> does exactly and how it does it.
>>
>>
> OSGi + JPA can be rather frustrating because whichever way you turn, some
> bits and pieces are missing:
>
> - Hibernate has no OSGi support at all.
>
> - Both Hibernate and Eclipselink have too many serious bugs in core JPA
> functions, which is why I favour OpenJPA, in spite of other peculiarities.
>
> - OpenJPA compile-time enhancement is a major nuisance and breaks
> compatibility with other persistence providers (my ceterum censeo with
> OpenJPA...)
>
> - Load-time weaving is great, OpenJPA supports it, but not all containers
> do. It works fine with GlassFish 3.1 (with plain old WARs, but probably not
> in OSGI mode, never tried.)
>
> - About a year ago, I had a working demo with Equinox 3.7-SNAPSHOT +
> OpenJPA 2.1 + Aries 0.4-SNAPSHOT using load-time weaving. The problem with
> Aries is they seem to be too busy coding to release anything.
>
> The latest Aries JPA release 0.3 of Jan 2011(!) does not support load time
> weaving. Last time I tried, the trunk didn't even build, and the new
> version-per-module approach adds to the confusion.
>
> - I also tried Eclipse Gemini at about the same time and dismissed it
> because it forces explicit Spring package dependencies on your application
> bundles, which really should be an implementation detail of the container.
>
> You can find some sample code, both with Aries and Gemini, here:
> http://code.google.com/p/osgi-**enterprise/<http://code.google.com/p/osgi-enterprise/>
>
> Some background on Aries + OpenJPA setup is in this blog:
> http://hwellmann.blogspot.de/**2010/09/openjpa-and-osgi.html<http://hwellmann.blogspot.de/2010/09/openjpa-and-osgi.html>
>
> Regards,
> Harald
>

Re: OpenJPA class enhancing and bundle starting order

Posted by Harald Wellmann <ha...@gmx.de>.
Am 29.05.2012 06:49, schrieb Balázs Zsoldos:
>
>   * Shall import-package used for a bundle that has OpenJPA compile time
>     enhancement?

For the model classes, or for the additional package dependencies added 
by the enhancer? If the framework supports weaving hooks, the additional 
dependencies should be added automagically.

>   * If an Entity class is enhanced by OpenJPA, can it be used in
>     multiple Persistence Units?

Are you trying to follow the OSGi Enterprise JPA spec, or just rolling 
your own OSGi + JPA environment? The spec requires all model classes of 
a persistence unit to be in the same persistence bundle.

I tried using entity classes from multiple bundles with OpenJPA, which 
may or may not work, depending on the context. For some join queries 
containing more than one class name, I sometimes had classloader errors.

>   * A class enhanced by OpenJPA can be used with other technologies like
>     Hibernate?

OpenJPA bytecode enhancement creates a compile-time and run-time 
dependency of the enhanced bytecode on OpenJPA. I.e. you cannot compile 
MyDAO.java on top of mymodel.jar containing your enhanced entity model 
without OpenJPA on the classpath.


>   * An enhanced class needs OpenJPA present in the runtime even if we
>     use it with a different provider like Hibernate or EclipseLink?
>     Practically if import-package is necessary, could it be optional?

Hmm, never tried that. But even if Hibernate or Eclipselink could deal 
with or ignore the enhanced bytecode, I suspect some other services 
might get confused by two persistence providers in the system.

>
> If anybody knows the answer to these questions please let me know! I
> think I will have to read a bit about the enhancement of OpenJPA what it
> does exactly and how it does it.
>

OSGi + JPA can be rather frustrating because whichever way you turn, 
some bits and pieces are missing:

- Hibernate has no OSGi support at all.

- Both Hibernate and Eclipselink have too many serious bugs in core JPA 
functions, which is why I favour OpenJPA, in spite of other peculiarities.

- OpenJPA compile-time enhancement is a major nuisance and breaks 
compatibility with other persistence providers (my ceterum censeo with 
OpenJPA...)

- Load-time weaving is great, OpenJPA supports it, but not all 
containers do. It works fine with GlassFish 3.1 (with plain old WARs, 
but probably not in OSGI mode, never tried.)

- About a year ago, I had a working demo with Equinox 3.7-SNAPSHOT + 
OpenJPA 2.1 + Aries 0.4-SNAPSHOT using load-time weaving. The problem 
with Aries is they seem to be too busy coding to release anything.

The latest Aries JPA release 0.3 of Jan 2011(!) does not support load 
time weaving. Last time I tried, the trunk didn't even build, and the 
new version-per-module approach adds to the confusion.

- I also tried Eclipse Gemini at about the same time and dismissed it 
because it forces explicit Spring package dependencies on your 
application bundles, which really should be an implementation detail of 
the container.

You can find some sample code, both with Aries and Gemini, here:
http://code.google.com/p/osgi-enterprise/

Some background on Aries + OpenJPA setup is in this blog:
http://hwellmann.blogspot.de/2010/09/openjpa-and-osgi.html

Regards,
Harald

Re: OpenJPA class enhancing and bundle starting order

Posted by Balázs Zsoldos <ba...@everit.biz>.
Hi,

thanks for the tips. My use case is really different from ordinary ones. We
develop OSS modules that can be re-used in different projects. A good
example is authorization where there are about 3-4 Entity classes only.
When someone wants to use the the authorization solution and works with the
same technology stack (JPA-OSGI) the only thing that he has to do is take
the classes into his/her PU. This means the following in practice:

We have bundle AUEntity that contains entity classes for the Authorization.
We have bundle LOCEntity that contains Entity classes for Localization. If
someone has an APP_PU bundle that contains the persistence.xml file all he
has to do is to import the packages from the first two Entity bundles and
list the classes from them. After that in the application code
authorization and localization extensions can be used. A very important
feature is that when someone writes a JPA Criteria Query it can be extended
with authorization checks by one Util function call.

There may be multiple applications that use the same Entity bundles for
their PU. These applications may use different Persistence Providers. For
example if App1 loads the entity jar with Hibernate and App2 uses OpenJPA I
will meet the problem that App1 already loaded the classes and OpenJPA
cannot enhance them.

I think I will check the compile time enhancement. The following questions
came into my mind:

   - Shall import-package used for a bundle that has OpenJPA compile time
   enhancement?
   - If an Entity class is enhanced by OpenJPA, can it be used in multiple
   Persistence Units?
   - A class enhanced by OpenJPA can be used with other technologies like
   Hibernate?
   - An enhanced class needs OpenJPA present in the runtime even if we use
   it with a different provider like Hibernate or EclipseLink? Practically if
   import-package is necessary, could it be optional?

If anybody knows the answer to these questions please let me know! I think
I will have to read a bit about the enhancement of OpenJPA what it does
exactly and how it does it.

Thanks and regards,
Balazs Zsoldos



On Mon, May 28, 2012 at 2:47 AM, James Carman
<jc...@carmanconsulting.com>wrote:

> Is compile-time enhancement not an option?
>
> Sent from tablet device.  Please excuse typos and brevity.
> On May 27, 2012 5:06 PM, "Balázs Zsoldos" <ba...@everit.biz>
> wrote:
>
>> Hi,
>>
>> thanks for the quick response. However I was interested in a slightly
>> different question. I had the following specific exception:
>>
>> <openjpa-2.2.0-r422266:1244990 nonfatal user error>
>> org.apache.openjpa.persistence.ArgumentException: This configuration
>> disallows runtime optimization, but the following listed types were not
>> enhanced at build time or at class load time with a javaagent: "
>>
>> If the Entity bundle is started before the JPA container picks it up
>> OpenJPA will not really work. I found an interesting paragraph in the
>> documentation of Gemini-JPA that is a hack to solve this problem at
>> http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics. It
>> refreshes the entity bundle if it is already resolved when Gemini JPA
>> Container picks it up. Well it sounds a bit sick but at least it may
>> work... Does the aries container do tricks like this?
>>
>> This is not that urgent to me as I was on EclipseLink before until I
>> found out that it cannot handle more difficult SQL queries. Hibernate could
>> however it uses solutions (storing the classes in static maps as cache). A
>> couple of days ago someone on this mail list (or the dev one) noted that
>> OpenJPA is more OSGI friendly that is why I thought it would be worthy to
>> have a look on it.
>>
>> Regards,
>> Balazs Zsoldos
>> Software Architect
>> Mobile: +36-70/594-92-34
>>
>> Everit Kft.
>> https://www.everit.biz
>>
>>
>>
>>
>> On Sun, May 27, 2012 at 10:30 PM, James Carman <
>> james@carmanconsulting.com> wrote:
>>
>>> If you're using Aries' JPA support, then it won't start up an entity
>>> manager for your bundle until a JPA provider (like OpenJPA) is
>>> available for it.
>>>
>>> On Sun, May 27, 2012 at 4:04 PM, Balázs Zsoldos
>>> <ba...@everit.biz> wrote:
>>> > Hi,
>>> >
>>> > I checked the OpenJPA-OSGI possibilities and the following question
>>> came
>>> > into my mind:
>>> >
>>> > - Is it a requirement for OpenJPA that the OpenJPA bundle has to start
>>> > before the one that contains Entity classes?
>>> >
>>> > I know in live OSGI containers admins can play with start levels
>>> however it
>>> > makes life very hard if we have to always think in which order we want
>>> to
>>> > start our bundles. I did not have these problems with EclipseLink and
>>> > Hibernate (I had different ones :)).
>>> >
>>> > Is there any possibility that OpenJPA-OSGI relationship will be
>>> enhanced
>>> > somewhen in the way that no start ordering will matter and nor OpenJPA
>>> > specific compilation neither javaagent usage will be necessary?
>>> >
>>> > Regards,
>>> > Balazs Zsoldos
>>> > Software Architect
>>> > Mobile: +36-70/594-92-34
>>> >
>>> > Everit Kft.
>>> > https://www.everit.biz
>>> >
>>> >
>>>
>>
>>

Re: OpenJPA class enhancing and bundle starting order

Posted by James Carman <jc...@carmanconsulting.com>.
Is compile-time enhancement not an option?

Sent from tablet device.  Please excuse typos and brevity.
On May 27, 2012 5:06 PM, "Balázs Zsoldos" <ba...@everit.biz> wrote:

> Hi,
>
> thanks for the quick response. However I was interested in a slightly
> different question. I had the following specific exception:
>
> <openjpa-2.2.0-r422266:1244990 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: This configuration
> disallows runtime optimization, but the following listed types were not
> enhanced at build time or at class load time with a javaagent: "
>
> If the Entity bundle is started before the JPA container picks it up
> OpenJPA will not really work. I found an interesting paragraph in the
> documentation of Gemini-JPA that is a hack to solve this problem at
> http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics. It
> refreshes the entity bundle if it is already resolved when Gemini JPA
> Container picks it up. Well it sounds a bit sick but at least it may
> work... Does the aries container do tricks like this?
>
> This is not that urgent to me as I was on EclipseLink before until I found
> out that it cannot handle more difficult SQL queries. Hibernate could
> however it uses solutions (storing the classes in static maps as cache). A
> couple of days ago someone on this mail list (or the dev one) noted that
> OpenJPA is more OSGI friendly that is why I thought it would be worthy to
> have a look on it.
>
> Regards,
> Balazs Zsoldos
> Software Architect
> Mobile: +36-70/594-92-34
>
> Everit Kft.
> https://www.everit.biz
>
>
>
>
> On Sun, May 27, 2012 at 10:30 PM, James Carman <james@carmanconsulting.com
> > wrote:
>
>> If you're using Aries' JPA support, then it won't start up an entity
>> manager for your bundle until a JPA provider (like OpenJPA) is
>> available for it.
>>
>> On Sun, May 27, 2012 at 4:04 PM, Balázs Zsoldos
>> <ba...@everit.biz> wrote:
>> > Hi,
>> >
>> > I checked the OpenJPA-OSGI possibilities and the following question came
>> > into my mind:
>> >
>> > - Is it a requirement for OpenJPA that the OpenJPA bundle has to start
>> > before the one that contains Entity classes?
>> >
>> > I know in live OSGI containers admins can play with start levels
>> however it
>> > makes life very hard if we have to always think in which order we want
>> to
>> > start our bundles. I did not have these problems with EclipseLink and
>> > Hibernate (I had different ones :)).
>> >
>> > Is there any possibility that OpenJPA-OSGI relationship will be enhanced
>> > somewhen in the way that no start ordering will matter and nor OpenJPA
>> > specific compilation neither javaagent usage will be necessary?
>> >
>> > Regards,
>> > Balazs Zsoldos
>> > Software Architect
>> > Mobile: +36-70/594-92-34
>> >
>> > Everit Kft.
>> > https://www.everit.biz
>> >
>> >
>>
>
>

Re: OpenJPA class enhancing and bundle starting order

Posted by Balázs Zsoldos <ba...@everit.biz>.
Hi,

thanks for the quick response. However I was interested in a slightly
different question. I had the following specific exception:

<openjpa-2.2.0-r422266:1244990 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: This configuration
disallows runtime optimization, but the following listed types were not
enhanced at build time or at class load time with a javaagent: "

If the Entity bundle is started before the JPA container picks it up
OpenJPA will not really work. I found an interesting paragraph in the
documentation of Gemini-JPA that is a hack to solve this problem at
http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics. It refreshes
the entity bundle if it is already resolved when Gemini JPA Container picks
it up. Well it sounds a bit sick but at least it may work... Does the aries
container do tricks like this?

This is not that urgent to me as I was on EclipseLink before until I found
out that it cannot handle more difficult SQL queries. Hibernate could
however it uses solutions (storing the classes in static maps as cache). A
couple of days ago someone on this mail list (or the dev one) noted that
OpenJPA is more OSGI friendly that is why I thought it would be worthy to
have a look on it.

Regards,
Balazs Zsoldos
Software Architect
Mobile: +36-70/594-92-34

Everit Kft.
https://www.everit.biz




On Sun, May 27, 2012 at 10:30 PM, James Carman
<ja...@carmanconsulting.com>wrote:

> If you're using Aries' JPA support, then it won't start up an entity
> manager for your bundle until a JPA provider (like OpenJPA) is
> available for it.
>
> On Sun, May 27, 2012 at 4:04 PM, Balázs Zsoldos
> <ba...@everit.biz> wrote:
> > Hi,
> >
> > I checked the OpenJPA-OSGI possibilities and the following question came
> > into my mind:
> >
> > - Is it a requirement for OpenJPA that the OpenJPA bundle has to start
> > before the one that contains Entity classes?
> >
> > I know in live OSGI containers admins can play with start levels however
> it
> > makes life very hard if we have to always think in which order we want to
> > start our bundles. I did not have these problems with EclipseLink and
> > Hibernate (I had different ones :)).
> >
> > Is there any possibility that OpenJPA-OSGI relationship will be enhanced
> > somewhen in the way that no start ordering will matter and nor OpenJPA
> > specific compilation neither javaagent usage will be necessary?
> >
> > Regards,
> > Balazs Zsoldos
> > Software Architect
> > Mobile: +36-70/594-92-34
> >
> > Everit Kft.
> > https://www.everit.biz
> >
> >
>

Re: OpenJPA class enhancing and bundle starting order

Posted by James Carman <ja...@carmanconsulting.com>.
If you're using Aries' JPA support, then it won't start up an entity
manager for your bundle until a JPA provider (like OpenJPA) is
available for it.

On Sun, May 27, 2012 at 4:04 PM, Balázs Zsoldos
<ba...@everit.biz> wrote:
> Hi,
>
> I checked the OpenJPA-OSGI possibilities and the following question came
> into my mind:
>
> - Is it a requirement for OpenJPA that the OpenJPA bundle has to start
> before the one that contains Entity classes?
>
> I know in live OSGI containers admins can play with start levels however it
> makes life very hard if we have to always think in which order we want to
> start our bundles. I did not have these problems with EclipseLink and
> Hibernate (I had different ones :)).
>
> Is there any possibility that OpenJPA-OSGI relationship will be enhanced
> somewhen in the way that no start ordering will matter and nor OpenJPA
> specific compilation neither javaagent usage will be necessary?
>
> Regards,
> Balazs Zsoldos
> Software Architect
> Mobile: +36-70/594-92-34
>
> Everit Kft.
> https://www.everit.biz
>
>