You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Mohammad Shamsi <m....@gmail.com> on 2015/10/14 12:00:31 UTC
Problem with JPA 2.2.0 in Karaf 4.0.2
Hi All,
I just updated the karaf container from 4.0.1 to 4.0.2 and apparently
EntityManager is not being injected to the DAO classes anymore.
The JPA feature (enterprise repo) has been updated from 2.1.0 to 2.2.0 in
the new karaf release.The feature includes "*aries.jpa.blueprint/2.2.0"*
and, as a workaround, if I downgrade *only this bundle* to the old version
(2.1.0) the problem will be solved.
Should I change anything in my code to make it work with
"aries.jpa.blueprint/2.2.0" or this is a bug?
Regards,
Mohammad Shamsi
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
I don't say it's the same, but it looks like the last changes introduced
some weird behaviors ;)
Regards
JB
On 10/14/2015 12:58 PM, mhshams wrote:
> Hi JB,
>
> I checked the other reported issue, regarding jpa 2.2.0, and I am not quite
> sure if they are related.
>
> In my case, all bundles are being started successfully. There is no error or
> even warning in the logs. Only if you try read or write something from/to
> db, the NPE is thrown from the service (DAO) class, because the entity
> manager is not injected in to it.
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043080.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by mhshams <m....@gmail.com>.
Hi JB,
I checked the other reported issue, regarding jpa 2.2.0, and I am not quite
sure if they are related.
In my case, all bundles are being started successfully. There is no error or
even warning in the logs. Only if you try read or write something from/to
db, the NPE is thrown from the service (DAO) class, because the entity
manager is not injected in to it.
--
View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043080.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Mohammad,
you are the second one to report an issue with Aries JPA 2.2.0.
So, it sounds like a bug (a regression) in some use cases.
We gonna take a look on that and fix for 4.0.3.
Sorry about that.
Regards
JB
On 10/14/2015 12:00 PM, Mohammad Shamsi wrote:
> Hi All,
>
> I just updated the karaf container from 4.0.1 to 4.0.2 and apparently
> EntityManager is not being injected to the DAO classes anymore.
>
> The JPA feature (enterprise repo) has been updated from 2.1.0 to 2.2.0
> in the new karaf release.The feature
> includes "*aries.jpa.blueprint/2.2.0"* and, as a workaround, if I
> downgrade *only this bundle* to the old version (2.1.0) the problem will
> be solved.
>
> Should I change anything in my code to make it work with
> "aries.jpa.blueprint/2.2.0" or this is a bug?
>
>
> Regards,
> Mohammad Shamsi
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Mohammad Shamsi <m....@gmail.com>.
Created the following ticket:
https://issues.apache.org/jira/browse/ARIES-1455
Trying it with annotation approach, I am getting exception during bundle
installation and installation fails.
Cheers,
On Thu, 19 Nov 2015 at 20:33 Christian Schneider <ch...@die-schneider.net>
wrote:
> Sounds like a valid problem. Can you open a jira issue for it?
> Do you also observe this problem when using the new transaction
> blueprint 2.0.0 using annotations?
>
> Christian
>
> Am 19.11.2015 um 16:04 schrieb mhshams:
> > Sorry for the very late reply. I just got some time to debug the code
> and I
> > think I found the issue.
> >
> > The issue is reproducible by nesting the bean definition inside service
> > definition in blueprint xml.
> >
> > <service interface="com.foo.MyDao">
> > <bean class="com.foo.impl.MyDaoImpl">
> > <tx:transaction method="*" value="Required"/>
> > </bean>
> > </service>
> >
> > As a workaround I can change the above definition to following:
> >
> > <bean id="myBean" class="com.foo.impl.MyDaoImpl">
> > <tx:transaction method="*" value="Required"/>
> > </bean>
> > <service interface="com.foo.MyDao">
> > <ref component-id="myBean" />
> > </service>
> >
> > The root cause (probably a bug) is the process method in
> > "JpaComponentProcessor" class in aries jpa blueprint:
> >
> > Set<String> components = new
> > HashSet<String>(cdr.getComponentDefinitionNames());
> > for (String component : components) {
> > ComponentMetadata compDef = cdr.getComponentDefinition(component);
> > if (compDef instanceof MutableBeanMetadata &&
> > !((MutableBeanMetadata)compDef).isProcessor()) {
> > handleComponent((MutableBeanMetadata)compDef, bundle,
> cdr,
> > container);
> > }
> > }
> >
> > Above code is checking if component definition is an instance of
> > "MutableBeanMetadata" which is not the case when the bean definition is
> > nested in service definition. instead it is an instance of
> > "MutableServiceMetadata"
> >
> > Cheers,
> > Mohammad Shamsi
> >
> >
> >
> >
> > --
> > View this message in context:
> http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043623.html
> > Sent from the Karaf - User mailing list archive at Nabble.com.
>
>
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Christian Schneider <ch...@die-schneider.net>.
Sounds like a valid problem. Can you open a jira issue for it?
Do you also observe this problem when using the new transaction
blueprint 2.0.0 using annotations?
Christian
Am 19.11.2015 um 16:04 schrieb mhshams:
> Sorry for the very late reply. I just got some time to debug the code and I
> think I found the issue.
>
> The issue is reproducible by nesting the bean definition inside service
> definition in blueprint xml.
>
> <service interface="com.foo.MyDao">
> <bean class="com.foo.impl.MyDaoImpl">
> <tx:transaction method="*" value="Required"/>
> </bean>
> </service>
>
> As a workaround I can change the above definition to following:
>
> <bean id="myBean" class="com.foo.impl.MyDaoImpl">
> <tx:transaction method="*" value="Required"/>
> </bean>
> <service interface="com.foo.MyDao">
> <ref component-id="myBean" />
> </service>
>
> The root cause (probably a bug) is the process method in
> "JpaComponentProcessor" class in aries jpa blueprint:
>
> Set<String> components = new
> HashSet<String>(cdr.getComponentDefinitionNames());
> for (String component : components) {
> ComponentMetadata compDef = cdr.getComponentDefinition(component);
> if (compDef instanceof MutableBeanMetadata &&
> !((MutableBeanMetadata)compDef).isProcessor()) {
> handleComponent((MutableBeanMetadata)compDef, bundle, cdr,
> container);
> }
> }
>
> Above code is checking if component definition is an instance of
> "MutableBeanMetadata" which is not the case when the bean definition is
> nested in service definition. instead it is an instance of
> "MutableServiceMetadata"
>
> Cheers,
> Mohammad Shamsi
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043623.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by mhshams <m....@gmail.com>.
Sorry for the very late reply. I just got some time to debug the code and I
think I found the issue.
The issue is reproducible by nesting the bean definition inside service
definition in blueprint xml.
<service interface="com.foo.MyDao">
<bean class="com.foo.impl.MyDaoImpl">
<tx:transaction method="*" value="Required"/>
</bean>
</service>
As a workaround I can change the above definition to following:
<bean id="myBean" class="com.foo.impl.MyDaoImpl">
<tx:transaction method="*" value="Required"/>
</bean>
<service interface="com.foo.MyDao">
<ref component-id="myBean" />
</service>
The root cause (probably a bug) is the process method in
"JpaComponentProcessor" class in aries jpa blueprint:
Set<String> components = new
HashSet<String>(cdr.getComponentDefinitionNames());
for (String component : components) {
ComponentMetadata compDef = cdr.getComponentDefinition(component);
if (compDef instanceof MutableBeanMetadata &&
!((MutableBeanMetadata)compDef).isProcessor()) {
handleComponent((MutableBeanMetadata)compDef, bundle, cdr,
container);
}
}
Above code is checking if component definition is an instance of
"MutableBeanMetadata" which is not the case when the bean definition is
nested in service definition. instead it is an instance of
"MutableServiceMetadata"
Cheers,
Mohammad Shamsi
--
View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043623.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Christian Schneider <ch...@die-schneider.net>.
Aries JPA does not do the transaction processing at all.
It is done by aries transaction blueprint. For karaf 4.0.2 we install
version 1.1.1 and version 2.0.0.
The old version supports xml style the new version just @Transactional.
So if you want to use the new code you need to use the new 2.0.0
namespace and the @Transactional annotation.
You can try to adapt this as a first step. If it does not help it would
be great if you can share some code that shows the problem.
Christian
On 14.10.2015 13:52, mhshams wrote:
> Christian,
>
> How about transactions?
> Does the xml style still supported in jpa 2.2.0 or I have to use
> @Transactional annotation?
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043085.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by mhshams <m....@gmail.com>.
Christian,
How about transactions?
Does the xml style still supported in jpa 2.2.0 or I have to use
@Transactional annotation?
--
View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043085.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
can you share your code somehow in order to take a look ?
Thanks,
Regards
JB
On 10/14/2015 01:49 PM, mhshams wrote:
> Christian,
>
> The annotation is there and as i mentioned it is working perfectly in 2.1.0.
> only after upgrading to 2.2.0 i am facing this issue.
>
>
> Cheers,
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043083.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>
--
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by mhshams <m....@gmail.com>.
Christian,
The annotation is there and as i mentioned it is working perfectly in 2.1.0.
only after upgrading to 2.2.0 i am facing this issue.
Cheers,
--
View this message in context: http://karaf.922171.n3.nabble.com/Problem-with-JPA-2-2-0-in-Karaf-4-0-2-tp4043078p4043083.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Re: Problem with JPA 2.2.0 in Karaf 4.0.2
Posted by Christian Schneider <ch...@die-schneider.net>.
You should make sure that your code is annotated with the
@PersistenceContext annotation where you want your EntityManager to be
injected.
The xml elements for EntityManager injection are not supported anymore.
The only reason I can imagine for a NPE in Aries JPA 2.2.0 is that you
do not have the annotation.
Take a look at the examples in aries jpa or at my tutorial
https://github.com/cschneider/Karaf-Tutorial/tree/master/tasklist-blueprint-cdi
.
Christian
On 14.10.2015 12:00, Mohammad Shamsi wrote:
> Hi All,
>
> I just updated the karaf container from 4.0.1 to 4.0.2 and apparently
> EntityManager is not being injected to the DAO classes anymore.
>
> The JPA feature (enterprise repo) has been updated from 2.1.0 to 2.2.0
> in the new karaf release.The feature
> includes "*aries.jpa.blueprint/2.2.0"* and, as a workaround, if I
> downgrade *only this bundle* to the old version (2.1.0) the problem
> will be solved.
>
> Should I change anything in my code to make it work with
> "aries.jpa.blueprint/2.2.0" or this is a bug?
>
>
> Regards,
> Mohammad Shamsi
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
http://www.talend.com