How can I force a .jar onto a worker's Java class path in MCR?
2 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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;
参考
カテゴリ
Help Center および File Exchange で Parallel Computing Fundamentals についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!