![](/img/trans.png)
[英]websphere liberty - Not able to generate application specific logging using slf4j or log4j
[英]websphere liberty - SLF4J jars conflicting with websphere internal bundles
我有一個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包導入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.