简体   繁体   English

Caused by: java.lang.IllegalAccessError: superclass access check class apache (in module x) that cannot access another apache class (in mod y)

[英]Caused by: java.lang.IllegalAccessError: superclass access check class apache (in module x) that cannot access another apache class (in mod y)

I'm new to modularized java 16 projects as well as using the maven build system whilst trying to implement the program using IntelliJ, JAVAFX and APACHE POI-OOXML. I'm new to modularized java 16 projects as well as using the maven build system whilst trying to implement the program using IntelliJ, JAVAFX and APACHE POI-OOXML.

For simplicity, I am implementing a button's event handler that instantiates a class that is responsible for using Apache: ControllerCode为简单起见,我正在实现一个按钮的事件处理程序,它实例化一个负责使用 Apache 的 class: ControllerCode

The problem then happens here: line 24 of this code然后问题发生在这里:此代码的第 24 行

Here is the stack trace:这是堆栈跟踪:

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1862)
    at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1729)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8889)
    at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
    at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
    at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
    at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
    at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
    at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3856)
    at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1851)
    at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
    at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
    at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
    at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
    at javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:127)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:76)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:273)
    at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:83)
    at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1859)
    ... 44 more
Caused by: java.lang.IllegalAccessError: superclass access check failed: class org.apache.poi.openxml4j.util.ZipSecureFile (in module org.apache.poi.ooxml) cannot access class org.apache.commons.compress.archivers.zip.ZipFile (in unnamed module @0x2db197a2) because module org.apache.poi.ooxml does not read unnamed module @0x2db197a2
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1088)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:182)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:814)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:735)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:660)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:634)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
    at org.apache.poi.ooxml/org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:379)
    at org.apache.poi.ooxml/org.apache.poi.xwpf.usermodel.XWPFDocument.newPackage(XWPFDocument.java:140)
    at org.apache.poi.ooxml/org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:130)
    at com.example.demo3/com.example.demo3.DataManager.createLessonWord(DataManager.java:24)
    at com.example.demo3/com.example.demo3.HelloController.onHelloButtonClick(HelloController.java:23)
    ... 56 more

I am completely new to all of these but I feel as though this line from the stack trace above is the culprit:我对所有这些都是全新的,但我觉得上面堆栈跟踪中的这一行是罪魁祸首:

Caused by: java.lang.IllegalAccessError: superclass access check failed: class org.apache.poi.openxml4j.util.ZipSecureFile (in module org.apache.poi.ooxml) cannot access class org.apache.commons.compress.archivers.zip.ZipFile (in unnamed module @0x2db197a2) because module org.apache.poi.ooxml does not read unnamed module @0x2db197a2

Here is the module-info:这是模块信息:

module com.example.demo3 {
    requires javafx.controls;
    requires javafx.fxml;
    requires org.apache.poi.ooxml;


    opens com.example.demo3 to javafx.fxml;

    exports com.example.demo3;
} 

My maven dependencies:我的 maven 依赖项:

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>16</version>
    </dependency>
    <dependency>
        <groupId>org.controlsfx</groupId>
        <artifactId>controlsfx</artifactId>
        <version>11.1.0</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.0.0</version>
    </dependency>
</dependencies> 

I would appreciate all help that I can get:)我会很感激我能得到的所有帮助:)

A piece as it says about a zip archive in the error.一篇关于错误中 zip 存档的文章。 There is no actual stream assigned with the place e,g, you have a String path but analogous there is not actually so much as an actual.io.File related part of the code.没有实际的 stream 分配给该位置,例如,您有一个字符串路径,但类似地实际上并没有实际那么多。io.File 相关的代码部分。 There is however a constructor for such document that takes a Stream argument on construction.但是,此类文档的构造函数在构造时采用 Stream 参数。

This issue is due to missing requires in apache poi 5.0.0, which is fixed in 5.1.0.此问题是由于 apache poi 5.0.0 中缺少要求,该问题已在 5.1.0 中修复。

5.1.0 module-info.java 5.1.0 模块信息.java

module org.apache.poi.ooxml {
    requires org.apache.poi.poi;
    requires org.apache.xmlbeans;
    requires org.apache.poi.ooxml.schemas;
    requires org.apache.commons.collections4;
    requires org.apache.commons.codec;
    requires org.apache.commons.compress;
    requires org.apache.commons.io;
    requires commons.math3;
...

5.0.0 module-info.java 5.0.0 模块信息.java

module org.apache.poi.ooxml {
    requires org.apache.commons.collections4;
    requires org.apache.commons.codec;
    requires commons.math3;
...

Adding requires org.apache.commons.compress;添加requires org.apache.commons.compress; in your project module-info.java can solve the problem.在你的项目中 module-info.java 可以解决这个问题。 But it looks like there are many requires added in version 5.1.0 which may be due to similar issue.但看起来 5.1.0 版中添加了许多requires ,这可能是由于类似的问题。 So to prevent other similar error, I would suggest upgrading poi to version 5.1.0 or above.所以为了防止其他类似的错误,我建议将 poi 升级到 5.1.0 或更高版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalAccessError:超类访问检查失败:class org.apache.poi.openxml4j.util.ZipSecureFile - java.lang.IllegalAccessError: superclass access check failed: class org.apache.poi.openxml4j.util.ZipSecureFile Caused by: java.lang.IllegalAccessError: class com.spire.xls.packages.sprRFA (in module spire.xls.free) 无法访问 class - Caused by: java.lang.IllegalAccessError: class com.spire.xls.packages.sprRFA (in module spire.xls.free) cannot access class java.lang.IllegalAccessError: 无法访问类,因为模块没有导出到未命名的模块 - java.lang.IllegalAccessError: cannot access class because module does not export to unnamed module java.lang.IllegalAccessError:类 javax.xml.parsers.SecuritySupport12 无法访问其超类 javax.xml.parsers.SecuritySupport - java.lang.IllegalAccessError: class javax.xml.parsers.SecuritySupport12 cannot access its superclass javax.xml.parsers.SecuritySupport 线程“主”java.lang.IllegalAccessError 中的异常:无法访问 class - Exception in thread "main" java.lang.IllegalAccessError: failed to access class 黄瓜java.lang.IllegalAccessError中的Spring错误:尝试访问类 - Spring error in Cucumber java.lang.IllegalAccessError: tried to access class java.lang.IllegalAccessError:尝试从类org.apache.poi.openxml4j.opc.ZipPackage中访问方法org.apache.poi.util.POILogger.log - java.lang.IllegalAccessError: tried to access method org.apache.poi.util.POILogger.log from class org.apache.poi.openxml4j.opc.ZipPackage java.lang.IllegalAccessError:无法访问其超级接口 - java.lang.IllegalAccessError: cannot access its superinterface java.lang.IllegalAccessError: 试图访问方法 - java.lang.IllegalAccessError: tried to access method java.lang.IllegalAccessError:尝试从类Entity访问字段ConcreteEntity.instance - java.lang.IllegalAccessError: tried to access field ConcreteEntity.instance from class Entity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM