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

webMethods Integration Server / Designer Application Platform Service / POJO as IS service

  • 1.  webMethods Integration Server / Designer Application Platform Service / POJO as IS service

    Posted Fri February 09, 2018 06:50 AM

    Hello,

    we are using Integration Server 10.1. We created POJO’s as Java services (exposed via Application Platform in Designer). Everything was working fine. But know we wanted to change these IS POJO services into simple Java Services. The reason for this is that we are using Deployer for deployment and don’t want to expose services during deployment process. The problem is that the referring downloaded .jar package contains a .txt file for configuration. When we try to execute the Java Service we get the following exception:

    com.wm.app.b2b.server.ServiceException: java.lang.IllegalStateException: Cant find resources/grib2/standardTableMap.txt

    However, the jar file is in the directory <package>\code\jarsfile and contains the config file in the given subdirectory.

    This problem only occurs when using simple java services and not the exposed services.

    We created a simple example:

    [/package dummy;

    import java.io.IOException;
    import java.net.URISyntaxException;
    import java.net.URL;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    import java.util.Calendar;

    public class Dummy {

            private URL url;
    
    public String getMessage() throws URISyntaxException, IOException {
    
    if(this.url == null){
    this.url = this.getClass().getResource("/static/dummy.txt");
    }
    
    Path path = Paths.get(this.url.toURI());
    return new String(Files.readAllBytes(path));
    
    }
    
    public String getFilename(){
    
    if(this.url == null){
    this.url = this.getClass().getResource("/static/dummy.txt");
    }
    return this.url.getFile();
    }
    
    public String getPath(){
    
    if(this.url == null){
    this.url = this.getClass().getResource("/static/dummy.txt");
    }
    return this.url.getPath();
    }
    
    public String getTime(){
    
    return Calendar.getInstance().getTime().toString();
    }
    

    }
    ]

    Building a jar and using this in java service leads to the following output of:

    file:/C:/SoftwareAG/IntegrationServer/instances/default/packages/_TestPackage/code/jars/dummy-0.0.1-SNAPSHOT.jar!/static/dummy.txt

    Thus, the path seems to be generated incorrectly.
    How can we solve the problem?

    Except for this problem, is there a possibility to easily deploy packages which are based on exposed POJO services using Deployer?

    Thank you very much in advance.

    dummy-0.0.1-SNAPSHOT.jar.zip (2.38 KB)


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


  • 2.  RE: webMethods Integration Server / Designer Application Platform Service / POJO as IS service

    Posted Sat February 10, 2018 05:57 AM

    I think everything worked fine here. You just have to read the file not via Files.readAllBytes (since what you want to read is not a file) but using URL.openConnection etc.


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


  • 3.  RE: webMethods Integration Server / Designer Application Platform Service / POJO as IS service

    Posted Mon February 12, 2018 04:51 AM

    Thank you for your quick reply.
    The problem is that since we do not have the source code, the .jar we use (ucar.nc2) is fix. This package uses method .getResourceAsStream(static-path).
    (see http://grepcode.com/file/repo1.maven.org/maven2/edu.ucar/grib/4.5.4/ucar/nc2/grib/grib2/table/Grib2Table.java line 62).

    Just the following short example as in ucar.nc2 .jar:

    private URL url;
    static public String filename = “/static/dummy.txt”;

    public String getFile() {
    
    ClassLoader cl = Dummy.class.getClassLoader();
    
    try (InputStream is = cl.getResourceAsStream(filename)) {
    if (is == null) throw new IllegalStateException("Cant find " + filename);
    }catch (IOException e) {
    e.printStackTrace();
    }
    if (this.url == null) {
    this.url = this.getClass().getResource("/static/dummy.txt");
    }
    return this.url.getFile();
    }
    

    }

    with

    import dummy.Dummy;
    public final class test_SVC

    {
    public static final void testPath(IData pipeline) throws ServiceException {
    IDataMap idm = new IDataMap(pipeline);
    Dummy dummy = new Dummy();
    String result = dummy.getFile();
    idm.put(“result”, result);
    }

    in Designer leads to exception:
    Could not run ‘test’
    java.lang.IllegalStateException: Cant find /static/dummy.txt when using dummy as.jar
    like
    However, we cannot change the underlying code of the ucar.nc2 .jar package.


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