MATLAB / Datafeed compiled code with Bloomberg APIv3 / Java library: Java Exception -
am trying compile matlab code employs bloomberg's apiv3 via datafeed toolbox. code runs fine within matlab. compiler works fine on code without java. javaclasspath references api via:
dynamic java path c:\blpv3\api\apiv3\javaapi\v3.7.1.1\lib\blpapi3.jar
i several compilation errors relating java (stacktrace below) on compilation :
mcc -m -r -startmsg -r -completemsg -v my_prog.m
i suppose need tell mcc link blpapi3.jar more explicitly, how? need set static java path?
any appreciated!
warning: java exception occurred getting method description java.util.locale class: java exception occurred: java.lang.noclassdeffounderror: com/bloomberglp/blpapi/session @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(unknown source) @ java.lang.class.privategetpublicmethods(unknown source) @ java.lang.class.getmethods(unknown source) @ com.mathworks.jmi.opaquejavainterface.doesmethodexist(opaquejavainterface.java:407) caused by: java.lang.classnotfoundexception: com.bloomberglp.blpapi.session @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ java.lang.classloader.loadclassinternal(unknown source) ... 5 more
after more browsing , lots of trials, have resolved issue. answers in several posts on site already. anyway, there several issues...
1
it appears
java exception occurred: java.lang.noclassdeffounderror
is runtime error, not compile error. fix updated classpath.txt in both compiler , mcr, located at,
$matlabroot\toolbox\local\classpath.txt
to this
javaclasspath
static java path c:\program files\matlab\r2012a\java\patch c:\blpv3\api\apiv3\javaapi\v3.7.1.1\lib\blpapi3.jar
alternatively, blpapi3.jar can copied
$matlabroot/java/jarext
alongside other jar files.
also, removed dynamic java path, works matlab ide.
2
i have disabled addpath in startup.m clause such as
if ~isdeployed && ~ismcc addpath d:\matlab ... end
3
arguments mcc must include directories in source files located, i.e.
mcc -m -i 'source_file_dir' -v top_level_function.m
4
when handling files within code, reference relative $matlabroot, e.g.
if isdeployed sfile_path = fullfile(matlabroot,'..','input',sfile_name); else sfile_path = which(sfile_name); end
5
notice $matlabroot of mcr different $matlabroot of matlab ide.
Comments
Post a Comment