如何在EJB jar文件中包含jar依赖项?

Xanathos

我正在尝试部署一个在其WEB-INF/libEJB jar文件中包含的Web项目该EJB在其构建路径中配置了对log4j(jar)的引用。当我使用打包在Websphere Application Server 8.5.5中的Web项目部署.ear文件并在其中启动servlet时,出现以下错误:

Error 500: javax.servlet.ServletException: SRVE0319E: For the [ServletPrueba] servlet, pe.com.projectavalon.Servlet.ServletPrueba servlet class was found, but a resource injection failure has occurred. 

我检查了日志,似乎找不到对“ log4j.jar”的引用。

[22/02/14 1:41:42:402 COT] 0000007c InjectionBind E   CWNEN0030E: The @EJB factory encountered a problem getting the object instance pe.com.projectavalon.Servlet.ServletPrueba/prueba binding object.  The exception message was: The EJB reference in the SampleWeb.war module of the SampleEAR application could not be resolved; nested exception is: com.ibm.ejs.container.ContainerEJBException: Unable to initialize deferred EJB.; nested exception is: com.ibm.ejs.container.ContainerException: Failed to start the Test component in the SampleWeb.war module of the SampleEAR application. : An operation in the enterprise bean constructor failed. It is recommended that component initialization logic be placed in a PostConstruct method instead of the bean class no-arg constructor.; nested exception is: 
    java.lang.NoClassDefFoundError: org/apache/log4j/Logger
[22/02/14 1:41:42:404 COT] 0000007c webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[ServletPrueba]: com.ibm.wsspi.injectionengine.InjectionException: Unable to obtain an instance for pe.com.projectavalon.Servlet.ServletPrueba/prueba: javax.ejb.EJBException: The EJB reference in the SampleWeb.war module of the SampleEAR application could not be resolved; nested exception is: com.ibm.ejs.container.ContainerEJBException: Unable to initialize deferred EJB.; nested exception is: com.ibm.ejs.container.ContainerException: Failed to start the Test component in the SampleWeb.war module of the SampleEAR application. : An operation in the enterprise bean constructor failed. It is recommended that component initialization logic be placed in a PostConstruct method instead of the bean class no-arg constructor.; nested exception is: 
    java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1123)
    at com.ibm.ws.ejb.injection.processor.EJBInjectionBinding.getInjectionObject(EJBInjectionBinding.java:1101)
    at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectableObject(InjectionBinding.java:1032)
    at com.ibm.wsspi.injectionengine.InjectionTarget.inject(InjectionTarget.java:125)
    at com.ibm.ws.injectionengine.AbstractInjectionEngine.inject(AbstractInjectionEngine.java:1065)
    at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.inject(WASAnnotationHelper.java:380)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.createTarget(ServletWrapperImpl.java:261)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1486)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1472)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:620)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1032)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:909)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)

当我检查ejb jar文件时,我发现log4j不存在。如何将log4j的jar包含在EJB Jar文件中?

印度骑士

最好在WEB-INF\lib目录下有log4j.jar文件然后,Web应用程序和ejb应用程序代码库都可以使用它。为此,请确保在您的ejb jar文件中,您有META-INF/MANIFEST.MF文件在Class-Path输入下指定log4j jar文件路径请记住,该路径必须相对于您的ejb jar文件。

例如,在下面的结构中,您可以在Class-PathMANIFEST.MF条目中指定lib/log4j.jar

WAR
|
-- WEB-INF
    |
    -- web.xml
    |
    -- classes
    |
    -- lib
        |
        -- ejb jar
        |      |
        |      |-- META-INF
        |              |
        |              -- MANIFEST.MF
        | 
        |
        |
        |-- log4j.jar

(格式不如手工输入那么好)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在jar文件中包含Maven依赖项?

如何在Gradle的JAR中包含单个依赖项?

如何在JRuby中包含类依赖项jar?

如何修改包含在作为 IntelliJ 依赖项的 JAR 中的文件

我如何仅包含依赖项标签中的jar

如何使用bnd / maven-bundle-plugin从jar依赖项将资源文件包含在osgi捆绑包中?

如何在.war中包含ejb-jar.xml

如何在Maven项目的部署中包含依赖项的测试jar?

如何使用maven创建一个可运行的jar,它在单独的“ lib”文件夹中包含依赖项(不是uber jar)

在Android Gradle构建中,如何从包含的jar文件中排除依赖项?

如何在Java中将依赖项添加到jar文件中

如何在其 jar 依赖项中读取战争文件清单?

如何在.jar中包含.xlsx文件?

如何将JAR依赖项包含到AAR库中

如何在Maven中添加jar依赖项?

如何使用Maven创建一个jar,其中每个依赖项在单独的文件夹中包括依赖项

包含依赖项中的类的jar文件

如何将所有依赖项放在可运行jar的单独文件夹中?

我如何使用Maven创建可执行jar文件,包括主类在Test中的依赖项

建立/部署EJB .jar及其依赖项

如何列出JAR的依赖项

如何获取.jar依赖项的文件路径位置?

如何确定升级依赖项是否会破坏jar文件?

如何编译具有jar依赖项的Java文件?

创建jar文件时如何包括库/依赖项?

如何用jar文件替换Google依赖项

如何在gradle jar任务生成的jar中包括运行时依赖项

如何在WAR文件中包含依赖项?

如何以 jar 格式在该 jar 中具有依赖项的最终 jar?