osgi服务报错以及相应的解决方法

来源:互联网 发布:sql server 2012版本 编辑:程序博客网 时间:2024/06/11 14:58

自己在项目中配置相关的OSGI服务,然后不能正常启动,首先是看容器的日志,

日志报错如下


Could not start bundlemvn:com.gzydt.license/com.gzydt.license.sign.service/1.0.0 in feature(s)license-sign-0.0.0: Unresolved constraint in bundlecom.gzydt.license.sign.service [239]: Unable to resolve 239.0: missingrequirement [239.0] osgi.wiring.package;(osgi.wiring.package=com.gzydt.license.sign.persist)

像碰到这种说在等待自己的组件的相关依赖的错误,一般可能有两种情况,第一,在依赖包中(pom)文件中没有加要依赖的包的范围,一般是提供范围为provide。如下就可以

<dependency> <groupId>com.gzydt.license</groupId><artifactId>com.gzydt.license.base.persist</artifactId><version>1.0.0</version><!--这个范围一定要提供,不然的话会依赖其他的包  --><scope>provided</scope></dependency><dependency> <groupId>com.gzydt.license</groupId><artifactId>com.gzydt.license.base.service</artifactId><version>1.0.0</version><!--这个范围一定要提供,不然的话会依赖其他的包  --><scope>provided</scope></dependency>
第二种情况就是要依赖的组件没有想外提供服务,导致他不能使用该组件的服务,

修改如下则可以

<Export-Package>com.gzydt.license.base.persist,com.gzydt.license.base.persist.entity,org.apache.commons.dbcp2</Export-Package>

第二种错误:

org.osgi.service.blueprint.container.ComponentDefinitionException:Unresolved ref/idref to component: licenseService


首先找到是在哪个组件中报这个错误的,然后到相应的buleprint.xml文件中去修改相应的服务

然后修改为正确的服务即可



0 0
原创粉丝点击