Having errors on Java RMI Server/Client Implementation - java

I'm currently following a small tutorial for RMI on another thread, here is the link!
The problem I'm having is that if I put all the classes on the same project(I'm using Netbeans) then it works flawlessly, but on real life the client and the server are usually different machines, so when I try to put the Client on a different project and Implement the same interface and SomeStruct class then I get the following error:
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: rmiserver.SomeInterface (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 clientrmi.SomeClient.main(SomeClient.java:17)
Caused by: java.lang.ClassNotFoundException: rmiserver.SomeInterface (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:556)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:255)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1559)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1515)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
... 3 more
and if I Implement the following code on the client :
if(System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}
then I get the following error:
java.security.AccessControlException: access denied ("java.net.SocketPermission" "127.0.0.1:1234" "connect,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051)
at java.net.Socket.connect(Socket.java:584)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:148)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
Any ideas on how to fix this? Any input is truly appreciated!

I think your problem is that you need a total of 3 projects:
First project contains the interface.
Second project contains the Server and add the first project as one of the libraries.
Third project contains the Client and add the first project as one of the libraries.
The key is that the client and server projects each have to have the interface (the same interface) inside the project.
Your error:
java.lang.ClassNotFoundException: rmiserver.SomeInterface (no security manager: RMI class loader disabled)
Says that it can't find your class: SomeInterface.
I don't think the Security Manager is your real problem.
Hope that helps.

Related

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.

WAS8.5.5 not incorporating Jacorb application

I had an application which is tightly coupled with jacorb and it is working great with Jboss. Now, i have to migrate this application to deploy the same in Websphere 8.5.5. General flow is , my application will reach another system (developed in C++) through corba usign jacorb. since IBM is having its own ORB implementations, My application is getting deployed in websphere. If my application is modified to make use of IBM orb jars, then 80% of applciation have to change. Kindly suggest me the way to include jacord proeprties and jar to resolve the errors.
My trails : All trails are independent to each other.
1) Kept my orb.properties, jacorb.jar and removed IBM orb.properties in WAS->JAVA->JRE->lib
2) Included my files in JVM classpath through Admin console.(Server failed to start after this change).
3) Modified the IBM orb.properties with jacorb properties but getting classcast exceptions.
Errors:
[3/4/15 0:52:23:175 PST] 00000001 ContainerHelp E WSVR0501E: Error creating component null [class com.ibm.ws.runtime.component.ORBImpl]java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:877)
at org.jacorb.config.JacORBConfiguration.setAttribute(Unknown Source)
at org.jacorb.config.JacORBConfiguration.setAttributes(Unknown Source)
at org.jacorb.config.JacORBConfiguration.init(Unknown Source)
at org.jacorb.config.JacORBConfiguration.<init>(Unknown Source)
at org.jacorb.config.JacORBConfiguration.getConfiguration(Unknown Source)
at org.jacorb.orb.ORB.set_parameters(Unknown Source)
at org.omg.CORBA.ORB.init(ORB.java:371)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:92)
[3/4/15 0:52:23:347 PST] 00000001 ContainerHelp E WSVR0501E: Error creating component com.ibm.ws.naming.bootstrap.NameServerImpl#e69374e2[_serverProcessType=UnManagedProcess, _listener=null,
Caused by: javax.naming.NamingException: Failed to initialize the ORB [Root exception is java.lang.reflect.InvocationTargetException]
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:400)
at com.ibm.ws.naming.urlbase.UrlContextImpl.<init>(UrlContextImpl.java:177)
at com.ibm.ws.naming.urlns.genericURLContext.<init>(genericURLContext.java:83)
at com.ibm.ws.naming.urlns.genericURLContextRoot.<init>(genericURLContextRoot.java:79)
at com.ibm.ws.naming.urlns.genericURLContextFactory.createURLContextRoot(genericURLContextFactory.java:110)
... 51 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:391)
... 55 more
Caused by: java.lang.ClassCastException: org.jacorb.orb.ORB incompatible with com.ibm.CORBA.iiop.ORB
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:92)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:179)
at com.ibm.ejs.oa.EJSClientORBImpl.<init>(EJSClientORBImpl.java:83)
at
Thanks for your support in advance.

I made an instance of CipherSpi class for a project and I get "JCE cannot authenticate the provider"

I'm making a project, and in the project it's part of our work to remake a cipher algorithm and others and then to use them using the JCA (java criptographic architecture) rules.
I have made a provider that provides multiple classes. All seems to be working well until I try to use getInstance().
I made, among others, a DH (extends KeyAgreementSpi) class for KeyAgreement different usages
KeyAgreement dh = KeyAgreement.getInstance("DH", myProvider);
I get:
Exception in thread "Thread-0" java.lang.SecurityException: JCE cannot authenticate the provider Ts001Proj1Provider
at javax.crypto.JceSecurity.getInstance(JceSecurity.java:114)
at javax.crypto.KeyAgreement.getInstance(KeyAgreement.java:263)
at fcul.ts001.proj1.SecuredStream.(SecuredStream.java:194)
at fcul.ts001.proj1.SecureStreamTest.run(SecureStreamTest.java:24)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.SecurityException: Cannot verify jar:file:/*pathToProject*/proj/Main/bin/!/
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:406)
at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:322)
at javax.crypto.JarVerifier.verify(JarVerifier.java:250)
at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:161)
at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:187)
at javax.crypto.JceSecurity.getInstance(JceSecurity.java:110)
... 4 more
Caused by: java.security.PrivilegedActionException: java.io.FileNotFoundException: *pathToProject*\proj\Main\bin (Access is denied)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:384)
... 9 more
Caused by: java.io.FileNotFoundException: *pathToProject*\proj\Main\bin (Access is denied)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:214)
at java.util.zip.ZipFile.(ZipFile.java:144)
at java.util.jar.JarFile.(JarFile.java:153)
at java.util.jar.JarFile.(JarFile.java:90)
at sun.net.www.protocol.jar.URLJarFile.(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:98)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
at javax.crypto.JarVerifier$2.run(JarVerifier.java:399)
... 11 more
The best part is that this code executed well:
KeyPairGenerator dhKeyPairGen = KeyPairGenerator.getInstance("DH", myProvider);
Why do I get it?
I'm working on win6.1 x64
There's a lot more to it than just implementing one class. You have to get your provider certified for a start. Why are you doing this?

java.lang.ClassNotFoundException: org.jboss.ejb.plugins.local.LocalHomeProxy (no security manager: RMI class loader disabled)

The code fragment below works when I the application is deployed in JBOSS as a EJB services.
I get a exception when I call the same code as a standalone program in eclipse. Is it not possible to call this on a simple java project ?
AuthenticationServices.getInstance().createSession("abcd");
Caused by: javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: org.jboss.ejb.plugins.local.LocalHomeProxy (no security manager: RMI class loader disabled)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:845)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.ejb.EjbHomeLoader.getRemoteHome(EjbHomeLoader.java:68)
at com.ejb.EjbHomeLoader.getRemoteHome(EjbHomeLoader.java:45)
at com.ejb.EjbManager.getEjbHome(EjbManager.java:238)
at com.ejb.EjbManager.getEjbObject(EjbManager.java:184)
at com.services.BaseServices.executeLocalEjbMethod(BaseServices.java:294)
... 2 more
Caused by: java.lang.ClassNotFoundException: org.jboss.ejb.plugins.local.LocalHomeProxy (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:375)
The class is in JBOSS.jar, please add it in your class path.

Java RMI UnmarshalException and AWS EC2 Server

I'm trying to implement the RMI Compute PI tutorial found on the Sun/Oracle website here. The server is located on an Amazon windows EC2 Server. The client is located on my personal computer at home. Just to keep things simple, I have disabled the firewall on the server and open all the port on the EC2 security group. I can ping the machine, have access to files, etc... My aim is just to have a basic RMI program worked on AWS. I will oversee security issues later.
Lauching the server is not a problem. And it's correctly bound to the RMI Registry. I'm using the following command to launch it :
java -Djava.security.manager -Djava.security.policy=C:\AWSTest\security.policy -Djava.rmi.server.codebase=file:/C:/AWS/Sources/sun-rmi-tutorial-server/bin/ file:/C:/AWS/Sources/sun-rmi-tutorial-common/bin/ -classpath C:\AWS\Sources\sun-rmi-tutorial-server\bin;C:\AWS\Sources\sun-rmi-tutorial-common\bin engine.ComputeEngine ec2-XX-XX-XX-XXX.ap-southeast-1.compute.amazonaws.com
The RMI registry is started on the server side.
I have declared a new security manager on the server side System.setSecurityManager(new RMISecurityManager())
I'm using a security.policy file where I'm granted all permission.
When I'm launching the client side, on my local computer, I'm ending with an UnmarshalException:
ComputePi exception: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Naming.java:101)
at client.ComputePi.main(ComputePi.java:14)
Caused by: java.lang.ClassNotFoundException: engine.ComputeEngine_Stub
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:453)
at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:184)
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:216)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1593)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
... 3 more
Do you have any suggestions of what is wrong ? Why can't the client find the correct Stub ? I'm using Eclipse Juno, Genady RMI Plugin and Java 1.7.0_07.
Thanks for your help
EDIT 1 :
The Java workspace is organized around 3 projects : the Client side, the Server Side and a Common project where both the server and the client share classes.
I can read the remote registry from my local computer. The RMI plugin can connect remotely to the server and inspect the registry.
If instead of making 3 projects I put all the classes under the same project, everything is working fine... But I notice that no stubs where generated (or needed).
If, on the client side, I'm putting a reference in the classpath to the server classes (everything being build locally), i have a connection timeout error instead of the unmarshalling error.
ComputePi exception: Connection refused to host: XX.XXX.XX.XX; nested exception is:
java.net.ConnectException: Connection timed out: connect
java.rmi.ConnectException: Connection refused to host: XX.XXX.XXX; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:128)
at engine.ComputeEngine_Stub.executeTask(ComputeEngine_Stub.java:35)
at client.ComputePi.main(ComputePi.java:19)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.(Socket.java:425)
at java.net.Socket.(Socket.java:208)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:146)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 5 more
You haven't deployed the stub class to the client.

Categories