简体   繁体   中英

How to install Hibernate 5 into Apache Karaf v4

I've installed Apache Karaf v4.03 and queried the list of available features for Hibernate, as listed below. Unfortunately, I am using Hibernate v5.

hibernate                     | 3.3.2.GA         |          | Uninstalled | enterprise-4.0.3         | Hibernate 3.x JPA persistence engine support
hibernate                     | 4.2.15.Final     |          | Uninstalled | enterprise-4.0.3         | Hibernate 4.2.x JPA persistence engine support
hibernate-envers              | 4.2.15.Final     |          | Uninstalled | enterprise-4.0.3         | Hibernate Envers 4.2.x
hibernate                     | 4.3.6.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate 4.3.x JPA persistence engine support
hibernate-envers              | 4.3.6.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate Envers 4.3.x
hibernate-validator           | 5.0.3.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate Validator support

I am unable to find instructions for installing Hibernate v5 into Karaf v4. Are there published instructions for performing this task, and perhaps a downloadable features file?

Latest hibernate-release comes Karaf ready already:

If you download the hibernate-release-5.0.5.Final.zip from hibernate's page ( http://sourceforge.net/projects/hibernate/files/hibernate-orm/5.0.5.Final/hibernate-release-5.0.5.Final.zip/download ) and decompress the file, you will see an osgi folder. There you can find an already prepared feauture: hibernate-osgi-5.0.5.Final-karaf.xml. You can just copy it to Karaf's deploy folder and then execute:

feature:install hibernate-orm

It should be installed without any problem.

Another way to install hibernate 5.0.5 feature is to add a repo to features with the command:

feature:repo-add command.

Here you can see the list of hibernate's features and the one I have installed:

karaf@root()> feature:list | grep hibernate
hibernate                     | 3.3.2.GA         |          | Uninstalled | enterprise-4.0.3         | Hibernate 3.x JPA persistence engine support
hibernate                     | 4.2.15.Final     |          | Uninstalled | enterprise-4.0.3         | Hibernate 4.2.x JPA persistence engine support
hibernate-envers              | 4.2.15.Final     |          | Uninstalled | enterprise-4.0.3         | Hibernate Envers 4.2.x
hibernate                     | 4.3.6.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate 4.3.x JPA persistence engine support
hibernate-envers              | 4.3.6.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate Envers 4.3.x
hibernate-validator           | 5.0.3.Final      |          | Uninstalled | enterprise-4.0.3         | Hibernate Validator support
hibernate-orm                 | 5.0.5.Final      | x        | Started     | hibernate-osgi           | Combines all Hibernate core dependencies and requ
hibernate-envers              | 5.0.5.Final      |          | Uninstalled | hibernate-osgi           | Feature for easily adding Envers support to hiber
hibernate-infinispan          | 5.0.5.Final      |          | Uninstalled | hibernate-osgi           | Feature for easily adding Infinispan-based cachin
hibernate-ehcache             | 5.0.5.Final      |          | Uninstalled | hibernate-osgi           | Feature for easily adding Ehcache-based caching s
karaf@root()>

Run the following commands on Karaf shell to get Hibernate 5.1.0.Final working on Karaf 4.0.x:

feature:repo-add mvn:org.hibernate/hibernate-osgi/5.1.0.Final/xml/karaf
feature:install hibernate-orm

Hibernate 5 already provides a feature that is also available from maven central. Recent karaf versions provide a nice shortcut to install such features:

feature:repo-add hibernate 5.0.5.Final
feature:install hibernate-orm

So there is no need to manually download the hibernate zip. If you build your own feature that needs hibernate 5 then you need to provide a element in it that points to the full hibernate feature url.

mvn:org.hibernate/hibernate-osgi/5.0.5.Final/xml/karaf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM