java.lang.NoClassDefFoundError: inside EJB Module

3k views Asked by At

I am trying to set up my application in my local workspace which is having WAS 6.1 Server. Its an enterprise application. After setting up the workspace, all the functionalities are working as expected except one webservices call.

In our application we use to make a service call to retrieve documents from repository.

public Document executeSearchRequest(String packageName, String serviceName, Document searchCriteriaDoc) throws CfGCPApplicationException
{
    try
    {
    CiServiceConsumerFactory serviceFactory = (CiServiceConsumerFactory) CfFrameworkMgr.getInstance().getComponent("SERVICE_CONSUMER_FACTORY");
    Document responseDoc = null;
    CiServiceConsumer consumer = serviceFactory.createConsumer();
    CffinServiceCall finRequestServiceCall = new CffinServiceCall();
    finRequestServiceCall.setPackageName(CfPropertyLoader.getProperty(packageName));
    CfLogWriter.debug("Package name : "+ CfPropertyLoader.getProperty(packageName));
    finRequestServiceCall.setServiceName(CfPropertyLoader.getProperty(serviceName));
    CfLogWriter.debug("Service name  : "+ CfPropertyLoader.getProperty(serviceName));
    finRequestServiceCall.setPayload(searchCriteriaDoc);
    CfLogWriter.debug("Payload  : "+ CfXMLHelper.getStringFromDocument(searchCriteriaDoc) );
    finRequestServiceCall.setTimeout(Integer.parseInt(CiGCPConstants.SERVICE_TIMEOUT_PERIOD)); //ToDo 
    CfLogWriter.debug("Timeout period  : "+ CiGCPConstants.SERVICE_TIMEOUT_PERIOD );
    System.setProperty("com.ibm.ssl.performURLHostNameVerification", "true");                   
// **Below statement is where the error is happening** 


            CffinServiceCall finReplyServiceCall = consumer.callRequestReply(finRequestServiceCall);

    if (finReplyServiceCall != null ){ 

        responseDoc = finReplyServiceCall.getPayloadSingleDocument();
        CfLogWriter.debug("Response Document : "+CfXMLHelper.getStringFromDocument(responseDoc));
    }
    return responseDoc;
    }catch(Exception ex)
    {
        throw new CfGCPApplicationException("executeSearchRequest failed" , ex);
    }

}

When i try to retrieve documents it is showing below error .

[1/3/17 12:31:55:517 CST] 00000033 ExceptionUtil E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "searchDocument" on bean "BeanId(GCPonline#GCPonlineEJB.jar#CrOnlineDocumentSearchRetrieval, null)". Exception data: java.lang.NoClassDefFoundError: com.fin.services.consumer.FetchServiceConsumerType
at com.fin.framework.services.consumer.CfServiceConsumerMgrImpl.checkConfigCache(CfServiceConsumerMgrImpl.java:665)
at com.fin.framework.services.consumer.CfServiceConsumerMgrImpl.getServiceDefinitionType(CfServiceConsumerMgrImpl.java:622)
at com.fin.framework.services.consumer.CfServiceConsumerMgrImpl.getServiceConsumerConfiguration(CfServiceConsumerMgrImpl.java:652)
at com.fin.framework.services.consumer.CfServiceConsumerImpl.getConsumerConfiguration(CfServiceConsumerImpl.java:687)
at com.fin.framework.services.consumer.CfServiceConsumerImpl.callRequestReply(CfServiceConsumerImpl.java:278)
at com.fin.app.GCP.facade.CfGCPBaseECMInterface.executeSearchRequest(CfGCPBaseECMInterface.java:92)
at com.fin.app.GCP.facade.CfGCPMobiusInterface.searchDocMetaDataDetByService(CfGCPMobiusInterface.java:90)
at com.fin.app.GCP.facade.CfGCPMobiusInterface.searchDocMetaDataDet(CfGCPMobiusInterface.java:66)
at com.fin.app.GCP.facade.CfOnlineDocumentSearchRetrievalUtility.searchMobiusDocuments(CfOnlineDocumentSearchRetrievalUtility.java:169)
at com.fin.app.GCP.facade.CfOnlineDocumentSearchRetrievalUtility.searchDocument(CfOnlineDocumentSearchRetrievalUtility.java:86)
at com.fin.app.GCP.bs.CrOnlineDocumentSearchRetrievalBean.searchDocument(CrOnlineDocumentSearchRetrievalBean.java:26)
at com.fin.app.GCP.bs.EJSRemoteStatelessCrOnlineDocumentSearchRetrieval_6df5d278.searchDocument(EJSRemoteStatelessCrOnlineDocumentSearchRetrieval_6df5d278.java:65)
at com.fin.app.GCP.bs._CrOnlineDocumentSearchRetrieval_Stub.searchDocument(_CrOnlineDocumentSearchRetrieval_Stub.java:75)
at com.fin.app.GCP.bs.delegate.CfGCPBsDelegateServiceImpl.searchDocument(CfGCPBsDelegateServiceImpl.java:1180)
at com.fin.app.GCP.actions.CgBillDetailsDispatchAction.retrieveDocument(CgBillDetailsDispatchAction.java:1070)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:989)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.fin.app.GCP.controller.CgAuthorizationFilter.doFilter(CgAuthorizationFilter.java:96)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3252)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:264)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1439)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:112)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1815)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
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:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)

The method FetchServiceConsumerType is present inside jar named Servicemf and I have checked the class path, The jar is present in the class path as below :

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="ejbModule"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/WebSphere v6.1 JRE"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.ibm.ws.ast.st.runtime.runtimeTarget.v61/was.base.v61"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry exported="true" kind="lib" path="/sharedlib/fetch/6.1.04/fetchservices.jar"/>
<classpathentry exported="true" kind="lib" path="/sharedlib/fetch/6.1.04/servicemf.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/gcponlineWeb"/>
<classpathentry kind="output" path="ejbModule"/>
</classpath>

I am totally clueless on what i need to do. Please throw some light on this .. Thanks in advance !!!

1

There are 1 answers

0
Andy Guibert On

If a class is available at compile time, you need to also make that class available to your application at runtime when it is deployed to the server.

It sounds like the missing class FetchServiceConsumerType comes from /sharedlib/fetch/6.1.04/servicemf.jar on your class path. So you have two basic options to make the class available to your application at runtime:

  1. Package the servicemf.jar in your enterprise application (EAR)
  2. Add servicemf.jar to a shared library, and provide that shared library to your enterprise application

Both options (among others) are described in detail here:
IBM - Best Practice for using common application files