gpt4 book ai didi

java - 在 glassfish 3.1.2.2 上部署 jersey/helloworld-osgi-webapp 时出错

转载 作者:太空宇宙 更新时间:2023-11-04 07:48:15 25 4
gpt4 key购买 nike


当尝试在 Glassfish 3.1.2.2 上部署示例 Jersey war 包代码(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插件没有在war中嵌入库?
提前感谢,米。

最佳答案

直接原因是在您的应用程序中它没有配置为这样做,而没有这样做的原因是在 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 标准导入包将 jersey-servlet 依赖项导入为 OSGi 服务:

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

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

关于java - 在 glassfish 3.1.2.2 上部署 jersey/helloworld-osgi-webapp 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14939901/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com