Solved

UnknownhostException in client

Posted on 2004-03-22
18
1,359 Views
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 ?
0
Comment
Question by:themuppeteer
  • 9
  • 5
  • 2
  • +1
18 Comments
 
LVL 2

Author Comment

by:themuppeteer
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:

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
 
LVL 2

Author Comment

by:themuppeteer
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..
0
 
LVL 13

Expert Comment

by:Webstorm
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 :
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
 
LVL 2

Author Comment

by:themuppeteer
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 ;).
0
 
LVL 2

Author Comment

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

Expert Comment

by:Webstorm
ID: 10921838
Try to run the ping command:

    ping mypc
0
 
LVL 13

Expert Comment

by:Webstorm
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.

0
 
LVL 2

Author Comment

by:themuppeteer
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...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:Webstorm
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 :

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
 
LVL 13

Expert Comment

by:Webstorm
ID: 10931772
0
 
LVL 2

Author Comment

by:themuppeteer
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,
themuppeteer
0
 
LVL 2

Author Comment

by:themuppeteer
ID: 11084501
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
 
LVL 9

Expert Comment

by:vzilka
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?
0
 
LVL 2

Author Comment

by:themuppeteer
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.

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
 
LVL 9

Expert Comment

by:vzilka
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...
 
0
 
LVL 2

Author Comment

by:themuppeteer
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,
themuppeteer
0
 
LVL 1

Accepted Solution

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

Computer101
E-E Admin
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now