gpt4 book ai didi

java - Maven Bundle 插件嵌入 deps 排除文件或包

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

我的 OSGi 包中需要 Apache 库 ( axis-jaxrpc ) 之一,但它有点缺陷,因为它的 jar 包含来自 java 内置程序 ( javax.xml.namespace.QName ) 的类。我无法用任何其他替代方案替换它 - 这是另一个依赖项的侧面依赖项......你知道这是怎么回事:)

问题是,每当我 bundle 并启动它时,它就会启动得很好。但是如果我触摸与 jaxrpc 相关的任何功能我收到一个 LinkageError 声称 QName已被 <bootloader> 加载。

我成功爆炸了jaxrpc jar 到我的 bundle jar 中,并在启动应用程序之前手动删除 javax.namespace 目录(即编辑 bundle jar 内容)。这成功了 - 我不再收到 LinkageError。

现在的问题是...我该如何以非 sado-maso 方式处理这种情况,并从嵌入的 jar 文件中排除有问题的类/包?

POM 片段:

依赖关系:

<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>

bundle 插件:

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.6</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>
/* application packages only */
</Export-Package>
<Private-Package>
/* application packages only */
</Private-Package>
<DynamicImport-Package>
*
</DynamicImport-Package>
<Import-Package></Import-Package>
<Include-Resource>
{maven-resources},target/classes/rebel.xml
</Include-Resource>
<Embed-Dependency>
/* other dependencies */
axis,
axis-jaxrpc;inline=true,
commons-discovery,
commons-logging
</Embed-Dependency>
</instructions>
</configuration>
</plugin>

换句话来说......有什么办法可以这样做:

<Embed-Dependency>
axis-jaxrpc;inline=true;exclude=javax.namespace.QName
</Embed-Dependency>

编辑:

为了清楚起见,异常(exception)情况:

Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.axis.message.MessageElement.getChildElements(Ljavax/xml/namespace/QName;)Ljava/util/Iterator;" the class loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) of the current class, org/apache/axis/message/MessageElement, and the class loader (instance of ) for interface javax/xml/soap/SOAPElement

最佳答案

删除axis-jaxrpc来自<Embed-Dependency>并添加 axis-jaxrpc 中的包您关心的<Private-Package>部分 - 这些将嵌入到您的 bundle 中。您可能需要对包 axis-jaxrpc 执行相同的操作依赖于或将相应的依赖包添加到 <Embed-Dependency>

关于java - Maven Bundle 插件嵌入 deps 排除文件或包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46523429/

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