• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UnknownHostException when running in exec

 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic