mayankparmar / matlabcontrol

Automatically exported from code.google.com/p/matlabcontrol
0 stars 1 forks source link

Matlab session cannot be registered #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of matlabcontrol are you using?
4.0.0

What version of MATLAB are you using?
R2012a

What operating system are you using?
Windows 7

Are you using matlabcontrol from inside MATLAB or outside MATLAB?
Outside MATLAB.  Specifically, from a custom-written Java plugin in the 
Java-based microscopy software MicroManager.

What steps will reproduce the problem?
1. Creating a MatlabProxyFactoryOptions instance.

What did you expect to happen? What happened instead?
I expected Matlab would open, create an instance, and then I would later be 
able to connect to that instance.  When I create an instance, I get the error 
message below in Matlab.  Commands sent through the proxy will execute, but I 
cannot reconnect to the session.

Errors:
Reconnecting to this session of MATLAB will not be possible
matlabcontrol.MatlabConnectionException: Could not register this session of 
MATLAB
    at matlabcontrol.MatlabBroadcaster.bindSession(MatlabBroadcaster.java:144)
    at matlabcontrol.MatlabBroadcaster.broadcast(MatlabBroadcaster.java:92)
    at matlabcontrol.MatlabConnector$EstablishConnectionRunnable.run(MatlabConnector.java:189)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.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)
Caused by: java.rmi.ServerException: RemoteException occurred in server thread; 
nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: matlabcontrol.MatlabSession (no security manager: RMI class loader disabled)
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:400)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:248)
    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:662)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
    at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
    at matlabcontrol.MatlabBroadcaster.bindSession(MatlabBroadcaster.java:140)
    ... 8 more
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested 
exception is: 
    java.lang.ClassNotFoundException: matlabcontrol.MatlabSession (no security manager: RMI class loader disabled)
    at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:390)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:248)
    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:662)
Caused by: java.lang.ClassNotFoundException: matlabcontrol.MatlabSession (no 
security manager: RMI class loader disabled)
    at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:533)
    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:1530)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1492)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
    ... 12 more

Original issue reported on code.google.com by asgro%pr...@gtempaccount.com on 20 Feb 2013 at 2:15

GoogleCodeExporter commented 8 years ago
Based on communication with bug opener the issue here is stemming from 
MicroManager interfering with Java RMI - this even occurs if MicroManger is 
running and the demo is used.

Original comment by nonot...@gmail.com on 21 Feb 2013 at 2:37

GoogleCodeExporter commented 8 years ago
Hello,
I have exactly the same problem. But I don't have MicroManager.
How do I know which program is interfering with the connection?
Thank you.

Original comment by apasq...@gmail.com on 9 Sep 2013 at 1:48

GoogleCodeExporter commented 8 years ago
i have exactly the same problem. But! If i started from Swing application its 
work, if i start from ant task it doesnt work !

Original comment by Aleksej.Turko@googlemail.com on 15 Jan 2015 at 10:19

GoogleCodeExporter commented 8 years ago
This works for me, maybe it helps, if still have problems.  

public MatlabCommand() throws Exception {
  // Change classloader for usage in OSGi threads
  ClassLoader OldClassLoader = Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
  this.Matlabfactory = new MatlabProxyFactory();
  this.MatlabProxy = Matlabfactory.getProxy();
  // Reset classloader
  Thread.currentThread().setContextClassLoader(OldClassLoader);
}

Original comment by t.heitpl...@googlemail.com on 21 May 2015 at 9:42