我正在尝试使用Hibernate 4.3.6.Final与Karaf 4.0.0 M2和MySQL v5.1.35,但收到以下错误:
karaf@root()> log:display
2015-06-05 11:14:32,068 | WARN | nsole user karaf | container | 120 - org.apache.aries.jpa.container - 1.0.2 | There are no suitable providers for the provider class name org.hibernate.jpa.HibernatePersistenceProvider and version range null to support the bundle leonard-orm-native/1.0.0.
2015-06-05 11:14:32,072 | WARN | nsole user karaf | container | 120 - org.apache.aries.jpa.container - 1.0.2 | There are no suitable providers for the provider class name org.hibernate.jpa.HibernatePersistenceProvider and version range null to support the bundle leonard-orm-native/1.0.0.
2015-06-05 11:14:32,073 | WARN | nsole user karaf | container | 120 - org.apache.aries.jpa.container - 1.0.2 | There are no suitable providers for the provider class name org.hibernate.jpa.HibernatePersistenceProvider and version range null to support the bundle leonard-orm-native/1.0.0.
2015-06-05 11:14:32,078 | ERROR | nsole user karaf | aries | 119 - org.apache.aries.jpa.blueprint.aries - 1.0.4 | No org.apache.aries.jpa.container.sync.Synchronization service registered.
2015-06-05 11:14:32,080 | INFO | nsole user karaf | BlueprintContainerImpl | 10 - org.apache.aries.blueprint.core - 1.4.2 | Bundle leonard-orm-native is waiting for dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=Leonard))(objectClass=javax.persistence.EntityManagerFactory))]
2015-06-05 11:14:32,081 | WARN | nsole user karaf | container | 120 - org.apache.aries.jpa.container - 1.0.2 | There are no suitable providers for the provider class name org.hibernate.jpa.HibernatePersistenceProvider and version range null to support the bundle leonard-orm-native/1.0.0.
2015-06-05 11:19:32,082 | ERROR | rint Extender: 3 | BlueprintContainerImpl | 10 - org.apache.aries.blueprint.core - 1.4.2 | Unable to start blueprint container for bundle leonard-orm-native due to unresolved dependencies [(&(&(org.apache.aries.jpa.proxy.factory=true)(osgi.unit.name=Leonard))(objectClass=javax.persistence.EntityManagerFactory))]
我可以在此处找到我要遵循的说明: http://www.liquid-reality.de/display/liquid/2012/01/13/Apache+Karaf+Tutorial+Part+6+-+Database+Access
我的项目中包含了Christian提供的数据源配置文件。
我已经做了大量的调查来解决,但我觉得我必须错过一些非常简单的事情。我们非常欢迎您的想法和贡献。
各种文件和karaf配置如下所示。
谢谢, 兰迪伦纳德
blueprint.xml
<?xml version="1.0" encoding="UTF-8"?>
<blueprint default-activation="eager" xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://aries.apache.org/xmlns/jpa/v1.0.0" xmlns:tx="http://aries.apache.org/xmlns/transactions/v1.0.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance
http://aries.apache.org/xmlns/jpa/v1.0.0 http://aries.apache.org/xmlns/jpa/v1.0.0
http://aries.apache.org/xmlns/transactions/v1.0.0 http://aries.apache.org/xmlns/transactions/v1.0.0 ">
<bean id="personService" class="net.lr.tutorial.karaf.db.examplejpa.impl.PersonServiceImpl">
<jpa:context unitname="Leonard" property="entityManager" />
<tx:transaction method="*" value="Required" />
</bean>
<service ref="personService" interface="net.lr.tutorial.karaf.db.examplejpa.PersonService" />
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="person/add">
<action class="net.lr.tutorial.karaf.db.examplejpa.command.AddPersonCommand">
<property name="personService" ref="personService" />
</action>
</command>
<command name="person/list">
<action class="net.lr.tutorial.karaf.db.examplejpa.command.ListPersonsCommand">
<property name="personService" ref="personService" />
</action>
</command>
<command name="person/deleteAll">
<action class="net.lr.tutorial.karaf.db.examplejpa.command.DeleteAllPersonsCommand">
<property name="personService" ref="personService" />
</action>
</command>
</command-bundle>
</blueprint>
的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="Leonard" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>osgi:service/Leonard</jta-data-source>
<class>net.lr.tutorial.karaf.db.examplejpa.Person</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>
在Karaf 4.0.0 M2中加载的捆绑包列表
karaf@root()> bundle:list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
--------------------------------------------------------------------------------------
144 | Active | 80 | 3.2.1 | Commons Collections
145 | Active | 80 | 2.6 | Commons Lang
146 | Active | 80 | 1.6.0 | Commons Pool
147 | Active | 80 | 1.1.1 | geronimo-jms_1.1_spec
152 | Active | 80 | 1.14.1.1 | Apache ServiceMix :: Bundles :: serp
153 | Active | 80 | 3.16.0 | Apache XBean :: ASM 4 shaded (repackaged)
154 | Active | 80 | 5.1.35 | Oracle Corporation's JDBC Driver for MySQL
155 | Active | 80 | 0.9.0 | ClassMate
156 | Active | 80 | 3.18.1.GA | Javassist
157 | Active | 80 | 2.0.1 | Apache Commons DBCP
158 | Active | 80 | 2.2.0 | Apache Commons Pool
159 | Active | 80 | 1.8.2.2 | Apache ServiceMix :: Bundles :: ant
160 | Active | 80 | 2.7.7.5 | Apache ServiceMix :: Bundles :: antlr
161 | Active | 80 | 3.0.0.1 | Apache ServiceMix :: Bundles :: cglib
162 | Active | 80 | 1.6.1.5 | Apache ServiceMix :: Bundles :: dom4j
163 | Active | 80 | 4.0.4.Final | hibernate-commons-annotations
164 | Active | 100 | 4.3.6.Final | hibernate-core
165 | Active | 100 | 4.3.6.Final | hibernate-entitymanager
166 | Active | 100 | 4.3.6.Final | hibernate-osgi
167 | Active | 80 | 1.2.2.Final | Java Annotation Indexer
168 | Active | 80 | 3.1.4.GA | JBoss Logging 3
169 | Active | 80 | 1.0.2.Final | JACC 1.4 API
170 | Active | 80 | 0.5.0 | OPS4J Pax JDBC Config
171 | Active | 80 | 0.5.0 | OPS4J Pax JDBC MySQL Driver Adapter
172 | Active | 80 | 0.5.0 | OPS4J Pax JDBC Pooling support using Commons-DBCP2
173 | Active | 80 | 0.5.0 | OPS4J Pax JDBC org.osgi.service.jdbc
174 | Active | 80 | 1.9.0 | Apache ServiceMix :: Specs :: Stax API 1.0
175 | Active | 80 | 1.4 | Commons DBCP
176 | Active | 80 | 4.0.0.M2 | Apache Karaf :: JDBC :: Core
189 | Failure | 80 | 1.0.0 | leonard-orm-native
安装功能列表如下:
karaf@root()> feature:list
Name | Version | Required | Installed | Repository | Description
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
transaction | 1.0.0 | | | enterprise-4.0.0.M2 | OSGi Transaction Manager
transaction | 1.0.1 | | | enterprise-4.0.0.M2 | OSGi Transaction Manager
transaction | 1.1.1 | x | x | enterprise-4.0.0.M2 | OSGi Transaction Manager
connector | 2.2.2 | | | enterprise-4.0.0.M2 | OSGi support for JCA Connector 1.5
connector | 3.1.1 | | | enterprise-4.0.0.M2 | OSGi support for JCA Connector 1.6
jpa | 2.0.0 | | x | enterprise-4.0.0.M2 | OSGi Persistence Container
jpa | 2.1.0 | x | x | enterprise-4.0.0.M2 | OSGi Persistence Container
openjpa | 2.2.2 | | | enterprise-4.0.0.M2 | Apache OpenJPA 2.2.x persistence engine support
openjpa | 2.3.0 | x | x | enterprise-4.0.0.M2 | Apache OpenJPA 2.3.x persistence engine support
hibernate | 3.3.2.GA | | | enterprise-4.0.0.M2 | Hibernate 3.x JPA persistence engine support
hibernate | 4.2.15.Final | | | enterprise-4.0.0.M2 | Hibernate 4.2.x JPA persistence engine support
hibernate-envers | 4.2.15.Final | | | enterprise-4.0.0.M2 | Hibernate Envers 4.2.x
hibernate | 4.3.6.Final | x | x | enterprise-4.0.0.M2 | Hibernate 4.3.x JPA persistence engine support
hibernate-envers | 4.3.6.Final | | | enterprise-4.0.0.M2 | Hibernate Envers 4.3.x
hibernate-validator | 5.0.3.Final | | | enterprise-4.0.0.M2 | Hibernate Validator support
jndi | 4.0.0.M2 | x | x | enterprise-4.0.0.M2 | OSGi Service Registry JNDI access
jdbc | 4.0.0.M2 | x | x | enterprise-4.0.0.M2 | JDBC service and commands
jms | 4.0.0.M2 | | | enterprise-4.0.0.M2 | JMS service and commands
application-without-isolation | 1.0.0 | x | x | enterprise-4.0.0.M2 | Provide EBA archive support
subsystems | 0.0.0.__aries_subsystem_version_ | | | enterprise-4.0.0.M2 | Support for OSGi subsystems
cxf-specs | 3.0.4 | | x | cxf-3.0.4 |
cxf-jaxb | 3.0.4 | | | cxf-3.0.4 |
cxf-abdera | 3.0.4 | | | cxf-3.0.4 |
wss4j | 2.0.3 | | | cxf-3.0.4 |
<!-- lots of cxf stuff -->
pax-jetty | 9.2.7.v20150116 | | x | org.ops4j.pax.web-4.1.0 | Provide Jetty engine support
pax-jetty-spdy | 4.1.0 | | | org.ops4j.pax.web-4.1.0 | Optional additional feature to run Jetty with SPDY
pax-http | 4.1.0 | | x | org.ops4j.pax.web-4.1.0 | Implementation of the OSGI HTTP Service
pax-http-whiteboard | 4.1.0 | | x | org.ops4j.pax.web-4.1.0 | Provide HTTP Whiteboard pattern support
pax-war | 4.1.0 | | x | org.ops4j.pax.web-4.1.0 | Provide support of a full WebContainer
pax-war-tomcat | 4.1.0 | | | org.ops4j.pax.web-4.1.0 | Provide support of a full WebContainer
pax-jsf-support | 4.1.0 | | | org.ops4j.pax.web-4.1.0 |
pax-cdi | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Provide CDI support
pax-cdi-1.1 | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Provide CDI 1.1 support
pax-cdi-1.2 | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Provide CDI 1.2 support
pax-cdi-weld | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Weld CDI support
pax-cdi-1.1-weld | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Weld CDI 1.1 support
pax-cdi-1.2-weld | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Weld CDI 1.2 support
pax-cdi-openwebbeans | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | OpenWebBeans CDI support
pax-cdi-web | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Web CDI support
pax-cdi-1.1-web | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Web CDI 1.1 support
pax-cdi-1.2-web | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Web CDI 1.2 support
pax-cdi-web-weld | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Weld Web CDI support
pax-cdi-1.1-web-weld | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Weld Web CDI 1.1 support
pax-cdi-1.2-web-weld | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Weld Web CDI 1.2 support
pax-cdi-web-openwebbeans | 0.12.0.SNAPSHOT | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | OpenWebBeans Web CDI support
deltaspike-core | 1.2.1 | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Apache Deltaspike core support
deltaspike-jpa | 1.2.1 | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Apache Deltaspike jpa support
deltaspike-partial-bean | 1.2.1 | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Apache Deltaspike partial bean support
deltaspike-data | 1.2.1 | | | org.ops4j.pax.cdi-0.12.0-SNAPSHOT | Apache Deltaspike data support
framework-security | 4.0.0.M2 | | | standard-4.0.0.M2 | OSGi Security for Karaf
service-security | 4.0.0.M2 | | | standard-4.0.0.M2 | Services Security for Karaf
aries-proxy | 4.0.0.M2 | | x | standard-4.0.0.M2 | Aries Proxy
aries-blueprint | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Aries Blueprint
aries-annotation | 4.0.0.M2 | | | standard-4.0.0.M2 | Aries Annotations
feature | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Features Support
shell | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Karaf Shell
shell-compat | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Karaf Shell Compatibility
deployer | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Karaf Deployer
wrapper | 4.0.0.M2 | | | standard-4.0.0.M2 | Provide OS integration
service-wrapper | 4.0.0.M2 | | | standard-4.0.0.M2 | Provide OS integration (alias to wrapper feature)
obr | 4.0.0.M2 | | x | standard-4.0.0.M2 | Provide OSGi Bundle Repository (OBR) support
bundle | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide Bundle support
config | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide OSGi ConfigAdmin support
diagnostic | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide Diagnostic support
instance | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide Instance support
jaas | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide JAAS support
log | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide Log support
package | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Package commands and mbeans
service | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide Service support
system | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide System support
http | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Implementation of the OSGI HTTP Service
http-whiteboard | 4.0.0.M2 | | x | standard-4.0.0.M2 | Provide HTTP Whiteboard pattern support
war | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Turn Karaf as a full WebContainer
jetty | 9.2.7.v20150116 | | | standard-4.0.0.M2 |
kar | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide KAR (KARaf archive) support
webconsole | 4.0.0.M2 | | | standard-4.0.0.M2 | Base support of the Karaf WebConsole
ssh | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide a SSHd server on Karaf
management | 4.0.0.M2 | x | x | standard-4.0.0.M2 | Provide a JMX MBeanServer and a set of MBeans in K
scheduler | 4.0.0.M2 | | | standard-4.0.0.M2 | Provide a scheduler service in Karaf to fire event
eventadmin | 4.0.0.M2 | | | standard-4.0.0.M2 | OSGi Event Admin service specification for event-b
jasypt-encryption | 4.0.0.M2 | | | standard-4.0.0.M2 | Advanced encryption support for Karaf security
scr | 4.0.0.M2 | | | standard-4.0.0.M2 | Declarative Service support
blueprint-web | 4.0.0.M2 | | | standard-4.0.0.M2 | Provides an OSGI-aware Servlet ContextListener for
wrap | 0.0.0 | x | x | standard-4.0.0.M2 | Wrap URL handler
profile | 4.0.0.M2 | | | standard-4.0.0.M2 | Profiles support
jolokia | 1.2.4.SNAPSHOT | | | standard-4.0.0.M2 | Jolokia monitoring support
<!-- lots of spring stuff -->
gemini-blueprint | 1.0.2.RELEASE | | | spring-4.0.0.M2 | Gemini Blueprint Extender
pax-jdbc-spec | 0.5.0 | | x | org.ops4j.pax.jdbc-0.5.0 | Provides OSGi JDBC Service spec
pax-jdbc | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Service support
pax-jdbc-config | 0.5.0 | x | x | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Config support
pax-jdbc-derby | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Derbi DataSourceFactory
pax-jdbc-h2 | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC H2 DataSourceFactory
pax-jdbc-mariadb | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Mariadb DataSourceFactory
pax-jdbc-mysql | 0.5.0 | x | x | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC MySQL DataSourceFactory
pax-jdbc-oracle | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Oracle DataSourceFactory
pax-jdbc-postgresql | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC PostgreSQL DataSourceFactory
pax-jdbc-sqlite | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC SQLite DataSourceFactory
pax-jdbc-pool-dbcp2 | 0.5.0 | x | x | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Pooling DataSourceFactory
pax-jdbc-pool-aries | 0.5.0 | | | org.ops4j.pax.jdbc-0.5.0 | Provides JDBC Pooling DataSourceFactory using Arie
在最后一点,我注意到jpa / 2.0.0和jpa / 2.1.0似乎都被加载了。我已经尝试卸载旧版本的jpa,但得到以下内容:
karaf@root()> feature:uninstall jpa/2.0.0
Error executing command: Feature named 'jpa/2.0.0' is not installed
答案 0 :(得分:1)
Karaf运行时安装了jpa / 2.0.0和jpa / 2.1.0。以下命令未删除旧的jpa版本:
karaf@root()> feature:uninstall jpa/2.0.0
Error executing command: Feature named 'jpa/2.0.0' is not installed
所以我开始使用新的Karaf 4.0.0 M2实例并从头开始安装所需的组件。没有安装jpa / 2.0.0,但是jpa / 2.1.0是。因此,我收到的错误消息已经解决。