gpt4 book ai didi

java - websphere liberty - SLF4J jar 与 websphere 内部包冲突

转载 作者:行者123 更新时间:2023-12-02 08:45:11 27 4
gpt4 key购买 nike

我有一个 OSGi 应用程序,其中包含 3 个包 -

1 - LoggingWrapper,充当 log4j 和 slf4j jar 的包装器,并导出 org.slf4j.* 包。

2 - MyProject,包含 JPA 代码,并导入以下包:

Import-Package: javax.management,
javax.naming,
javax.persistence;version="1.1.0",
javax.persistence.criteria;version="1.1.0",
javax.persistence.metamodel;version="1.1.0",
javax.sql;version="0.0.0",
javax.transaction;version="1.1.0",
javax.transaction.xa;version="1.1.0",
org.apache.openjpa.enhance;version="2.2.0",
org.apache.openjpa.util;version="2.2.0",
org.slf4j

在服务器上部署它会导致以下错误:

[AUDIT   ] CWWKZ0404E: An exception was generated when trying to resolve the contents of the application JpaTestApp.  The exception text from the OSGi framework is: Uses constraint violation. Unable to resolve resource MyProject [IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/defaultServer/apps/JpaTestApp.eba/MyProject_1.0.0.jar] because it is exposed to package 'org.slf4j' from resources LoggingWrapper [IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/defaultServer/apps/JpaTestApp.eba/LoggingWrapper_1.0.0.jar] and com.ibm.ws.slf4j-api.1.7.7 [osgi.identity; osgi.identity="com.ibm.ws.slf4j-api.1.7.7"; type="osgi.bundle"; version:Version="1.0.7.cl50420141211-1039"] via two dependency chains.

Chain 1:
MyProject [IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/defaultServer/apps/JpaTestApp.eba/MyProject_1.0.0.jar]
import: (&(osgi.wiring.package=org.slf4j)(version>=0.0.0))
|
export: osgi.wiring.package: org.slf4j
LoggingWrapper [IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/defaultServer/apps/JpaTestApp.eba/LoggingWrapper_1.0.0.jar]

Chain 2:
MyProject [IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/defaultServer/apps/JpaTestApp.eba/MyProject_1.0.0.jar]
import: (&(osgi.wiring.package=org.apache.openjpa.util)(version>=2.2.0))
|
export: osgi.wiring.package=org.apache.openjpa.util; uses:=org.slf4j
com.ibm.ws.jpa [osgi.identity; osgi.identity="com.ibm.ws.jpa"; type="osgi.bundle"; version:Version="1.0.7.cl50420141211-1039"]
import: (osgi.wiring.package=org.slf4j)
|
export: osgi.wiring.package: org.slf4j
com.ibm.ws.slf4j-api.1.7.7 [osgi.identity; osgi.identity="com.ibm.ws.slf4j-api.1.7.7"; type="osgi.bundle"; version:Version="1.0.7.cl50420141211-1039"]
[AUDIT ] CWWKZ0020I: Application JpaTestApp not updated.

从应用程序中删除“LoggingWrapper”包会导致以下错误:

[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications. 
[AUDIT ] CWWKZ0404E: An exception was generated when trying to resolve the contents of the application JpaTestApp. The exception text from the OSGi framework is: Unable to resolve IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/experimentalServer/apps/JpaTestApp.eba/XLetDBUtility_1.0.0.jar: missing requirement org.apache.aries.subsystem.core.archive.ImportPackageRequirement: namespace=osgi.wiring.package, attributes={}, directives={filter=(&(osgi.wiring.package=org.slf4j)(version>=0.0.0))}, resource=IFileAdapter wrapping file with url file:/D:/programs/WebSphere/liberty/wlp/usr/servers/experimentalServer/apps/JpaTestApp.eba/XLetDBUtility_1.0.0.jar
[AUDIT ] CWWKZ0012I: The application JpaTestApp was not started.

如何解决这些错误?

最佳答案

尽管 Liberty 旨在将应用程序与运行时中包含的开源库(例如 slf4j)隔离开来,但如果导入某些 openjpa 包,似乎会存在一些泄漏。您应该能够在应用程序中使用 JPA,而无需导入 org.apache.openjpa* 包,因此最好的选择是避免它们。切换到动态运行时增强(而不是构建时增强)将节省构建步骤,并且还允许您删除 openjpa 包导入。

关于java - websphere liberty - SLF4J jar 与 websphere 内部包冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28983486/

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