These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: OSGi packaging for Version 4.2
PostPosted: Sun May 25, 2014 3:07 pm 
Newbie

Joined: Sat Feb 25, 2006 6:46 am
Posts: 9
Hello.

I'm trying to set up a KAR packaging to deploy Hibernate 4.2.11 as a feature to our ServiceMix 4.5.

At this time, we exclude use newer version (4.3.5 for example) of hibernate that come with a JPA 2.1 level while our existing code is not really ready for.

My feature is almost ready, but I have still two problems. A copy of the feature at the end of the message.

The first is about the "hibernate-osgi" bundle that declares the following Import-Package :
Code:
org.osgi.framework;ve rsion="[1.6,2)"
.

This import is obviously not resolved on Karaf.

The second problem is about the aries bundles that some examples of feature include in version 1.0.0, while our ServiceMix only provides a version 0.3.

When our bundle, with the PersistenceContext injection in the blueprint, is deployed, an error is thrown :

Code:
waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=MY-HIBERNATE-TESTS))(objectClass=javax.persistence.EntityManagerFactory))]


Some posts let understand that it may be a problem with old versions of aries JPA container.

I've been trying to add the aries 1.0.0 packages to my features, but they seem to be in conflict with the prepackaged versions of SerrviceMix.

An idea about this issues, or similar experiences ?

Thanks for your help.

Regards.

Code:
      <feature>jpa</feature>
      <feature>jndi</feature>
      <feature>transaction</feature>

      <bundle
         dependency="true"
         start-level="30">mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/1.1</bundle>

      <bundle start-level="30">mvn:org.apache.aries/org.apache.aries.util/1.0.0</bundle>

      <bundle>mvn:org.hibernate/hibernate-core/4.2.12.Final</bundle>
      <bundle>mvn:org.hibernate/hibernate-entitymanager/4.2.12.Final</bundle>
      <bundle>mvn:org.hibernate.common/hibernate-commons-annotations/4.0.2.Final</bundle>
      <bundle>mvn:org.hibernate/hibernate-osgi/4.2.12.Final</bundle>

      <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr/2.7.7_5</bundle>
      <bundle dependency="true">mvn:org.javassist/javassist/3.18.1-GA</bundle>

      <bundle>mvn:com.fasterxml/classmate/0.5.4</bundle>
      <bundle>mvn:org.jboss.logging/jboss-logging/3.1.0.GA</bundle>
      <bundle>wrap:mvn:org.jboss/jandex/1.1.0.Alpha1</bundle>

_________________
Ephemeris Lappis


Top
 Profile  
 
 Post subject: Re: OSGi packaging for Version 4.2
PostPosted: Tue May 27, 2014 10:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
Hello, regarding the org.osgi.framework import, I'm confused when you say that "This import is obviously not resolved on Karaf". Most of our integration testing revolves around Felix, Karaf, and SMX, all of which should provide that package. Are you seeing otherwise? What's the exact error you receive?

Note that the features.xml file in our quickstarts is for reference only -- we definitely do not claim that they'll work in all versions of containers.

If I remember correctly, ServiceMix provides its own version of Aries, so including your own would probably introduce conflicts. It would be really interesting if you could modify, by hand, the Hibernate manifests and see if widening the version ranges would still work. I'm curious to see if the older version of Aries, etc. would still work. If they do, open a JIRA and ping me. I'll modify them to make sure it works.

Thanks!


Top
 Profile  
 
 Post subject: Re: OSGi packaging for Version 4.2
PostPosted: Wed May 28, 2014 3:33 am 
Newbie

Joined: Sat Feb 25, 2006 6:46 am
Posts: 9
Hello.

Sorry if I was not precise enough...

First about the OSGi environment : our ServiceMix in version 4.5.3 and its Karaf 2.2.11 provide an older version of the framework package (1.5.0), while the hibernate-osgi manifest requires :

Code:
org.osgi.framework;version="[1.6,2)",org.osgi.framework.wiring;version="[1.0,2)"


An import for "wiring" is also set, but it seems that this version of Karaf comes with none.

Then, about Aries, as all my attempts to add an alternative packaging of several bundles finally only led to conflicts, I decided to let my tests on this version of ServiceMix for a moment, even if ultimately we'll have to come back latter since our customer's current platform relies on the older version, and evaluate the situation with a newer version (5.0.1), and come back to test the old Karaf only if I manage to execute controled versions of bith Hibernate and my own test bundles.

This late version of ServiceMix comes with several prepackaged Hibernate 3.3.2, 4.2.7 and 4.3.1. This Karaf also provide more recent version of Aries packages, among others, the JPA container comes in version 1.0.0 instead of the 0.3. Before anything, I've tested my bundles with the 4.2.7, as our code targets JPA 2.0 and all my JUnit tests are done with 4.2.12. But the same errors occured when the entity manager factrory is about to be created and injected in my DAO service.

Code:
waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=MY-HIBERNATE-TESTS))(objectClass=javax.persistence.EntityManagerFactory))]


I've found on the Karaf forum a post about same kind of errors, and an explanation about it (http://karaf.922171.n3.nabble.com/JPA-with-Karaf-td4031000.html). The problem seem to be in relation with the lifecycle of the bundles, something between the JPA continer, the Hibernate OSGi module and the DAO bundle itself.

A suggested workaround is to stop the Hibernate OSGi bundle, install our budles and restart Hiberanate's one. Changing the start level of the Hibernate OSGi module to make it start after all others is a possibility, and I've tested it with my own 4.2.12 feature.

This operation seems to work once, but any update of the DAO bundle leads the system to be instable, and a stop/start of the OSGi bundle is not always effective. Generally, rebooting ServiceMix reset the bundle start order and the entity manager after all is injected !

But transactions don't work, and write operations are not commited to the database. My service level bundle declares transactions requirement, but it seems that the entity manager is not actually managed and transactions are not propagated.

Code:
   <bean
      id="my.business"
      class="my.tests.hibernate.business.service.BusinessService">
      <property name="dao">
         <reference interface="my.tests.hibernate.dao.SuperDAO" />
      </property>
      <tx:transaction
         method="*"
         value="Required" />
   </bean>

   <service
      ref="my.business"
      interface="my.tests.hibernate.business.Business" />


The DAO level bundle blueprint that exposes the persistence is the following :

Code:
   <bean
      id="my.dao"
      class="my.tests.hibernate.dao.jpa.JpaSuperDAO">
      <jpa:context
         property="entityManager"
         unitname="MY-HIBERNATE-TESTS">
         <jpa:map>
            <entry
               key="hibernate.dialect"
               value="org.hibernate.dialect.PostgreSQLDialect" />
            <entry
               key="hibernate.show_sql"
               value="true" />
         </jpa:map>
      </jpa:context>
   </bean>

   <service
      ref="my.dao"
      interface="my.tests.hibernate.dao.SuperDAO" />


Though, in my Hibernate feature, I activate the JPA and transaction features.

So, "bit by bit" I'm finally on a more optimistic perspective to find a solution, but it seems that anyway there is always a new concern...

Any idea about the transaction problem ?

Thanks for you help.

Regards.

_________________
Ephemeris Lappis


Top
 Profile  
 
 Post subject: Re: OSGi packaging for Version 4.2
PostPosted: Wed May 28, 2014 5:23 am 
Newbie

Joined: Sat Feb 25, 2006 6:46 am
Posts: 9
Hello again.

I'm going on testing, and I've seen strange messages in the log files :

Code:
10:37:14,319 | INFO  | l Console Thread | context                          | 197 - org.apache.aries.jpa.container.context - 1.0.1 | A TransactionSynchronizationRegistry service is now available in the runtime. Managed persistence contexts will now integrate with JTA transactions using [org.apache.aries.transaction.AriesTransactionManager, javax.transaction.TransactionManager, javax.transaction.TransactionSynchronizationRegistry, javax.transaction.UserTransaction, org.apache.geronimo.transaction.manager.RecoverableTransactionManager, org.springframework.transaction.PlatformTransactionManager].
10:37:14,322 | INFO  | l Console Thread | context                          | 197 - org.apache.aries.jpa.container.context - 1.0.1 | No quiesce support is available, so managed persistence units will not participate in quiesce operations.
10:37:14,331 | INFO  | l Console Thread | container                        | 198 - org.apache.aries.jpa.container - 1.0.0 | The file org.apache.aries.jpa.container.properties was not found in bundle org.apache.aries.jpa.container/1.0.0. The default properties {} will be used.
10:37:14,338 | INFO  | l Console Thread | container                        | 198 - org.apache.aries.jpa.container - 1.0.0 | No quiesce support is available, so managed persistence units will not participate in quiesce operations.


Do you think this may explain my transaction problem ?
What should be the problem ?

FYI, I only use non-JTA transactions, as expected in my persistence.xml :

Code:
<persistence
   version="2.0"
   xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

   <persistence-unit
      name="MY-HIBERNATE-TESTS"
      transaction-type="RESOURCE_LOCAL">

      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/hb-tests)</non-jta-data-source>

      <class>my.tests.hibernate.entities.Person</class>
      <class>my.tests.hibernate.entities.Thing</class>

   </persistence-unit>

</persistence>


Thanks for your help.
Regards.

_________________
Ephemeris Lappis


Top
 Profile  
 
 Post subject: Re: OSGi packaging for Version 4.2
PostPosted: Thu May 29, 2014 12:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 18, 2012 5:03 am
Posts: 36
Location: Fort Wayne, Indiana, USA
Thanks much for all the info! Give me a few days -- we're swamped at the moment. But I'll definitely look into this. I'm sure some of the version ranges are too narrow, etc. -- most of what hibernate-osgi does is pretty basic stuff, so widening the ranges shouldn't be an issue.


Top
 Profile  
 
 Post subject: Re: OSGi packaging for Version 4.2
PostPosted: Mon Jun 09, 2014 4:11 am 
Newbie

Joined: Sat Feb 25, 2006 6:46 am
Posts: 9
Hello again !

I've continued my tests, and I've managed to build a set of bundles that work more or less as expected on our ServiceMix 5.0.1. Good news !

But, among the remaining problems, the most troublesome is the strange lifecycle issues. As described in other posts, After starting JPA and Hibernate features, it's mandatory stop the Hibernate OSGi bundle before deploying ours, and restart it afterward to make it take into account our persistence context.

Then, when we try to deploy new versions of our code, this Hibernate bundle seems to fails sometimes to get the new context.

Likewise, when restarting the server, despite the start levels of the bundles, the same Hibernate OSGi bundle fails three times out of four : it seems that sometimes the datasource that is created using a blueprint and exposed as a service is not fully available, and all the JPA chain is broken...

That offers an optimistic perspective from a developer point of view, but deployment operations and delivery in these conditions are still a true challenge.

Have you any idea to get a better mastering of all that ?

Thanks again.

Best regards.

_________________
Ephemeris Lappis


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.