【问题标题】:error when deploying jersey/helloworld-osgi-webapp on glassfish 3.1.2.2在 glassfish 3.1.2.2 上部署 jersey/helloworld-osgi-webapp 时出错
【发布时间】:2013-02-03 02:18:23
【问题描述】:


尝试在 Glassfish 3.1.2.2 上部署示例球衣战争捆绑代码(git 上的 helloworld-osgi-webapp:https://github.com/jersey/jersey-1.x/tree/master/jersey/samples/helloworld-osgi-webapp)时,我收到以下 osgi 错误:

remote failure: Error occurred during deployment: Exception while loading the app: 
  org.osgi.framework.BundleException: Unresolved constraint in bundle war-bundle [344]:
  Unable to resolve 344.0: missing requirement [344.0] osgi.wiring.package; (&(osgi.wiring.package=com.sun.jersey.api.core)(version>=1.18.0)(!(version>=2.0.0))).
  Please see server.log for more details.
  Command deploy failed

为什么 maven felix 插件没有在战争中嵌入库?
提前感谢, M.

【问题讨论】:

    标签: java jersey osgi glassfish-3 apache-felix


    【解决方案1】:

    直接原因是在您的应用程序中它没有被配置为这样做,而不是因为在 OSGi 世界中它不应该这样做。

    来自pom,它在提供的范围内:

    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-servlet</artifactId>
    <version>${project.version}</version>
    <scope>provided</scope>
    <classifier>cobertura</classifier>
    

    而且它只会嵌入运行时和编译范围:

    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
    

    并使用 OSGi 标准 import-package 将 jersey-servlet 依赖项导入为 OSGi 服务:

    <Import-Package>com.sun.jersey.api.core,com.sun.jersey.spi.container.servlet,*</Import-Package>
    

    在 OSGi 世界中,依赖项应该部署为单独的 OSGi 包,而不是嵌入到战争中。这就是你的例子正在做的事情。因此,您应该将 jersey 部署为单独的 OSGi 包。

    【讨论】:

    • (如果你真的非常想嵌入它,你应该将依赖范围从“提供”更改为“编译”并删除相关的导入包)
    • 我的问题是我需要在具有球衣 1.11 的 Glassfish 3.1.2.2 上部署我的 OSGi wab,并且我想使用球衣的 2.x 版本。我现在的解决方法是使用 1.11。我应该升级我的GF的球衣吗?还是嵌入我的球衣依赖项更好?
    • @mehdi-terraneen 最好在 glassfish 上升级它,但请注意,您需要一个有效的 osgified 版本。
    猜你喜欢
    • 2013-07-04
    • 1970-01-01
    • 2018-12-09
    • 1970-01-01
    • 1970-01-01
    • 2011-10-20
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    相关资源
    最近更新 更多