We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


UnknownhostException in client

themuppeteer asked
Medium Priority
Last Modified: 2007-12-19
Hello guys,

I'm working on this ne for a while now,
I'm making a game with an application client and a Jboss server.
I want my client to connect to my jboss application server over the internet.
Localhost everything works fine.
I finally got my client on http with the help of vzilka (to pass firewalls over the internet),
then I got a log4j error for some reason but managed to solve it partially by outing
the log4j.jar in the same directory as my jar.
Now I got another exception in the client so I still can not connect:
The client gets the ip from my server and manages to resolve the name of my server but further than that it does not get.

log4j:WARN No appenders could be found for logger (org.jboss.invocation.http.interfaces.Util).
log4j:WARN Please initialize the log4j system properly.
javax.naming.CommunicationException: Operation failed.  Root exception is java.net.UnknownHostException: PCXZ
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:143)
      at java.net.Socket.connect(Socket.java:425)
      at java.net.Socket.connect(Socket.java:375)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:366)

The log4j thing would be nice to have it solved but the worst problem is the unknowhostexception.
Can anybody help me ?
Watch Question


Ok, I found something new...

apperantly, the client can get to my pc, it gets the local windows name (PCXZ) and returns with that. then an unknwohostexception occurs because PCXZ means nothing to the client.

I read on the internet that I should adapt run.bat to:


but jboss seems to ignore this line completely!
It still sends PCXZ to the client.

I even put PCXZ in the clients host file so that it would know what to do when it gets that name but no luck.

Then I've put PCXZ in the hosts file of the server hoping that it would somehow translate the name to an ip when I start jboss...foolish me.

Can anyone help me ? (I'll buy you a beer if you do :))


I tried to change my windows name to my ip adres, but I can't put dots in the name from windows..
Just for clarification, PCXZ is the name of my pc at home.

Does really nobody knows this ? (and why is there a limit on 500 points...)
Comon guys..
Top Expert 2004

Hi themuppeteer,

Sorry for the late answer, but i was busy with some other questions.

I found a web site about properties used by JBoss :

For the "hosts" file, it should be in  C:\WINNT\system32\drivers\etc  for Windows 2000, and look like this: localhost PCXZ

You can also try to give another name than "PCXZ" to your computer.


Thanks for the reply Webstorm,

I think I already tried that,

<quote>Then I've put PCXZ in the hosts file of the server hoping that it would somehow translate the name to an ip when I start jboss...foolish me</quote>

 but I'll cross check that again to make sure.
Guess its time take the dust of my application server and see if it still starts ;).


I have put that in the hosts file:    localhost    mypc

and changed the name of my pc from pcxz to mypc
,the client now says:
javax.naming.CommunicationException: Operation failed.  Root exception is java.n
et.UnknownHostException: mypc
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:143)
        at java.net.Socket.connect(Socket.java:425)

Any clues ?
Top Expert 2004

Try to run the ping command:

    ping mypc
Top Expert 2004

If you're using a proxy, you can try to run your application with this command:
    java -Dhttp.proxyHost=<proxyhost> -Dhttp.proxyPort=<proxyport> ...
where <proxyhost> and <proxyport> are your proxy configuration.


I'm not using a proxy,( unless windows xp is doing something behind my back ?)
Just my pc at home with windows xp, I also have zonealarm running but I put that of for the tests (before I start the application server that is).
I already tried to ping, it works on localhost but not  at client side (which is my whole problem).
If only my client would get the ip adres (which is pingable,I've tried), instead of the hostname of my pc, my probem would be solved I think.

I will try the proxy parameters with my ip and port filled in for proxyhost and port anyway, you never know...
Top Expert 2004

>> If only my client would get the ip adres (which is pingable,I've tried), instead of the hostname of my pc
Your client can't see your pc with its computer name unless it's on the same network domain.

You may need an internet server domain name like 'server.mypc.net', or, as you said, your client must use the IP address.

I found some related forums about this kind of problem :


According to:

you need to have a host file like this:        localhost.localdomain        localhost       mymachinename

just replace by the server ip and mymachinename by mypc

I hope this will work.
Top Expert 2004



Hello WebStorm,

First of all sorry it took me so long to reply..
I've been on holiday for a week and very busy at work, so I havn't been able to continue my work on the application much.
I did make a helloWorld Client that loops and tries to connect over and over again and prints all the steps on screen, since I can't keep bothering people to test my client over the internet. The client is almost ready now.
I'll soon come back with more information...
Thnx for hanging on.

Best regards,


my client is finished so now I can do some serious tests.

It still doesnt work , not with the host file, and also not with the usehostname
to false.

Still the windows name is send to the client.

I have also been looking on the jboss site, but they all say the same (useHostName and change hosts file )..

I am trying to understand here. The client is getting an IP address from JBoss? Can you post the code that raises the exception?


Hello vzilka,

The situation was as following: the client knew the ip address of the server, connected, found the home interface but when I did a create, I got an unknownhostexception in the client that mentioned the windows name of my server pc. I use did because since last week, the problem is solved. Apperantly the client must use a so called 'detached http invoker'. I don't know excactely how it works, I just know it works. It is solved on the jboss forum by mr Catalin Kormos
who had exactely the same problem but thought it was because he used jms.


and just to avoid people clicking this link in the future and getting a page not found, I'll post the answer here to, it is the jboss.xml file in your beans meta-inf directory:

(all credit to catalean who gave the solution)

Catalean: "I think You have to enable a HTTP detached invoker on your EJBs. You better search for more information about detached invokers in JBoss. I just found this example, i did't test it yet, but it seems to be the solution for your, and also, for my problem to. You have to modify your jboss.xml descriptor, and for each EJB you want to access over HTTP, specify the http detached invoker. Then you obtain the home interface of an EJB, looking up after the jndi name specified by the invoker binding, "helloworld/HelloHTTP". Hope it helps. "
<?xml version="1.0" encoding="UTF-8"?>
   "-//JBoss//DTD JBOSS 3.2//EN"


      <!-- A custom invoker for RMI/HTTP -->

(There was a small error in his code which catalean fixed in his thread, I posted the correct xml file)

Thanks a lot  all of you guys for hangin in.
I can continue my game now after 4 months of being stuck on this..

Very best regards,

Congratulations ;-)
Sorry for not taking a part in this, I saw a discussion and didn't want to get in the middle of things...


No problem, you've been a great help to me already with the http stuff.
But I think you can always post in the middle of a discussion, the person in trouble (me in this case) will gladly answer both persons in order to get his problem solved. But then again, it might be polite to leave a fare chance for the points to the first one. Wich explains why you joined in after all.

Best regards,
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.