viatra / massif

Massif is a Matlab Simulink Integration Framework for Eclipse
https://viatra.github.io/massif/
Eclipse Public License 1.0
19 stars 14 forks source link

Command Evaluation Server fails to import in Matlab 2019a #194

Open ujhelyiz opened 5 years ago

ujhelyiz commented 5 years ago

When trying to import simulink models using Matlab2019a with the latest Massif 0.8.0 CI build, it failed with the following exception:

hu.bme.mit.massif.communication.CommandEvaluationException: Exception occurred while evaluating command!
    at hu.bme.mit.massif.communication.AbstractCommandEvaluator.evaluateCommand(AbstractCommandEvaluator.java:65)
    at hu.bme.mit.massif.communication.AbstractCommandEvaluator.evaluateCommands(AbstractCommandEvaluator.java:264)
    at hu.bme.mit.massif.communication.command.MatlabCommand.execute(MatlabCommand.java:99)
    at hu.bme.mit.massif.simulink.api.adapter.block.DefaultBlockAdapter.process(DefaultBlockAdapter.java:56)
    at hu.bme.mit.massif.simulink.api.Importer.createBlockInstance(Importer.java:934)
    at hu.bme.mit.massif.simulink.api.Importer.createBlock(Importer.java:870)
    at hu.bme.mit.massif.simulink.api.Importer.createBlocksFromTopLevel(Importer.java:804)
    at hu.bme.mit.massif.simulink.api.Importer.traverseAndCreateEMFModel(Importer.java:620)
    at hu.bme.mit.massif.simulink.ui.handlers.ImportModelHandler$1.run(ImportModelHandler.java:196)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: 
5: Error on invoking command in matlab server 
Additional information:
{Number of output arguments=1, Type:=eval, Input arguments=, Command:=ImporterTmpResult(1:end)}
---------------------
Original exception: 
java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.mathworks.jmi.types.MLArrayRef
    at br.com.embraer.massif.commandevaluation.client.MatlabClient.prepareMatlabRMIException(MatlabClient.java:191)
    at br.com.embraer.massif.commandevaluation.client.MatlabClient.executeEval(MatlabClient.java:215)
    at hu.bme.mit.massif.communication.commandevaluation.MatlabClientAccess.executeEval(MatlabClientAccess.java:38)
    at hu.bme.mit.massif.communication.AbstractCommandEvaluator.dataRetriever(AbstractCommandEvaluator.java:142)
    at hu.bme.mit.massif.communication.AbstractCommandEvaluator.evaluateCommand(AbstractCommandEvaluator.java:58)
    ... 9 more

When looking at the partial model created, the issue comes at the very start. I am also attaching the debug log and the created file for future reference.

massif_080_matlab_2019a.zip

ujhelyiz commented 5 years ago

Most likely this is also caused by the missing massif-functions.m issue first defined in #156 - but I have to check it again.

thSoft commented 5 years ago
ujhelyiz commented 5 years ago

Makes sense that adding the massif_functions.m to the path does not help, as it is already added to the installation folder (https://github.com/viatra/massif/issues/156#issuecomment-505832285)...

abelhegedus commented 5 years ago

I found this: https://diffplug.github.io/matconsolectl/javadoc/4.4.2/matlabcontrol/MatlabProxy.html

Function Handles and Non-Built-In Classes MATLAB function_handles and all non-built-in classes (such as the Map class or user defined classes) are converted to an instance of com.mathworks.jmi.types.MLArrayRef that is not Serializable which prevents it from being transferred to a Java application running outside MATLAB (more information on this can be found in the exception section below).

abelhegedus commented 5 years ago

This could be better handled in https://github.com/viatra/massif/blob/master/plugins/br.com.embraer.massif.commandevaluation.server/src/br/com/embraer/massif/commandevaluation/server/MatlabRemoteImpl.java by checking for Serializable and even special cases.