webMethods

webMethods

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
  • 1.  Conflict with commons lib

    Posted Sun December 08, 2024 11:32 PM
    hi,
     
    I want to use Apache commons-io V2.16.1 in my Java service. My code works fine in standalone mode (not in webMethods), but when I put it into IS it throws an « Exception ».
     
    After some research, I found an older version of this library in "/webMethods/common/lib/ext/". Unfortunately, this jar file cannot be changed to the latest version as it may affect other apps or IS itself.
     
    Is there a way to use my javaservice with commons-io in the « instances/default/lib/jars/custom » folder instead of « /webMethods/common/lib/ext/ »?
     
    thank you for your reply







    ------------------------------
    DONGWOO LEE
    ------------------------------


  • 2.  RE: Conflict with commons lib

    Posted Tue December 10, 2024 09:33 AM

    See Where to Put Your Classes and Jar Files:

    If your package needs a different version of a class or jar file than one that is on the server classpath, do the following:
    1.Copy the version you need to your package's code/classes or code/jars directory.
    2.Change your package's classloader property to "package".

    More details on setting the classloader property can be found here

    This method should work if your usage of those Java classes are contained to a single package. It wouldn't work if you need to pass objects of those classes between packages, but that should be avoided in any case.







    ------------------------------
    Dave Laycock
    ------------------------------



  • 3.  RE: Conflict with commons lib

    Posted Tue December 10, 2024 11:37 AM

    In addition what @Dave Laycock has written, there is an additional aspect for this specific scenario (at least as I understand it from the screenshots).

    The problem is the Apache POI XML handling. The underlying XML Beans library does some custom class-loading at runtime. Through a somewhat "unfortunate" approach this effectively uses the version that comes shipped with IS.

    The bottom line is that you cannot use current versions of Apache POI to process XML-based formats (like .xlsx). I had looked at this in early 2024 and found numerous post on Reddit etc. So it is not the fault of webMethods but the weird approach of the XML Beans library.

    If you want to process Excel spreadsheets, you could also have a look at https://github.com/JahnTech/webmethods-is-jt_excel



    ------------------------------
    All the best,
    Christoph
    ------------------------------



  • 4.  RE: Conflict with commons lib

    Posted Tue December 10, 2024 02:06 PM

    If you have a different version of a jar you should place it in code/jars folder of your package. Normally the server's jar files are picked first. That is why you are getting that error. If you want the jars from your package to be picked first, add a line to the manifest.v3 file of your package as below:

    <value name="classloader">package</value>



    ------------------------------
    Rupinder Singh
    CTO, Nibble Technologies
    https://www.nibl.tech/
    ------------------------------