How to fix Illegal reflective access by com.mathworks.util.DeleteOnExitShutdownInitializer?
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I have a RESTful API project where I use Spring Boot Maven. I'm also processing in Matlab with a jar file. I converted this project to .jar file, but when I run it with java -jar demo.jar it closes after running. However, since it was a restful API, it had to remain open so that I could access the APIs.
Java : Java 11
Matlab: R2018a
pom.xml:
<?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>
        <cholSolver.path>C:\Users\user\Desktop\PDTO-Project\pdtopolys\cholSolver.jar</cholSolver.path>
        <javabuilder.path>C:\Program Files\MATLAB\R2018a\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</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>peridynamics</groupId>
            <artifactId>cholSolver</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${cholSolver.path}</systemPath>
        </dependency>    
    <dependency>
        <groupId>com.mathworks</groupId>
        <artifactId>javabuilder</artifactId>
        <version>R2018a</version>
        <scope>system</scope>
        <systemPath>${javabuilder.path}</systemPath>
    </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
After running the jar file, it starts working. So far, no problem. However, in order for me to access the RESTful APIs I created, it must remain running and the process must not be terminated.
A few warning messages and closed:
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
09:48:29.501 [SpringApplicationShutdownHook] DEBUG org.springframework.context.annotation.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@24269709, started on Fri Sep 29 09:46:43 EET 2023
 I tried to use:
java --add-opens java.base/java.lang=ALL-UNNAMED -jar path/to/demo.jar
nothing changed.
How can i solve the problem?
0 Commenti
Risposte (1)
  Varun
      
 il 20 Dic 2023
        
      Modificato: Varun
      
 il 20 Dic 2023
  
      Hey! I think this is due to a bug in the JDK. I found out about it in the following bug report:  https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8193516. JDK 11 is probably also affected even it is not listed in the bug report. It appears to be more of a JAVA issue than an MATLAB issue. Hope this helps!
0 Commenti
Vedere anche
Categorie
				Scopri di più su Startup and Shutdown in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

