Struct Contents Reference From a Non-Struct Array Object

I had to get in touch with Mathworks viz a viz a problem concerning the passing of a Java object to various workers of the parallel computing toolbox of Matlab. I got the following answer from the support. I am sure someone is going to encounter the same problem and might need help. Please peruse.

Hello Muhammad Adil,

I am Preethi and I am writing in reference to your Technical Support Case #03167864 regarding ‘Struct contents reference from a non-struct array object.’.

I understand that you are seeing an error when trying to call a function of a serialized Java Object in parfor loop
One of the possible reasons would be that the Java class is added in the dynamic java classpath. The workers are not able to access the dynamic java classpath since it is specific to that session of MATLAB, and all the workers run on different MATLAB processes. Use one of the following two workarounds to make this work:

1) Please add the java class to the “static” java class path. Instructions on how to do this can be found in the following documentation link:
http://www.mathworks.com/help/matlab/matlab_external/bringing-java-classes-and-methods-into-matlab-workspace.html#f4867 <http://www.mathworks.com/help/matlab/matlab_external/bringing-java-classes-and-methods-into-matlab-workspace.html#f4867>

This will make sure that all MATLAB processes will have access to the same java class path.

2) The “javaaddpath” function to add entries to the dynamic Java class path can be executed on all the workers using the “pctRunOnAll” command as follows:

>pctRunOnAll javaaddpath(‘path’) %Replace ‘path’ with the appropriate path

Please make sure that the parallel pool is running before running this command.
I believe this will help in resolving the issue you are facing. I am thus marking this case as closed for now. If the issue persists, please feel free to reply to this email and I will be happy to reopen the case and help you further.

Please preserve the Reference ID in further correspondence on this query. This allows our systems to automatically associate your reply to the appropriate Case.

Sincerely,
Preethi Ayyamperumal
MathWorks Technical Support

Self-Service: https://www.mathworks.com/support/contact_us.html
File Exchange and MATLAB Answers: http://www.mathworks.com/matlabcentral/

Photo by ZapTheDingbat

If you found an error, highlight it and press Shift + Enter or click here to inform us.

CC BY-NC-ND 4.0 Struct Contents Reference From a Non-Struct Array Object by Psyops Prime is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Leave a Reply