简体   繁体   English

Apache felix 无法将 dbcp2 作为捆绑加载

[英]Apache felix cannot load dbcp2 as bundle

I have created an OSGi bundle, that is using apache commons dbcp2 to create a database connection pool.我创建了一个 OSGi 包,它使用 apache commons dbcp2 创建数据库连接池。 I am using apache felix gogo as runtime to start my bundles.我正在使用 apache felix gogo 作为运行时来启动我的包。 I have loaded multiple other external libraries without any problems into the apache felix:我已经将多个其他外部库毫无问题地加载到 apache felix 中:

Image here (cant post no rep): https://i.gyazo.com/c779ccaba20e3fa327d61a621748d8dc.png图片在这里(不能发布没有代表): https://i.gyazo.com/c779ccaba20e3fa327d61a621748d8dc.png

However every time I try to start dbcp2 bundle which is requiered in my bundle I get the following error:但是,每次我尝试启动捆绑包中需要的 dbcp2 捆绑包时,都会出现以下错误:

Image here (cant post no rep): https://i.gyazo.com/ac7b673e63b9e6ad764af2e6adddb19a.png图片在这里(不能发布没有代表): https://i.gyazo.com/ac7b673e63b9e6ad764af2e6adddb19a.png

I have found that there is some Apache mixservice bundle available, but it contains dbcp 1.4 and I need dbcp 2.5.0 or higher.我发现有一些 Apache mixservice bundle 可用,但它包含 dbcp 1.4,我需要 dbcp 2.5.0 或更高版本。

What needs to be done so apache felix is able to load the dbcp2 as a library requiered by other projects?需要做什么才能使 apache felix 能够将 dbcp2 作为其他项目所需的库加载?

What you see in the error is that the dbcp bundle requires the javax.transaction package in version >= 1.1.0.您在错误中看到的是 dbcp 包需要版本 >= 1.1.0 的 javax.transaction package。 This is not an error in the bundle.这不是捆绑包中的错误。 It just means that you need to provide this package in the OSGi container.这只是意味着您需要在 OSGi 容器中提供这个 package。

Normally you would install a bundle that provides the package.通常你会安装一个提供 package 的包。 In this case the package comes from the jre and the system bundle should export it.在这种情况下,package 来自 jre,系统捆绑包应将其导出。

Depending on how you start felix the way to export a system package is different.根据您启动 felix 的方式,导出系统 package 的方式不同。 For example if you use bndtools you do this in a bndrun file.例如,如果您使用 bndtools,您可以在 bndrun 文件中执行此操作。 See the Enroute microsevice example .请参阅Enroute 微服务示例

For plain felix see the parameter " org.osgi.framework.system.packages.extra ".对于普通的 felix,请参见参数“ org.osgi.framework.system.packages.extra ”。

In this example the javax.transaction package is exported (among some others).在此示例中,导出了 javax.transaction package(以及其他一些)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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