JAVA RMI Client - java

I have the problem that my RMI Application Client isn't working when i hit the "run" Button in Eclipse. It throws the following exception:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.net.MalformedURLException: unknown protocol: rsrc
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
...
I looked on the internet and people seem to have that problem when generating JARs from eclipse. But my (ant-built) jars work fine, just inside Eclipse it's not doing as it should!
InterfaceRemota objetoRemoto = (InterfaceRemota)Naming.lookup("//localhost:1097/ObjetoRemoto");

I found a solution, before starting the rmiregistry server I have to clean the java classpath using "set CLASSPATH="
c: > set CLASSPATH=
c: > rmiregistry

Related

How to solve the "Unable to update binding" error in SONAR LINT?

Scenario :
Recently I have installed SONAR lint v3.4 on Eclipse Oxygen.2 Release (4.7.2
I have SONAR qube server running and I was successfully able to connect SONAR lint to it.
Problem :
However after the connection when I try to take updates from the SONARQUBE server.
Eclipse throws the following error :
Failed to update binding for 1 project,
Unable to update binding for
project 'xyz-project'
Unable to move
C:\Users\vsinghal\eclipse-workspace\.sonarlint\work{SONARQUBE server
domain}\.sonartmp_7415526389500015248\8960528228988360636
to
C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage{SONARQUBE
server domain}\modules\xyz-project
I checked the error log, following is the trace in eclipse :
java.lang.IllegalStateException: C:\Users\vsinghal\eclipse-workspace\.sonarlint\work\{SONARQUBE server domain name}\.sonartmp_7415526389500015248\8960528228988360636 to C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage\{SONARQUBE server domain name}\modules\xyz-project
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDir(FileUtils.java:47)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.replaceDir(FileUtils.java:153)
at org.sonarsource.sonarlint.core.container.connected.update.perform.ModuleStorageUpdateExecutor.update(ModuleStorageUpdateExecutor.java:63)
at org.sonarsource.sonarlint.core.container.connected.ConnectedContainer.updateModule(ConnectedContainer.java:118)
at org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl.updateModule(ConnectedSonarLintEngineImpl.java:260)
at org.sonarlint.eclipse.core.internal.server.Server.updateProjectStorage(Server.java:338)
at org.sonarlint.eclipse.core.internal.jobs.ServerUpdateJob.run(ServerUpdateJob.java:66)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: java.nio.file.AccessDeniedException: C:\Users\vsinghal\eclipse-workspace\.sonarlint\work\{SONARQUBE server domain name}\.sonartmp_7415526389500015248\8960528228988360636 to C:\Users\vsinghal\eclipse-workspace\.sonarlint\storage\{SONARQUBE server domain name}\modules\xyz-project
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileCopy.move(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.move(Unknown Source)
at java.nio.file.Files.move(Unknown Source)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDirPreferAtomic(FileUtils.java:53)
at org.sonarsource.sonarlint.core.client.api.util.FileUtils.moveDir(FileUtils.java:45)
... 7 more
What did I do try and solve it ?
I gave complete permissions/full control to Everyone for the
eclipse workspace folder in windows explorer .
I tried opening eclipse as admin
I have checked the SONAR server is accessible
but after all these steps the error still doesn't go.
Can anyone help me in finding a solution to this ?
I'm currently experiencing the same issue using SolarLint in both eclipse and Intellij.
There is a reasonable suggestion on google groups, https://groups.google.com/forum/#!topic/sonarlint/nQW1kJBjUYg which suggests that the cause could by a virus scanner interfering in the process. However thus far despite following that theory, I'm still experiencing the issue. Something to try though.

Rmi Client cant find Server stub

I have a server project and a client inside it . Server runs fine . Client inside server project runs fine too . But when i create another Client project ,with the interface inside but not the server ofc, i compile it and when i try to run it i get this error . i have read a lot of stuff but nothing works yet, i tried security manager to client , i tried a lot of thinks actually and i keep getting this error, I read also that i need to start a new rmi registry for clients project i tried that to but i can't open a new one
error:
run:
Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: RMIServer03_Stub (no security manager: RMI class loader disabled)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
at Client.<init>(Client.java:65)
at Client.main(Client.java:141)
Caused by: java.lang.ClassNotFoundException: RMIServer03_Stub (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:396)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:186)
at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:637)
at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:264)
at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:219)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373)
... 4 more
C:\Users\blue-icon\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second)
All you have to to is generate the stub clas with rmic and deploy it to the client.
This is mentioned in every worthwhile RMI tutorial. Rather surprising that you didn't encounter it.

How to run the rmiregistry and rmi server with the right parameters?

How to run the rmiregistry and RMI server with the right parameters on the remote host?
Got this problem when running the RMI client:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.net.MalformedURLException: unknown protocol: c
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.labros.client.TestClient.main(TestClient.java:33)
Caused by: java.net.MalformedURLException: unknown protocol: c
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
I started the rmiregistry on the remote host with the following:
rmiregistry -J-Djava.rmi.server.codebase=file:///export/home/timsadm/Projects/rmi-server/cla‌​sses -J-Djava.security.policy=/export/home/timsadm/Projects/rmi-server/classes/java.p‌​olicy &
and the server with
java -Djava.rmi.server.codebase=file:///export/home/timsadm/Projects/rmi-server/class‌​es -Djava.security.policy=/export/home/timsadm/Projects/rmi-server/classes/java.pol‌​icy com.labros.server.Server
Server started
java -Djava.rmi.server.codebase=file:///export/home/timsadm/Projects/rmi-server/class‌​es
and
java.net.MalformedURLException: unknown protocol: c
These are mutually contradictory. I suspect your codebase parameter really looks like this:
-Djava.rmi.server.codebase=c:/export/home/timsadm/Projects/rmi-server/class‌​es
which isn't a valid URL.
But why are you using the codebase feature at all? A file: codebase URL only works within a single host, in which case you don't need the codebase feature at all, or if it specifies a shared filesystem from the point of view of the Registry and the client, which this one doesn't appear to do. Normally codebase URLs are http: or ftp:, and they refer to a JAR file.

java rmi call failure across different jvm versions

I have existing rmi server running with jvm 1.5 and client running in jvm 1.6 communicating with no issues.
However, when i run (server under JVM 1.7/ client jvm1.7) OR (server under JVM 1.7/ client jvm 1.6)getting following error -
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.tmobile.kiosk.simulator.Kiosk.<init>(Unknown Source)
at com.tmobile.kiosk.simulator.Kiosk.main(Unknown Source)
Caused by: java.io.EOFException
at java.io.DataInputStream.readByte(Unknown Source)
With (Server jvm 1.5/ client jvm 1.7) getting following error -
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: com.xxx.yyy.zzzserver.ZZZServerFactoryImpl_Stub (no security manager: RMI class loader disabled)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
Is this happening due to RMI changes across Java versions?
Can i run rmi Server in JVM 1.7 without any code changes so that existing clients (jvm 1.5 etc) can connect to it.
We are not rebuilding the jar file which was built probably using java 1.4 or 1.5.
Thanks in Advance
Problem was some old jar versions being part of classpath.

running rmi server, classnotfound [duplicate]

This question already has answers here:
java.rmi.ServerException: RemoteException occurred in server thread (ClassNotFoundException)
(5 answers)
Closed 6 years ago.
Hi I'm trying to run a java application that binds a class to the naming server, but i constantly get a ClassNotFoundException
First I start the registry:
rmiregistry
then from eclipse I try to execute the server but get this error
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
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:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at progInternet2008.Pozzobon.tesi.Slave.main(Slave.java:54)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: progInternet2008.commons.NominabileFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:711)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:655)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:592)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
... 12 more
I've read the RMI Java tutorial but still could not get it working...
As VM Arguments I've set this:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008
please help me
(I'm using Java 6)
Run the rmiregisrty command from your /bin, /build, or /build/classes folder, whichever folder is the root of your built files.
I spent half a day trying to solve that same thing.
The exception is occurring because the rmiregistry application doesn't know where to load classes from. When you attempt to bind an object in the RMI registry, the registry downloads the class definition for that object. Some of the other answers are telling you to get around this by setting the classpath for the rmiregistry app so that it has the class definitions when it is started and doesn't need to download anything, but Sun's Java RMI tutorial explicitly says not to do this. I suspect this has the potential to cause conflicts between the version of the class in the registry and the class on the server.
The correct way to handle the problem is to set the java.rmi.server.codebase property as you were trying to do. The property requires that a directory path be terminated with a forward slash, like so:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/
You may also be having trouble if the ${workspace_loc} variable is a relative path and the rmiregistry application was not started in the same directory so the relative path is not correct for it. If you either make the path absolute, or start the rmiregistry in the appropriate directory, the ClassNotFoundException should go away. See the tutorial on the java.rmi.server.codebase property for a little more detailed information.
Okay I just overcame this problem. Make sure when you run rmiregistry that your CLASSPATH environment variable is set.
For example, you might have a script:
set CLASSPATH=[path to jdbc driver].jar
rmiregistry.exe
This was all I needed to get my lost classpath working. I'm not sure how to send -cp commandline to rmiregistry.exe. Its documentation is quite lacking.
I'm fairly certain that you'll have to start your RMI server using the same classpath as your application. I believe it takes the same parameters as java, i.e. -cp [your class path].
Close the cmd window where the rmiregistry was initially started.In a fresh cmd go to the location where your project classfiles are located(uptill bin) and start the registry using the below command:
rmiregistry -J-Djava.rmi.server.useCodebaseOnly=false
If you are using Eclipse ,Run the ServerSideProject and your ImplementationClass Instance gets bound to the URL specified.
Just print a line below the the binding method and see to it whether it is gets printed. If it gets printed successfully it means your server is working fine.
try to add /bin at the end of your VM Arg:
-Djava.rmi.server.codebase=file:${workspace_loc}/progInternet2008/bin
The file you will run are in this directory, so you need to include it in the path.
I upgraded from JDK1.6.0_33 to 1.7.0_45 and had the same problem. I found this document and resolved the problem by starting rmiregistry with:
rmiregistry -Djava.rmi.server.useCodebaseOnly=false
Refer below
http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/enhancements-7.html
I had the same problem, to fix this ensure that your CLASSPATH is set to the path containing the server classes when running rmiregistry.
On a linux machine run the following commands.
export CLASSPATH="<server_class_path>"
Ensure the CLASSPATH has been set:
echo $CLASSPATH
Once the class path has been set, run rmiregistry
rmiregistry &
I spent a whole day uninstalling and reinstalling my JDK and changing the classpaths's and environment variables. But the culprit was that the command start rmigregistry didnt' start rmiregistry in a proper way. So, thanks for the comments on this page the solution was to unset the CLASSPATH temporarily. And that is done through the command set CLASSPATH=

Categories