Java RMI registry can't find server object - java

So, the problem is I have some server code that will allow a Client to call functions on it using rmiregistry. It should be noted I'm running these commands on OS X terminal and I have two folders I'm working within:
RMI - which will call the rmiregistry and
Server - which has all my server code in it
So, I open one terminal and enter this:
rmiregistry -J-Djava.rmi.server.codebase=file:/Desktop/RMI/Server/ &
All is well, I get a port back.
I then login to the Server folder that contains my server code to run my calculatorserver program.
Now I've been told to specify the codebase and the security policy:
java -Djava.rmi.server.codebase=file:/Desktop/RMI/Server/ -Djava.security.policy=server.policy calculatorserver
However, I keep on getting this same error:
Server Error: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: calculator
I know the only reason I'm getting this error is because the rmiregistry can't find the server object.
Some guidance would be appreciated

That's not a real HTTP URL. It's a directory name with http: stuck in front of it. You need to use a real http: URL with a real HTTP server. Or FTP.
You can use a file: URL, but then you're more or less stuck within a single host, in which case you don't actually need the codebase feature at all. And if you do use a file: URL, it has to be intelligible to the Registry and the client, which again means either they're all in the same host or it names a shared directory that the Registry and client can see.
NB Don't specify the codebase to the Registry (or the client, unless it exports remote (callback) objects): only to the server JVM

Related

Start jmeter distributed testing from clouds

I want to run distributed load testing by jmeter, where servers(linux) are in the cloud and I have ability to start test from my local pc.
Is it even possible or client and servers should be in same subnet?
And in case its possible, may you provide me step by step guide how to achive this goal?
I have tired
https://jmeter.apache.org/usermanual/remote-test.html
https://cloud.google.com/community/tutorials/ssh-port-forwarding-set-up-load-testing-on-compute-engine?hl=ja
but I got error after error.
Before I disabled ssl verification, next error appeared:
error during JRMP connection establishment; nested exception is:
javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
With disabled ssl verification I have next error:
Error in rconfigure() method java.rmi.MarshalException: error marshalling argume
nts; nested exception is:
java.net.SocketException: Connection reset by peer: socket write error
I have feeligs, like I making smth wrong with setting ip, port or firewall, but cant understand what
It is definitely possible to starts load agents (jmeter-server) from your local system. The only condition is that the traffic should not be blocked by firewall.
Based on your error, it looks like jmeter process is not having permission to open a port, port is already open (although there is a specific exception for this)
You can also try allowing all incoming traffic to your slaves (cloud linux boxes) and try running the test again.
According to the manual you mentioned all you need to do is just to take the following steps:
On your local machine set up the SSH tunnel:
ssh -L 24000:127.0.0.1:24000 -R 25000:127.0.0.1:25000 -L 26000:127.0.0.1:26000 username#hostname_of_cloud_machine
On the cloud machine launch the JMeter slave
./jmeter -s -Jserver.rmi.ssl.disable=true -Jserver_port=24000 -Jserver.rmi.localhostname=127.0.0.1 -Jserver.rmi.localport=26000 -j jmeter.log
Again on the local machine launch the JMeter master:
./jmeter -Jserver.rmi.ssl.disable=true -Jremote_hosts=127.0.0.1:24000 -Jclient.rmi.localport=25000 -Jmode=Statistical -n -t test.jmx -l result.jtl
You don't need to configure any firewalls as all the communication is happening over the SSH tunnel
More information:
Remote hosts and RMI configuration
Apache JMeter Properties Customization Guide

How to connect to a Grakn Server running on a GCP VM instance

I'm trying to connect to a Grakn Server running on a GCP VM instance. I have read the related post in the discussion forum. One of the replies suggests to do the following on the server side:
Edit ./conf/main/grakn.properties:
storage.hostname=EXTERNAL.ip.v4.address
Edit ./conf/cassandra/cassandra.yaml:
seeds: "EXTERNAL.ip.v4.address"
broadcast_address: EXTERNAL.ip.v4.address
listen_address: INTERNAL.ip.v4.address
rpc_address: INTERNAL.ip.v4.address
Access it from the Java API:
GraknSession session = Grakn.session(“EXTERNAL.ip.v4.address”, keySpaceName);
What i have interpreted from this, for my specific case, is the following:
-Replace EXTERNAL.ip.v4.address with the External IP of my VM instance
-Replace INTERNAL.ip.v4.address with the Internal IP of my VM instance
When i start the server i get this exception cause (I think this is the root cause):
Caused by:
com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException:
PoolTimeoutException: [host=104.197.131.17(104.197.131.17):9160,
latency=10000(10000), attempts=1]Timed out waiting for connection
at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:231)
What am i missing?
Do i have to add firewall rules?
Thanks for the help.
To access Grakn remotely using the Java API, you need to open the following ports on the GCP and Linux VM firewall (eg. iptables):
4567
9160
Make sure you are able to access those from the client machine.

How to find weblogic t3 adminurl

I have a weblogic folder, From this - How can i find the adminurl that I can use with the below command
java weblogic.Deployer –adminurl t3://server:7001 –username system –password weblogic –listapps
I tried looking into setupinfo.txt, portlist.ini - but somehow this did not help/work. How can get this working?
I get errors/exceptions like these (after few attempts)
The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object
Unable to connect to 'http://server:7001': Destination unreachable; java.net.ConnectException: Tried all: 1 addresses, but could not connect over HTTPS to server: localhost port: 7102; No available router to destination
based on setupinfo.txt, I am able to login to the web console - but I need to know how to get this command working with adminurl !!!
Thanks,
Got it, thanks Alex.
Steps
Find startscript.xml under your weblogic domain , search this file for "ADMIN_URL"
The same can be done by web console UI ..... Admin Console Login to AdminConsole->Server->Configuration->ListenPort (enable and note down the port)
Bingo.

java.rmi.ConnectException: Connection refused to host and java.rmi.UnmarshalException: Error unmarshaling return header;

I've been learning about RMI and I started with the Hello World program, which I got to work, and then began using other sample programs which all worked. (well there were errors, but I debugged them with the help of google/stackoverflow). and now I began writing my own project, which is basically a Traveling Salesman implementation that offloads the intense computation to a server.
Everything was working fine, when suddenly all my server RMI implementations broke. ie. when I run computeEngine from Eclipse as an RMI application (I use the RMI plugin), I get either the error:
java.rmi.ConnectException: Connection refused to host
or the error:
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is: java.io.EOFException
I have 4-5 different RMI applications that were all working and then all of a sudden the "ComputeEngine.java" file which I run on the server started returning one of these 2 errors for every single one of my applications.
Note: since I am testing these applications, I use "localhost" as my server hostname. In otherwords, the server and the client are the same machine.
Things I have tried:
I have checked my etc/hosts/ file and found that 127.0.0.1 is set as localhost. I also created a new machine entitled "virtualmachine" and used my public IP address. Both did not work.
I have double and triple checked my server.policy and client.policy files, and both seem to be fine.
I have tried running the RMI application from terminal (instead of using the RMI plugin from eclipse) and I get the same errors
I quit all java processes and reran everything making sure I started the server first (other threads suggested that these errors come from running the client first)
I've portscanned myself and port 1099 (the default rmi port) says "LISTEN" when I run my server (even though the server is returning an exception).
I've tried changing java.rmi.server.hostname, but nothing has seemed to help so far.
I'm not understanding how I'm not getting connection to host when I am running both the server and client on the same computer.
I preemptively apologize from being sucky at RMI and Java and missing some likely obvious solution.
Should I include any source code from what I have been trying to run?
EDIT: Here is the stack trace:
ComputeEngine exception:
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:227)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:33)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(DataInputStream.java:267)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:213)
... 3 more
Thank You!
EDIT 2:
I noticed that if I restarted the RMIregistry when I started the application (as in, I selected the option in the Eclipse RMI plugin that restarted the rmiregistry) I would get a ClassNotFoundError for a class that is in my 'codebase.jar'.
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: compute.Compute
Any ideas?

java.rmi.UnmarshalException: unable to pull client classes by server

I have an RMI client/server set-up on two machines that works fine in a simple situation when the server doesn't require a client-side defned class. However, when I need to use a class defined on the client side I am unable to have the server unmarshall those classes. I suspect this is an issue with my java.rmi.server.codebase property that I pass in as argument to the client app. I followed Sun's RMI Tutorial trail and I think I have followed the steps exactly except that I don't specify a classpath argument when executing client and server because they execute in the directory right above the root package directory (however I tried that too with no effect).
The exceptions I get when attempting to execute the different client-side combinations described in detail below are all the same:
RmiServer exception:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: test.MyTask
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:353)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:553)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy0.execute(Unknown Source)
at test.myClient.main(myClient.java:32)
The details are:
My client/server rmi is set up over a home network behind a router. The router is assigned to a static ip address I will call myhostname. Appropriate port-mapping is set-up in the router that points to the right machines.
role, machine, os, ip-address:
server, venice, linux ubuntu 9.10, 10.0.1.2
client, naples, mac os x leopard, 10.0.1.4
I startup the server side as follows inside /home/andrews/workspace/epsilon/bin:
1 starting registry on the default port 1099:
venice% rmiregistry &
2 starting web-server on port 2001 pointing to code base for common interfaces:
venice% java webserver/ClassFileServer 2001 /home/andrew/workspace/epsilon/bin
3 starting server app (main class in test/myServer) which registers the server object:
venice% java -Djava.rmi.server.codebase="http://myhostname:2001/" -Djava.security.policy=server.policy -Djava.rmi.server.hostname=myhostname test/myServer &
Now the client side inside /Users/andrews/Development/Java/workspace/epsilon/bin:
1 start a local web server that can server client-side classes to the server (not sure if this is needed, but I added I tried it, and still no success; I have added port-mapping to the router for 2001 to venice, for 2002 to naples)
naples$ java webserver/ClassFileServer 2002 /Users/andrews/Development/Java/workspace/epsilon/bin/
Trying to run the client (note: I don't specify the -cp argument because client executes right above the root package directory):
1 try #1 using an http hostname
naples$ java -Djava.rmi.server.codebase=http://10.0.1.4:2002/ -Djava.security.policy=client.policy test.myClient myhostname
Note 1: the myhostname argument at the end is passed-in to the client so that it resolves to server's rmi hostname.
Note 2: I tried using localhost:2002 instead of 10.0.1.4:2002 too.
Note 3: I tried using myhostname:2002 since myhostname is assigned to the router and I have proper port-mapping set-up, this address should resolve to naples and not venice
2 try #2:
naples$ java -Djava.rmi.server.codebase=file:/Users/andrews/Development/Java/workspace/epsilon/bin/ -Djava.security.policy=client.policy test.myClient myhostname
Note 1: the code base url format is correct, I created a small program to convert current file directory path into a url and used that. using file:///Users... has same effect.
Other notes:
1 my server and client policy files correctly specify the path, as I've tested this setup with good and bad paths, and getting a security exception for bad path
2 this setup works if I don't use client-side defined objects, the client connects correctly to the server and the server executes.
3 when I place the client-side class on the server in the server's classpath, all executes fine.
All help is appreciated.
Do you really need to use RMI? Me and a friend tried it once in school and it was way slow, much slower then the simple ObjectOutputStream networking we had been doing earlier.
I strong agree with Chad Okere's said, RMI is really very slow and consuming-resouces. sometimes directly use Sockets maybe is simple and useful chooice, regarding your exception Could you confirm your rmi server work correctly? http://www.javarmi.com/2010/05/java-rmi-error-unmarshalling-arguments/ maybe be can help you

Categories