How to fix com.mathworks.toolbox.javabuilder.MWException issue?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a java project that i used matlab and javabuilder in. Actually it works but suddenly it started to get errors. (Before this i tried to get java .jar file but i could get before). I don't understand what is the problem and what should i do?
Error:
Undefined function or variable 'matlabrc'.
Undefined function or variable 'ctfroot'.
Error in checkRequiredMCRProducts (line 14)
... Matlab M-code Stack Trace ...
com.mathworks.toolbox.javabuilder.MWException: An error occurred while initializing the component.
Undefined function or variable 'ctfroot'.
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:889)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$5.invoke(MWMCR.java:771)
at com.sun.proxy.$Proxy49.mclInitializeComponentInstance(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.newInstance(MWMCR.java:633)
at cholSolver.CholSolverMCRFactory.newInstance(CholSolverMCRFactory.java:53)
at cholSolver.CholSolverMCRFactory.newInstance(CholSolverMCRFactory.java:64)
at cholSolver.Cholmod2.<init>(Cholmod2.java:79)
at peri.Beso3D_PD.initiate(Beso3D_PD.java:667)
at peri.Beso3D_PD.<init>(Beso3D_PD.java:129)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1326)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:921)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292)
at peri.demoApp.main(demoApp.java:10)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.mathworks.util.DeleteOnExitShutdownInitializer (file:/C:/Program%20Files/MATLAB/MATLAB%20Runtime/v94/java/jar/util.jar) to field java.io.DeleteOnExitHook.files
WARNING: Please consider reporting this to the maintainers of com.mathworks.util.DeleteOnExitShutdownInitializer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
And this is the pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.16</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo1</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<chSolver.path>C:\Users\suuser\Desktop\PDTO-Github\PDTO-Project\pdtopolys\chSolver.jar</chSolver.path>
<javabuilder.path>C:\Program Files\MATLAB\MATLAB Runtime\v94\toolbox\javabuilder\jar\javabuilder.jar</javabuilder.path>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.googlecode.matrix-toolkits-java</groupId>
<artifactId>mtj</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>peri</groupId>
<artifactId>chSolver</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${chSolver.path}</systemPath>
</dependency>
<dependency>
<groupId>com.mathworks</groupId>
<artifactId>javabuilder</artifactId>
<version>9.4</version>
<scope>system</scope>
<systemPath>${javabuilder.path}</systemPath>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
</project>
Months ago i get some error looks like this (again tried to get java .jar from the project). I could solve this problem with <includeSystemScope>true</includeSystemScope>. But i get error again.
Also, when i tried to open pom.xml file, i get this message:
Command failed: mvn -q help:effective-pom -Doutput=\c:\Users\user\Desktop\Project\pdt\fea\effective-pom.xml -f /c:/Users/user/Desktop/Project/pdt/fea/pom.xml POM file "/c:/Users/user/Desktop/Project/pdt/fea/pom.xml" specified the -f/--file command-line argument does not exist
How can i solve this problem?
0 comentarios
Respuestas (1)
Sachin Lodhi
el 11 de Jun. de 2024
Hi Rozerin,
The error message you are seeing indicates that the "matlabrc" function is missing, likely because the application can not locate the CTF archive in which "matlabrc" is located. This issue may arise during certain application build processes where shared libraries are "stripped" of some data, potentially removing the embedded CTF archives needed during execution. To avoid this, ensure your build process includes the "-C" option, which prevents stripping and keeps CTF files embedded in the binaries.
Another workaround here is to delete the CTF extraction folder, and run the EXE of your compiled application again. If the "MCR_CACHE_ROOT" environment variable is not set and you are using a Windows machine, the CTF extraction location can be found at the following temporary directory:
C:\Users\[username]\AppData\Local\Temp\[username]\mcrCache[version]
Otherwise, this information will be saved to the location specified by the "MCR_CACHE_ROOT" environment variable. To ensure that Windows does not remove files in this temporary directory, you may set up the "MCR_CACHE_ROOT" environment variable to point to a non-temporary directory you have write access to.
If neither of these workarounds resolve the issue, follow these additional troubleshooting steps, previously found at https://www.mathworks.com/help/compiler/index.html
1) Ensure that your application runs in MATLAB (uncompiled) without this error.
2) Ensure that MATLAB starts up without this error.
3) Verify that the generated deployable archive contains a file called matlabrc.m
4) Verify that the generated code (in the "_mcc_component_data.c" file) adds the deployable archive folder containing matlabrc.m to the MATLAB runtime path
5) Delete the "*_mcr" folder and rerun the application.
6) Recompile the application.
I would also recommend you to go through the following MATLAB Answer for other workarounds : https://in.mathworks.com/matlabcentral/answers/98050-why-do-i-get-an-error-saying-undefined-function-or-variable-matlabrc-when-executing-a-program-th
I hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!