This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Testing my RMI BusinessLogic with more than 200 Threads

 
Sophie Siegel
Greenhorn
Posts: 9
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

I'm testing my RMI business logic with threads.
Under about 200 Threads everything is fine... but with more than 200 Threads I've got the following exception:

java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at

Can somebody help me please?

Thank you very much!
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Sophie. Welcome to JavaRanch!

Well, it will be hard to say something without some details. How are your tests? Are you using Roel's test cases? Can you show us your testing code?
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sophie,

I googled a bit and noticed it could be something OS-related. Which OS are you using?

I noticed your 1st post was in August 2011, so are you aware of the changed mandatory requirements of this certification (you must follow a mandatory course in order to complete this certification)?

Kind regards,
Roel
 
Sophie Siegel
Greenhorn
Posts: 9
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

thank you for answering so fast !

I got the problem with Roel's testingClass and with my own test.
My own test class is a little similar like Roel's.
I start my RMI-Server in main and in the method 'startTests' I only start the threads in a for-loop:


I don't have this like Roel's test:



My booking thread for example then get the remoteModel with Naming.lookup and call my book-Method.

It is a little bit strange that the exception is coming soon.
My OS is Windows XP. Like Roel's link it seems to be a problem with Windows. But what can I do now?

Roel, thank you for remembering for the mandatory course. I've visited a course but I nearly forgot that I have to fill in a course submission form .

Best regards,
Sophie
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sophie,

I didn't use Naming.lookup but used Registry.lookup to get a stub (also used similar code for registering my server) as described in this Oracle tutorial. Maybe you can give this code a try and see what happens...

Hope it helps!
Kind regards,
Roel

 
Sophie Siegel
Greenhorn
Posts: 9
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

first I have this:



And now I tried rebinding the client with this:



The Start-Method on server side in class UrlyBirdRemoteModelImpl:




My structure is like this one:




I have the problems most of the times and sometimes the test runs without this ConnectException.
My internet connection is not always good. Can this perhaps be the problem? Or do you only get ConnectIOException if the connection to internet is bad?

I'm slowly running out of ideas and I must upload the assignment soon....
Doesn't anybody have the same problem?

Regards,
Sophie
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have same issue if you run both client and server on same computer, using localhost or 127.0.0.1 as the server address?
 
Sophie Siegel
Greenhorn
Posts: 9
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

I run both on the same computer and try it with localhost, 127.0.0.1 and the ipAddress I got from "ipconfig".

If I start so:


Most times I got the ConnectException.

But when I start without port I got ConnectionException and sometimes this exception:

java.rmi.NoSuchObjectException: no such object in table
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

But starting with port is the correct way for the assignment I think.

Roel, what operating system do you use?

Thanks,
Sophie
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Sophie.

You know, some time ago, I think I remember a guy saying that he was with this same problem. The thing is, I don't really think you have a problem. I myself didn't test my application with not even more than one client in the same LAN. All I did was, I started the server in one machine and started the client in another machine, pointing to the server. I didn't have any problems. So I don't think you have to worry about it.

Oh, and by the way, I too had LocateRegistry.getRegistry instead of Naming.lookup.
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sophie Siegel wrote:But starting with port is the correct way for the assignment I think.

Yes! It should be the port number the user provides when he enters the configuration settings of the server and/or network client

Sophie Siegel wrote:what operating system do you use?

I was using a WinXP computer.

Like Roberto I also tested my network solution on 1 other pc in my network (also a WinXP machine). When those 2 could successfully communicate with each other, I marked the RMI part as finished
 
Sophie Siegel
Greenhorn
Posts: 9
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo both,

you made me be relieved

I hope I don't have a very strict tester!
I tried still one test to be a little bit saver that my application is okay.
I have two laptops... on my laptop with Windows 7 I started my server like normaly starting the server and on the laptop with Windows XP I started the client with the testclass (the testclass now starts only the 500 clients) and now I get another ConnectException:

java.rmi.ConnectException: Connection refused to host: 192.168.178.34; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at test.TestBusinessServiceBooking$SearchThread.run(TestBusinessServiceBooking.java:209)


and sometimes also:


java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
java.net.SocketException: Connection reset
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at test.TestBusinessServiceBooking$SearchThread.run(TestBusinessServiceBooking.java:209)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readByte(Unknown Source)
... 5 more

If I tried it another way round ... so that server is my Windows XP machine and the clients are started from my Windows 7 machine I also get the "connection timed out"-exception and again the old exception:

java.rmi.ConnectException: Connection refused to host: 192.168.178.22; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at test.TestBusinessServiceBooking$SearchThread.run(TestBusinessServiceBooking.java:209)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 6 more

But this both should work I thought because they don't run on same computer only in the same WLAN.

Best Regards,
Sophie
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am aware of similar issues when using 2 different machines, but Linux was always one of them (some issues about the hosts file). Never heard about something similar with Windows machines, but no harm having a look how it was solved on a Linux (more info here and here). In the 2nd link you'll find this post where somebody says he has seen it also on Windows machines if more than 1 IP is configured, so I would certainly investigate into that one.

And because we are getting out of options: i hope it's not a firewall issue and they are turned off when trying to run the program

Hope it helps!
Good luck!
 
Sophie Siegel
Greenhorn
Posts: 9
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Roel, hello Roberto,

I turned my firewall off on both computers.

Roel, I understand the links you sent that I have to change the hostfile of the computer which starts the server to:
<my real ip address> <my computer name>

I tested again with one computer starts the server and the other computer starts the many clients, I still got a ConnectException.
Before changing the hostfile I also sometimes saw SocketException and SocketTimeOutException.

But one client and one server on different machines runs perfect.

I slowly think that I can ignore this problem. Do you both also think so?

Another question.... my assignment says:
You must not require the use of an HTTP server.

How can I find out that my application doesn't need an HTTP server?

Thanks a lot!

Bye,
Sophie
 
Roel De Nijs
Sheriff
Posts: 10594
143
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sophie Siegel wrote:Do you both also think so?

If one client and one server on different machines runs perfectly, I don't think you have to worry about it and just ignore it. I myself just did no more testing than running 1 network server and a few (2-3) network clients on 2 different machines in the same network.

Sophie Siegel wrote:How can I find out that my application doesn't need an HTTP server?

As long as you don't need to start an HTTP server (like Apache I guess) prior to get your application to work correctly you also don't have to worry about that one. In my eyes that's one of the easiest requirements in the assignment to meet

Good luck!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic