• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1403
  • Last Modified:

UnknownhostException in client

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 ?
0
themuppeteer
Asked:
themuppeteer
  • 9
  • 5
  • 2
  • +1
1 Solution
 
themuppeteerAuthor Commented:
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:

JAVA_OPTS=$JAVA_OPTS -Dprogram.name=$PROGNAME
-Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
-Djava.rmi.server.useLocalHostname=false

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 :))
0
 
themuppeteerAuthor Commented:
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..
0
 
WebstormCommented:
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 :
http://maven.apache.org/reference/plugins/jboss/properties.html

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

127.0.0.1 localhost
127.0.0.1 PCXZ

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

0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
themuppeteerAuthor Commented:
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 ;).
0
 
themuppeteerAuthor Commented:
I have put that in the hosts file:

127.0.0.1    localhost
127.0.0.1    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 ?
0
 
WebstormCommented:
Try to run the ping command:

    ping mypc
0
 
WebstormCommented:
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.

0
 
themuppeteerAuthor Commented:
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...
0
 
WebstormCommented:
>> 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 :

http://forum.java.sun.com/thread.jsp?forum=51&thread=497887&tstart=75&trange=15

According to:
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=24eb8515.0403040204.60b107c7%40posting.google.com&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.lang.java.beans

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

just replace 10.129.1.2 by the server ip and mymachinename by mypc

I hope this will work.
0
 
themuppeteerAuthor Commented:
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,
themuppeteer
0
 
themuppeteerAuthor Commented:
Oki,
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 )..
0
 
vzilkaCommented:
I am trying to understand here. The client is getting an IP address from JBoss? Can you post the code that raises the exception?
0
 
themuppeteerAuthor Commented:
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.

http://www.jboss.org/index.html?module=bb&op=viewtopic&t=49763

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. "
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
   "-//JBoss//DTD JBOSS 3.2//EN"
   "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">

<jboss>
   <enterprise-beans>
      <session>
         <ejb-name>HelloWorld</ejb-name>
         <jndi-name>helloworld/Hello</jndi-name>
       <invoker-bindings>
            <invoker>
               <invoker-proxy-binding-name>stateless-http-invoker</invoker-proxy-binding-name>
              <jndi-name>helloworld/HelloHTTP</jndi-name>
            </invoker>
                   </invoker-bindings>
      </session>                  
   </enterprise-beans>

   <invoker-proxy-bindings>      
      <!-- A custom invoker for RMI/HTTP -->
      <invoker-proxy-binding>
         <name>stateless-http-invoker</name>
         <invoker-mbean>jboss:service=invoker,type=http</invoker-mbean>
         <proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
         <proxy-factory-config>
            <client-interceptors>
               <home>
                  <interceptor>org.jboss.proxy.ejb.HomeInterceptor</interceptor>
                  <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
                  <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
                  <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
               </home>
               <bean>
                  <interceptor>org.jboss.proxy.ejb.StatelessSessionInterceptor</interceptor>
                  <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
                  <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
                  <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
               </bean>
            </client-interceptors>
         </proxy-factory-config>
      </invoker-proxy-binding>            
   </invoker-proxy-bindings>
</jboss>      



(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,
themuppeteer
0
 
vzilkaCommented:
Congratulations ;-)
Sorry for not taking a part in this, I saw a discussion and didn't want to get in the middle of things...
 
0
 
themuppeteerAuthor Commented:
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,
themuppeteer
0
 
Computer101Commented:
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 9
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now