UnknownhostException in client

Posted on 2004-03-22
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 ?
Question by:themuppeteer
  • 9
  • 5
  • 2
  • +1

Author Comment

ID: 10661609
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 :))

Author Comment

ID: 10789562
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..
LVL 13

Expert Comment

ID: 10897989
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.

The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!


Author Comment

ID: 10898430
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 ;).

Author Comment

ID: 10921423
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 ?
LVL 13

Expert Comment

ID: 10921838
Try to run the ping command:

    ping mypc
LVL 13

Expert Comment

ID: 10921883
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.


Author Comment

ID: 10925711
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...
LVL 13

Expert Comment

ID: 10931679
>> 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.

Author Comment

ID: 11057712
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,

Author Comment

ID: 11084501
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 )..

Expert Comment

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

Author Comment

ID: 11200849
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,

Expert Comment

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

Author Comment

ID: 11200910
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,

Accepted Solution

Computer101 earned 0 total points
ID: 11518702
PAQed, with points refunded (500)

E-E Admin

Featured Post

Simple Misconfiguration =Network Vulnerability

In this technical webinar, AlgoSec will present several examples of common misconfigurations; including a basic device change, business application connectivity changes, and data center migrations. Learn best practices to protect your business from attack.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
The video provides a quick and easy steps to migrate MBOX file to well known Outlook PST and Office 365. Besides this, it also supports and migrates more than 20 email clients of MBOX which include AppleMail, Opera, Thunderbird and SeaMonkey effortl…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question