Executing jar file via Java Snippet Node

Hi,

An example jar command: “java -jar “/home/knime/java/pdf_jar/test.jar” “arguments” “/home/knime/java/out/100229.pdf””

I can run this command via putty on knime-server and i was able to creating pdf files.
Also I am doing same thing using java snippet node on my workflow and its also creating pdf files on my local environment.

this is the simple code:

String process = “java -jar”+ " " +c_jarpath + " " +c_httprequest + " " +c_filepath;
out_javacode = process;
Process exec = Runtime.getRuntime().exec(process);
while (exec.isAlive()) {

        }

I have deployed this workflow to the server and ran it. But somehow it didnt create pdf files. i tried different things to achieve to creating pdf files but i wasnt succesfull whatever i have tried.

Someone may have experienced same issue.

What should i do with using this command and change some settings on server side to create pdf files?

Hi,
what error do you see when executing the workflow on the server? Or did it run through and there were just no PDFs?
Kind regards,
Alexander

Hi Alexander,

thank you for reply.

It doesnt throw any exception. It just doesnt create PDF files on linux side via KNIME GUI or deploying to server and starting from webportal but when you look at the Node it shows green. Every node shows green and java throws no exception. But when i copy process command and paste it on terminal in linux, it creates PDF files.

When i run the same workflow from the KNIME GUI on windows side it justs works fine.

Somehow it is not creating PDF files from Java Snippet node on Linux System.

On code part its connecting to httprequest via login parameters. And downloading files into a directory.

i have also transported codes from jar file to Java Snippet and tried again. Everthing is green but no pdf files :slight_smile:

Thanks
Yasin

Hi,
Maybe your file path does not work on the server for some reason, e.g. because it is a Windows file path or it is relative to the KNIME executable?
Kind regards,
Alexander

Hi Alexander,

I have created an exception while i was trying to execute httprequest through batch file:

Exception in thread “main” java.io.IOException: Server returned HTTP response code: 500 for URL: http://reportserver/ReportServer_?FtestFpdf_folder&rs:Command=Render&pid=100229&rs:Format=PDF
at sun.reflect.GeneratedConstructorAccessor1.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at jcifs.http.NtlmHttpURLConnection.getInputStream(NtlmHttpURLConnection.java:242)

Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://reportserver/ReportServer_?FtestFpdf_folder&rs:Command=Render&pid=100229&rs:Format=PDF
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(Unknown Source)
at jcifs.http.NtlmHttpURLConnection.parseResponseCode(NtlmHttpURLConnection.java:424)
at jcifs.http.NtlmHttpURLConnection.doHandshake(NtlmHttpURLConnection.java:463)
at jcifs.http.NtlmHttpURLConnection.handshake(NtlmHttpURLConnection.java:103)
at jcifs.http.NtlmHttpURLConnection.getInputStream(NtlmHttpURLConnection.java:240)
… 2 more

There is Ntlm authentication while calling httprequest. It is working if i am calling jar command via Knime from windows.

String process = “java -jar”+ " " +c_jarpath + " " +c_httprequest + " " +c_filepath;
out_javacode = process;
Process exec = Runtime.getRuntime().exec(process);
while (exec.isAlive()) {
        }

This code part from jar file which is embedded in code.

        System.setProperty("http.auth.ntlm.domain", "domain");
        System.setProperty("jcifs.smb.client.domain", "domain");
        System.setProperty("jcifs.smb.client.username", "user");
        System.setProperty("jcifs.smb.client.password", "password");
        System.setProperty("jcifs.netbios.hostname", "server");
        System.setProperty("java.protocol.handler.pkgs", "jcifs");

Hi,

Java Snippet calls a jar file which is work without exception on windows environment. On linux system via gui or server it isnot working and throwing no exception. the whole workflow finishes with green.

my solution was creating a schedule on windows server and calling knime.exe via batch file. The batch file itself calls my workflow project.

Kind Regards
Yasin

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.