Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在Java17 模块项目使用出现的问题 #245

Open
Ximeng0918 opened this issue Mar 2, 2025 · 7 comments
Open

在Java17 模块项目使用出现的问题 #245

Ximeng0918 opened this issue Mar 2, 2025 · 7 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Ximeng0918
Copy link

当在Java17 模块项目使用的时候,因需要使用POI的功能,所以显示显式声明 requires org.apache.poi.ooxml;
显式声明后执行就会报如下错误
java.lang.NoClassDefFoundError: Could not initialize class cn.idev.excel.write.handler.DefaultWriteHandlerLoader

@psxjoy
Copy link
Member

psxjoy commented Mar 2, 2025

This issue isn't related to fastexcel's compatibility with JDK17.
IMO, the problem stems from using different versions of poi dependencies in the project,
which is leading to jar conflicts and resulting errors.

@psxjoy psxjoy self-assigned this Mar 2, 2025
@psxjoy psxjoy added help wanted Extra attention is needed question Further information is requested labels Mar 2, 2025
@Ximeng0918
Copy link
Author

Ximeng0918 commented Mar 2, 2025

This issue isn't related to fastexcel's compatibility with JDK17. IMO, the problem stems from using different versions of poi dependencies in the project, which is leading to jar conflicts and resulting errors.

项目是一个小工具很小并没有使用很多依赖。
依赖列表:
javafx-controls:17.0.6
javafx-fxml:17.0.6
lombok:1.18.36
fastexcel:1.1.0
druid:1.2.24

module-info.java文件

module com.abc.tool {
    requires javafx.controls;
    requires javafx.fxml;

    requires static lombok;
    requires fastexcel.core;
    requires druid;
    requires java.sql;
    requires org.apache.poi.ooxml;  // 不加这个  运行没有问题

    opens com.abc.tool.util;
    opens com.abc.tool.model;
    opens com.abc.tool.views to javafx.fxml;
    exports com.abc.tool;
}

@psxjoy
Copy link
Member

psxjoy commented Mar 3, 2025 via email

@Ximeng0918
Copy link
Author

Could you provide a minimal reproducible demo?

Ximeng0918 @.***> 于2025年3月2日周日 23:07写道:

https://github.com/liu-demo/fast-excel-demo.git

@psxjoy
Copy link
Member

psxjoy commented Mar 4, 2025 via email

@Ximeng0918
Copy link
Author

Your demo cannot run successfully. error log

java: java.lang.NoSuchFieldError: Class
com.sun.tools.javac.tree.JCTree$JCImport does not have member field
'com.sun.tools.javac.tree.JCTree qualid'

Ximeng0918 @.***> 于2025年3月3日周一 23:13写道:

项目的JDK使用的 Java17

@psxjoy
Copy link
Member

psxjoy commented Mar 4, 2025

IMO, the issue stems from the Java Module System's access restrictions. To be precise, the org.apache.poi.ooxml module hasn't exposed the classes and fields within the org.apache.poi.xssf.streaming package to the fastexcel.core module. This leads to an InaccessibleObjectException when reflection is used to access those fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants