How do I prevent Matlab java object generated with MATLAB Builder JA from failing with errors on the second time it is called in the same applciation scope.

1 view (last 30 days)
Two different matlab programs compile with javabuilder and called from JAVA programs are failing on the second time they are called from the same applciation.
Any ideas on what could be happening?
  • Matlab code is compiled with MCR 717 x64 using java 1.6.0_38.
  • Java calling code is compiled with x64 using java 1.6.0_38.
  • matlab java entry function/object is called from java object.
  • Java object is called by java session bean.
  • Session bean is called by java web service.
  • Web service is running in Glassfish 3.1.2.2.
One error on restart: Error using matlabpool (line 134) Java exception occurred: java.lang.IllegalStateException: An application can only use one MCR component that uses Parallel Computing Toolbox functionality. at com.mathworks.toolbox.distcomp.util.MatlabRefStore.initMatlabRef(MatlabRefStore.java:27)
The other error on restart: SEVERE: Undefined function 'javaaddpath' for input arguments of type 'cell'. com.mathworks.toolbox.javabuilder.MWException: An error occurred while initializing the component. Undefined function 'javaaddpath' for input arguments of type 'cell'. at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclInitializeComponentInstance(Native Method) at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$700(MWMCR.java:23) at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclInitializeComponentInstance(MWMCR.java:837)
  3 Comments
Chrysanthie
Chrysanthie on 16 Jul 2013
The solution.
Create the java matlab object once and reuse. then disposed either when the application quites or web service is undeployed, the expected multiple run behavior when callign the matlab java object works correctly.
matlabJavaObject mjo = null;
myFunction() {
if (mjo == null ) {matlabJavaObject mjo = new matlabJavaObject();}
//do something
mjo.dispose(); }

Sign in to comment.

Answers (0)

Categories

Find more on Java Package Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!