2014-02-22 3 views
1

EJB jar 파일 WEB-INF/lib에있는 웹 프로젝트를 배포하려고합니다. 이 EJB는 빌드 경로에 log4j (jar)에 대한 참조를 구성합니다. 내가 웹 스피어 애플리케이션 서버 8.5.5에 패키지 된 웹 프로젝트와 .ear 파일을 배포하고, 내부의 서블릿을 시작할 때, 나는이 오류가 :EJB jar 파일에 jar 종속성을 포함시키는 방법은 무엇입니까?

나는 로그를 확인

, 보이는 것과 기준은 " 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가 없다는 것을 알았습니다. EJB Jar 파일 안에 log4j의 jar를 어떻게 넣을 수 있습니까?

답변

1

WEB-INF\lib 디렉토리 아래에 log4j.jar 파일이있는 것이 더 좋습니다. 그런 다음 웹 응용 프로그램과 ejb 응용 프로그램 코드베이스에서 모두 사용할 수 있습니다. 이렇게하려면 ejb jar 파일에 META-INF/MANIFEST.MF 파일에 Class-Path 항목 아래에 log4j jar 파일 경로를 지정했는지 확인하십시오. 염두에두고, 경로는 ejb jar 파일에 상대적이어야합니다.

+0

완벽하게 작동합니다. 조정할 항목이 있지만 서블릿의 호출이 훌륭하게 작동합니다. 감사. 그리고 포맷팅은 꽤 명확합니다. 걱정하지 마세요 = D – Xanathos

+0

당신은 환영합니다 :-) – IndoKnight

2

META-INF/MANIFEST.MF을 만들었거나 작성 했습니까?

Manifest 내에서로드 할 jar도 지정할 수 있습니다. 이 기능을하려면 항아리를 귀에 직접 놓아야합니다.

이 경우 tutorial이 있습니다.

-1

설정 a를 예를 들어

, 당신은

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

lib/log4j.jar로 MANIFEST.MF의 Class-Path 항목에 지정할 수 있습니다 아래의 구조 (가 손으로 입력이 같은 형식은 잘되지 않습니다) 응용 프로그램 서버 (환경> 공유 라이브러리)에서 공유 라이브러리를 열고 모든 병을 그 경로에 넣으십시오. 웹 프로젝트의 Manifest.mf에서 항아리를 언급해야합니다. 매니페스트 파일의 경로는 WebContent> META-INF입니다.

관련 문제