javax.persistence.PersistenceException (no security manager: RMI class loader disabled)

5

I created a policy file that gives the permission for my machine to run both the client and the server, I also passed the ports to them. Inside the server I instantiate RMI Security (since if I take it the policy does not work)

Server started works ok. Customer starts running ok. I finish inserting the last field to create a new user in the database and comes these errors.

Client:

  

java.rmi.UnmarshalException: Error unmarshaling return; nested   exception is: java.lang.ClassNotFoundException:   javax.persistence.PersistenceException (no security manager: RMI class   loader disabled) at   sun.rmi.transport.StreamRemoteCall.executeCall (StreamRemoteCall.java:247)     at sun.rmi.server.UnicastRef.invoke (UnicastRef.java:162) at   java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod (RemoteObjectInvocationHandler.java:194)     at   java.rmi.server.RemoteObjectInvocationHandler.invoke (RemoteObjectInvocationHandler.java:148)     at com.sun.proxy. $ Proxy0.insert (Unknown Source) at   rmi.client.Services.addressUsers (Servicos.java:42) at   rmi.cliente.RMICliente.main (RMICliente.java:16) Caused by:   java.lang.ClassNotFoundException:   javax.persistence.PersistenceException (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:214)     at   java.io.ObjectInputStream.readNonProxyDesc (ObjectInputStream.java:1613)     at   java.io.ObjectInputStream.readClassDesc (ObjectInputStream.java:1518)     at   java.io.ObjectInputStream.readOrdinaryObject (ObjectInputStream.java:1774)     at java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1351)     at java.io.ObjectInputStream.readObject (ObjectInputStream.java:371)     at   sun.rmi.transport.StreamRemoteCall.executeCall (StreamRemoteCall.java:245)     ... 6 more

Note: The server has stopped giving error, now it's just the client.

    
asked by anonymous 22.11.2015 / 17:01

1 answer

1

Your problem seems to be classpath, so look at this from here:

  

java.lang.ClassNotFoundException: javax.persistence.PersistenceException (no security manager: RMI class loader disabled) at   rmi.client.Services.addressUsers (Servicos.java:42)

That is, in its Servicos class that is on the client side, there was an attempt to access the PersistenceException class. This class probably does not exist on the client side, as it should not make sense to have JPA on the client side.

It happens that when javax.persistence.PersistenceException is serialized from the server to the client, the client can not deserialize because the exception does not exist there. The result is an error in deserialization.

So what's happening is this:

  • Server persistence error occurred.
  • The error was serialized and sent to the client.
  • The client could not deserialize the exception and this caused another exception.
  • And you may be able to see PersistenceException on the server side with all the information that made it launch.

    To fix this, here are some possibilities:

    • Add the JPA JAR to the client classpath.
    • Append the class javax.persistence.PersistenceException in isolation to the client classpath.
    • On the server side, do not let PersistenceException be serialized to the client ever. To do this, use try...catch blocks in a way that prevents this. It is important to be aware that PersistenceException does not leak even as the cause of a higher-level exception.
    23.11.2015 / 03:10