I am trying to send an image location url using curl script to a restful webservice. The script is working fine when i run it directly on my server unix box. However while trying to fire the script using the sample code - fireCommandExec, i am getting
the below error.
500 internal server error.
We’re sorry but a serious error has occurred in the system.
PFB the java code. However I do not feel the issue is with java code. The same code was tried in eclipse, and the script was run without any issue.
Process child = Runtime.getRuntime().exec(command);
// read stdout; required to keep this process from becoming a zombie
InputStream stdout = child.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stdout));
int siz = 1024;
char[] buff = new char[siz];
int r = 0;
StringBuffer sbf = new StringBuffer();
while ( ( r = reader.read(buff, 0, siz) ) > 0 )
{
sbf.append(buff, 0, r);
}
stdoutText = sbf.toString();
// read stderr; required to keep this process from becoming a zombie
InputStream stderr = child.getErrorStream();
reader = new BufferedReader(new InputStreamReader(stderr));
StringBuffer sbf2 = new StringBuffer();
while ( ( r = reader.read(buff, 0, siz) ) > 0 )
{
sbf2.append(buff, 0, r);
}
stderrText = sbf2.toString();
child.waitFor(); // IllegalThreadStateException, if w/o wait & child not terminated
status = child.exitValue();
Is the target RESTful web service implemented by Jive REST API? It looks like a server side error, your java code is ok, you’d better confirm this with web service provider.
Yes, the target is a jive REST API. However what confuses me is that, when i try to run the same curl script from my server unix box i get success response.
There is something different between Runtime.exec invoke and directly shell invoke about parse the args.
May be you can try Runtime.getRuntime().exec(new String{“curl”, “-k”, “-i”, “-u”, …}) instead.
Is there anything else i can try? Not sure what is the issue. I checked with the webservice provider, and they have no error logs at their end to help the situation.