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

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)

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.

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.