• Post Reply Bookmark Topic Watch Topic
  • New Topic

UnknownHostException when running in exec  RSS feed

 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Am running a Java application from another Java application using the Runtime.exec(). It loads and runs just fine, but throws an UnknownHostException when run from exec. Works fine directly from command line. The stack trace: java.net.UnknownHostException: BW5524: BW5524

at java.net.InetAddress.getLocalHost(InetAddress.java:1191)

at org.apache.axis.utils.SessionUtils.getEntropy(SessionUtils.java:214)

at org.apache.axis.utils.SessionUtils.getRandom(SessionUtils.java:191)

BW5524 is the network name of my workstation. The code throwing this is apache axis.
Any ideas mucho appreciado...
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There used to be a problem under old, old versions of Windows wherein if you used the version of Runtime.exec() that replaces the environment variables, executed processes wouldn't have the needed environment variables to load the Winsock library (back when TCP/IP wasn't really integrated with the OS.) NT4 had this problem, I believe, and Win95 too. This could be a symptom of that if you're using an old JVM and/or a crusty old OS. Are you?
 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using 1.4.2_03 JDK, and ensured my JAVA_HOME environment variable is set to the install dir of this JDK. OS is Win2K version 5.

Thanks for this and any further info....
 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further, just to confirm, wrote a toy program as follows, which also throws UnknownHostException:

import java.net.InetAddress;
import java.net.UnknownHostException;
public class Test1
{
public static void main (String [] argv) {
InetAddress localHost=null;
try {
localHost = java.net.InetAddress.getLocalHost();
}
catch (UnknownHostException ex) {
if (localHost == null) {
System.out.println ("localHost is null");
}
System.out.println("Exception: " + ex.getMessage());
System.exit(-1);
}
System.out.println("localHost = " + localHost.getHostName());
}
public Test1()
{
}
}

RESULT:
.localHost is null

Exception: java.net.UnknownHostException: BW5524: BW5524



Time: 0.37



OK (1 tests)
 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just as an FYI, this problem is solved when you supply a SecurityManager to the JVM you are exec'ing - -Djava.security.manager -java.security.policy=k:/security.policy . The policy file will need to grant appropriate security to the app...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!