Matlab compiled jar cannot run with task scheduler but can run manually

5 views (last 30 days)
Hello everyone,
I have some matlab-code, which included as jar-File (created with matlab compiler sdk) in a java-application. If I start my java-application manually using a bat-file everything works. But if I start the same bat-file using the windows task scheduler the matlab-code cannot be executed. (The other parts of the java-application work in both cases)
Stacktrace:
... Matlab M-code Stack Trace ...
com.mathworks.toolbox.javabuilder.MWException: An error occurred while initializing the component.
Could not access the MATLAB Runtime component cache. Details: Some error has occurred in the file: b:\matlab\standalone\mclmcr\mcr_cache\mclcomponentcache.cpp, at line: 250.
The error message is:
Failed to completely extract component!
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclInitializeComponentInstance(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$700(MWMCR.java:31)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclInitializeComponentInstance(MWMCR.java:888)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$5.invoke(MWMCR.java:770)
at com.sun.proxy.$Proxy79.mclInitializeComponentInstance(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.newInstance(MWMCR.java:632)
I also don't understand why it's accessing drive B. The file and the matlab runtime installation is located on drive C.
Things I already checked:
  • Path variable of the matlab runtine installation
  • Check the cache files (https://de.mathworks.com/matlabcentral/answers/33638-could-not-access-the-mcr-component-cache-error)
  • Setting an env-variable MCR_ROOT_CACHE to a temp-folder (didn't found the link again)
  • I tried to compile with -C but it fails:Packaging...Creating the bundle...Failed to create the install bundle[...]\for_testing\de.ctf (The system cannot find the file specified)
Setup:
  • Matlab 2016b
  • Java 8
  • win server 2012 (64bit)
Would be great, if someone give me a hint. Thanks, Thomas

Accepted Answer

Prannay Jain
Prannay Jain on 6 Apr 2017
I am not sure what might be the issue, but there are few things you might try:
1) It may be a permission issue. Make sure that you have the right permissions to access MCR cache folder. Can you try changing MCR_CACHE_ROOT to some other folder and see if it makes any difference.
2) Is your application accessed/shared by multiple users? (Again look for the permissions for all the users even within your system.)
3) Did you correctly provide 'start-in' directory while creating the task? This discussion might be helpful: http://stackoverflow.com/questions/1020023/specifying-start-in-directory-in-schtasks-command-in-windows
  2 Comments
Thomas Schürle
Thomas Schürle on 10 Apr 2017
Thanks for your answer. Unfortunately it didn't solve the issue.
1) I tried another folder (also the variable names MCR_CACHE_ROOT and MCR_ROOT_CACHE)
1/2) I checked the permissions again. Everything is fine. And it's working by manual start, so it think they are fine
3) Yes, i did and it works (the java-application finds it additional files, which requires the right start-directory)
Thomas Schürle
Thomas Schürle on 10 Apr 2017
Appendix: Finally, it works. I'm not really sure, what solved the issue. Probably it was the invalid name of the environment-variable; so thanks again! (I added some other applications on the same server and had some restarts and now it works...)

Sign in to comment.

More 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!