필터 지우기
필터 지우기

How can I force a .jar onto a worker's Java class path in MCR?

조회 수: 8 (최근 30일)
Alex
Alex 2015년 8월 6일
댓글: Alex 2015년 8월 10일
To preface this question, I acknowledge that the way everything is currently coded is bad, but in this case I am a user and not a developer -- I can't just rewrite the project correctly and recompile.
The situation I'm facing is that I'm trying to run some code in MCR that opens up a parcluster and uses parfor to run a function in parallel. That function calls a custom Java package which I have added to the MCR classpath, but when workers are spawned they do not get the same classpath. I don't care how it gets done (e.g. I am comfortable modifying the default installation), but somehow I need to shove a .jar into the classpath that workers see without changing any code.
Here is the error:
No class {com.etc.etc} can be located on the Java class path
Error in {functionName}>(parfor body) (line 17)
Error in {functionName}(line 15)
Caused by:
Error using javaObject
No class {com.etc.etc} can be located on the Java class path
The package is definitely working correctly for the purposes of the MCR classpath because the code would not even get that far otherwise (a class in the same package is used before the matlabpool is spawned).
This is running on Java 6 and MCR 8.1.

답변 (1개)

Varun Bhaskar
Varun Bhaskar 2015년 8월 10일
Hello,
I understand that you want each worker to dynamically load a .jar file. You can do the same by including the .jar file as an attachment to be sent to each worker when 'parpool' is started in the following manner:
parpool('AttachedFiles',{'ABC.jar'});
Each worker can then call the 'javaaddpath' to retrieve the .jar file from the attachment folder. The attachment folder can be obtained in the following manner:
folder = getAttachedFilesFolder;
  댓글 수: 1
Alex
Alex 2015년 8월 10일
The code is already compiled and I cannot recompile. Consider the question "how do I trick MCR into including a custom .jar everywhere" as opposed to "how do I code this properly."

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by