IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Java code works fine in Java Project while it fails in wM Java Service

  • 1.  Java code works fine in Java Project while it fails in wM Java Service

    Posted Thu September 05, 2019 05:14 AM

    Hi Experts,

    I am trying to generate an excel file using apache POI API and I have included the below jar files in a java project and executed the service and the excel file was successfully created.

    commons-codec-1.12.jar
    commons-collections4-4.3.jar
    commons-compress-1.3.jar
    dom4j-1.6.1.jar
    poi-3.9-20121203.jar
    poi-ooxml-3.9-20121203.jar
    poi-ooxml-schemas-3.9-20121203.jar
    xmlbeans-3.1.0.jar

    But, When I include the same code in webMethods java service, it gives the below error. I searched online and it seems such errors as below will occur when 2 versions of the same .jar files are in the classpath and will conflict.

    java.lang.reflect.InvocationTargetException: org.apache.poi.xssf.streaming.SXSSFWorkbook.getSheetAt(I)Lorg/apache/poi/xssf/streaming/SXSSFSheet;

    I searched in my SAG Installation Directory for any conflicting poi jar files and it seems it is referred at many other places as well(please refer attached file for details) and I am not sure how I can make my program to use only the .jar files placed inside my package/code/jars directory.

    Note: Debugging the java service does not result in any error and the excel file is generated successfully, but running it gives the above error.

    Appreciate any help on this.

    Regards,
    Irfan
    POI Jar References.txt (7.13 KB)


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 2.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Thu September 05, 2019 10:49 AM

    Hi Irfan,

    was the package reloaded after placing the Jar-Files into code/jars?

    Can you provide some more lines from Server-Log, as the InvocationTargetException seems to be incomplete for me?
    You can check the IS Classpath in IS Admin UI in the WmRoot package by opening the WmRoot/about.dsp page

    Regards,
    Holger


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Thu September 05, 2019 04:22 PM

    Hi Holger,

    Thanks for the response.

    Yes, the package was reloaded after placing the jar files and restarted the IS as well but no luck.

    Here are the logs.

    Error Message

    org.apache.poi.xssf.streaming.SXSSFWorkbook.getSheetAt(I)Lorg/apache/poi/xssf/streaming/SXSSFSheet;
    Caused by: java.lang.reflect.InvocationTargetException: null
    Caused by: java.lang.NoSuchMethodError: org.apache.poi.xssf.streaming.SXSSFWorkbook.getSheetAt(I)Lorg/apache/poi/xssf/streaming/SXSSFSheet;

    Stack Trace:

    java.lang.NoSuchMethodError: org.apache.poi.xssf.streaming.SXSSFWorkbook.getSheetAt(I)Lorg/apache/poi/xssf/streaming/SXSSFSheet;
    at LargeExcelProcessing.java.documentListToExcel(java.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:404)
    at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:645)
    at com.wm.ps.serviceMock.ServiceInterceptor.process(ServiceInterceptor.java:360)
    at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:39)
    at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:53)
    at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
    at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
    at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
    at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:299)
    at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:34)
    at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:377)
    at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:544)
    at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:382)
    at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:234)
    at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:215)
    at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:257)
    at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:520)
    at com.wm.lang.flow.FlowState.step(FlowState.java:389)
    at com.wm.lang.flow.FlowState.invoke(FlowState.java:360)
    at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcI…

    If we assume there is something wrong in the jars or code, then how is it that debugging the same java service with the same jars not throwing any error.

    Please share your thoughts on the same.

    Thanks,
    Irfan


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 4.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Fri September 06, 2019 12:21 AM

    Hi,

    Apparently your IS has multiple copies of Apache-POI jars scattered everywhere in the instance. Please check at the classpath of the about page of IS Admin UI and see if at the IS common library folder there is already similar files being loaded into memory. That might be the reason why it confuses the JVM and resolve to the wrong jar file.

    When developing in Designer, the issue won’t be there simply because the said jar file is the only jar file existed in the Designer built classpath hence will not have that issue.

    Can you check manifest.v3 in your package containing this line?

    package


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 5.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Fri September 06, 2019 06:31 AM

    Hi Mike,

    Yes, I suspected the same and hence I removed the below 2 jar files manually(from the mentioned jars shared earlier) to see if the issue resolves but no luck there.

    ./common/runtime/bundles/inm/eclipse/plugins/org.apache.poi_3.9.0.v201405241750.jar
    ./Designer/eclipse/plugins/org.apache.poi_3.9.0.v201405241750.jar

    I have seen manivest.v3 file and below are the contents of it.

    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <Values version="2.0">
    <value name="enabled">yes</value>
    <value name="system_package">no</value>
    <value name="version">1.0</value>
    <null name="startup_services"/>
    <null name="shutdown_services"/>
    <null name="replication_services"/>
    <null name="requires"/>
    <null name="listACL"/>
    <value name="webappLoad">yes</value>
    </Values>

    I tried by adding the mentioned line of classpath and reloaded the package/restarted IS but it didnt help.

    Any other update I have to do in my manifest.v3 to force it use only the jars inside the package?

    Regards,
    Irfan


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 6.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Fri September 06, 2019 01:14 PM

    Hi,

    The one affecting your IS are likely these:

    ./IntegrationServer/instances/default/packages/LargeExcelProcessing/code/jars/poi-3.9-20121203.jar
    ./IntegrationServer/instances/default/packages/LargeExcelProcessing/code/jars/poi-ooxml-3.9-20121203.jar
    ./IntegrationServer/instances/default/packages/LargeExcelProcessing/code/jars/poi-ooxml-schemas-3.9-20121203.jar

    Could it be either one of these having the same class in the namespace?

    Try disable this package LargeExcelProcessing and restart the IS again.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Fri September 06, 2019 02:44 PM

    Hi,

    I should have mentioned this probably, that ‘LargeExcelProcessing’ is the package I am working on and hence I have placed the .jar files inside the package.

    I am suspecting something conflicting from the common runtime, but I checked in the about page and did not see anything related to poi jars on the classpath but still only debug works but running the service fails.

    Regards,
    Irfan


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 8.  RE: Java code works fine in Java Project while it fails in wM Java Service

    Posted Sun September 08, 2019 04:44 AM

    Hi Mike/Holger,

    The issue is resolved now. Here is what I did.

    Deleted the poi .jars from the Integration Server/lib folder and deleted the package which was giving error and restarted the IS and then freshly created a new package and kept the relevant jars inside the jars folder of the package and the error is no longer existing now.

    Thanks for the support.

    Regards,
    Irfan


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods