Coder Social home page Coder Social logo

quarkiverse / quarkus-poi Goto Github PK

View Code? Open in Web Editor NEW
12.0 6.0 3.0 241 KB

Apache POI is an API to access Microsoft Office files. This extension provides integration with Apache POI

Home Page: https://poi.apache.org/

License: Apache License 2.0

Java 100.00%
excel poi powerpoint quarkus-extension word

quarkus-poi's Introduction

Quarkus extension for Apache POI

All Contributors

Version

This is a Quarkus extension for Apache POI.

What is Apache POI?

Apache POI is a Java API for Microsoft Documents. It allows Java programs to read and write files in Microsoft Office formats, such as Word, Excel and PowerPoint. It also allows programs to create new files in these formats. It is an open source project and is available under the Apache License.

Apache POI is a project of the Apache Software Foundation.

What is Quarkus?

Quarkus is a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards.

How to use this extension?

Include the following dependency in your pom.xml:

<dependency>
    <groupId>io.quarkiverse.poi</groupId>
    <artifactId>quarkus-poi</artifactId>
    <version>${quarkus.poi.version}</version>
</dependency>

Features

This extension provides the following features:

  • Native image support
  • Support for Apache POI 5.2.3

Docker

When building native images in Docker using the standard Quarkus Docker configuration files some additional features need to be installed to support Apache POI. Specifically font information is not included in Red Hat's ubi-minimal images. To install it simply add these lines to your DockerFile.native file:

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9

######################### Set up environment for POI #############################
RUN microdnf update && microdnf install freetype fontconfig && microdnf clean all
######################### Set up environment for POI #############################

WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
# Shared objects to be dynamically loaded at runtime as needed,
COPY --chown=1001:root target/*.properties target/*.so /work/
COPY --chown=1001:root target/*-runner /work/application
# Permissions fix for Windows
RUN chmod "ugo+x" /work/application
EXPOSE 8080
USER 1001

CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

Caution

Make sure .dockerignore does not exclude .so files!

Contributors ✨

Thanks goes to these wonderful people (emoji key):

George Gastaldi
George Gastaldi

💻 🚧
Tomaž
Tomaž

💻 🚧
Melloware
Melloware

📖 🐛 💻
Michael Schilling
Michael Schilling

🐛 ⚠️
manofthepeace
manofthepeace

🐛
Giancarlo Calderón Cárdenas
Giancarlo Calderón Cárdenas

📖

This project follows the all-contributors specification. Contributions of any kind welcome!

quarkus-poi's People

Contributors

actions-user avatar allcontributors[bot] avatar dependabot[bot] avatar gastaldi avatar knuspertante avatar melloware avatar tpodg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

quarkus-poi's Issues

NPE in FontConfiguration.getVersion

I am using AutoSize Columns and getting this in Native mode.

XLSX:

2023-02-22 16:28:44,535 SEVERE [org.pri.app.exc.PrimeExceptionHandler] (executor-thread-5) java.lang.reflect.InvocationTargetException: java.lang.InternalError: java.lang.reflect.InvocationTargetException
        at [email protected]/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:87)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:168)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
        at [email protected]/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75)
        at [email protected]/java.awt.Font.getFont2D(Font.java:526)
        at [email protected]/java.awt.Font.canDisplayUpTo(Font.java:2282)
        at [email protected]/java.awt.font.TextLayout.singleFont(TextLayout.java:469)
        at [email protected]/java.awt.font.TextLayout.<init>(TextLayout.java:530)
        at org.apache.poi.ss.util.SheetUtil.getCellWidth(SheetUtil.java:224)
        at org.apache.poi.ss.util.SheetUtil.getCellWidth(SheetUtil.java:185)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidthForRow(SheetUtil.java:336)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:280)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:257)
        at org.apache.poi.xssf.streaming.SXSSFSheet.autoSizeColumn(SXSSFSheet.java:1621)
        at org.apache.poi.xssf.streaming.SXSSFSheet.autoSizeColumn(SXSSFSheet.java:1567)
 at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
Caused by: java.lang.reflect.InvocationTargetException
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at [email protected]/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85)
        ... 92 more
Caused by: java.lang.NullPointerException
        at [email protected]/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
        at [email protected]/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224)
        at [email protected]/sun.awt.FontConfiguration.init(FontConfiguration.java:106)
        at [email protected]/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706)
        at [email protected]/sun.font.SunFontManager$2.run(SunFontManager.java:358)
        at [email protected]/sun.font.SunFontManager$2.run(SunFontManager.java:315)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:168)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
        at [email protected]/sun.font.SunFontManager.<init>(SunFontManager.java:315)
        at [email protected]/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
        at [email protected]/sun.awt.X11FontManager.<init>(X11FontManager.java:56)

XLS:

2023-02-22 16:31:07,717 SEVERE [org.pri.app.exc.PrimeExceptionHandler] (executor-thread-5) java.lang.reflect.InvocationTargetException: java.lang.InternalError: java.lang.reflect.InvocationTargetException
        at [email protected]/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:87)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:168)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
        at [email protected]/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:75)
        at [email protected]/java.awt.Font.getFont2D(Font.java:526)
        at [email protected]/java.awt.Font.canDisplayUpTo(Font.java:2282)
        at [email protected]/java.awt.font.TextLayout.singleFont(TextLayout.java:469)
        at [email protected]/java.awt.font.TextLayout.<init>(TextLayout.java:530)
        at org.apache.poi.ss.util.SheetUtil.getCellWidth(SheetUtil.java:224)
        at org.apache.poi.ss.util.SheetUtil.getCellWidth(SheetUtil.java:185)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidthForRow(SheetUtil.java:336)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:280)
        at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:257)
        at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:2298)
        at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:2280)
 at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:203)
Caused by: java.lang.reflect.InvocationTargetException
        at [email protected]/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at [email protected]/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
        at [email protected]/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:85)
        ... 92 more
Caused by: java.lang.NullPointerException
        at [email protected]/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
        at [email protected]/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:224)
        at [email protected]/sun.awt.FontConfiguration.init(FontConfiguration.java:106)
        at [email protected]/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:706)
        at [email protected]/sun.font.SunFontManager$2.run(SunFontManager.java:358)
        at [email protected]/sun.font.SunFontManager$2.run(SunFontManager.java:315)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:168)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
        at [email protected]/sun.font.SunFontManager.<init>(SunFontManager.java:315)
        at [email protected]/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
        at [email protected]/sun.awt.X11FontManager.<init>(X11FontManager.java:56)

Dockerfile doesn't correctly build

By using the Dockerfile from the README.md as a guide to edit latest Dockerfile.native or Dockerfile.micro-native from Quarkus 3

  • Env:
    Windows 11
    Podman 4.9.4 (inside WSL)
    Powershell 7.4.2

  • Commands:

./mvnw package -Dnative "-Dquarkus.native.container-build=true"
podman build -f src/main/docker/Dockerfile.native -t <redacted> .
  • Dockerfile.native:
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9

######################### Set up environment for POI #############################
RUN microdnf update && microdnf install freetype fontconfig && microdnf clean all
######################### Set up environment for POI #############################

WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
# Shared objects to be dynamically loaded at runtime as needed,
COPY --chown=1001:root target/*.properties target/*.so /work/
COPY --chown=1001:root target/*-runner /work/application
# Permissions fix for Windows
RUN chmod "ugo+x" /work/application
EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
  • target folder:
    image

  • Full Log:

podman build -f src/main/docker/Dockerfile.native -t test-native-poi .
STEP 1/10: FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9
STEP 2/10: RUN microdnf update && microdnf install freetype fontconfig && microdnf clean all
--> Using cache 5e40506b4381604c154c7cdc007bdc2c9ec03734164da3fe257f3183331c07d1
--> 5e40506b4381
STEP 3/10: WORKDIR /work/
--> Using cache 5c66e4f6134929771a404e0978c4a537b3b23520b59d0c4614d3112d573fb059
--> 5c66e4f61349
STEP 4/10: RUN chown 1001 /work     && chmod "g+rwX" /work     && chown 1001:root /work
--> Using cache 83770f7be1e980ffb721efbf16ff0d3ac1ff374ae61cd0e95a34333c00417351
--> 83770f7be1e9
STEP 5/10: COPY --chown=1001:root target/*.properties target/*.so /work/
Error: building at STEP "COPY --chown=1001:root target/*.properties target/*.so /work/": checking on sources under "/var/tmp/libpod_builder2608102444/build": Rel: can't make  relative to /var/tmp/libpod_builder2608102444/build; copier: stat: ["/target/*.properties" "/target/*.so"]: no such file or directory

Additional Information:

I also found https://quarkus.io/guides/quarkus-runtime-base-image#extending-the-image, which worked without issues. I'm just not sure if I should use the "full AWT support", if there is any optimization that can be done or if I must use the .so files generated at build time.

Working Dockerfile.native:

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9 AS BUILD
RUN microdnf install freetype fontconfig

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9

COPY --from=BUILD \
    /lib64/libfreetype.so.6 \
    /lib64/libgcc_s.so.1 \
    /lib64/libbz2.so.1 \
    /lib64/libpng16.so.16 \
    /lib64/libm.so.6 \
    /lib64/libbz2.so.1 \
    /lib64/libexpat.so.1 \
    /lib64/libuuid.so.1 \
    /lib64/

COPY --from=BUILD \
    /usr/lib64/libfontconfig.so.1 \
    /usr/lib64/

COPY --from=BUILD \
    /usr/share/fonts /usr/share/fonts

COPY --from=BUILD \
    /usr/share/fontconfig /usr/share/fontconfig

COPY --from=BUILD \
    /usr/lib/fontconfig /usr/lib/fontconfig

COPY --from=BUILD \
    /etc/fonts /etc/fonts

WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

# Permissions fix for Windows
RUN chmod "ugo+x" /work/application

EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

Working Dockerfile.micro-native:

FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9 AS BUILD
RUN microdnf install freetype fontconfig

FROM quay.io/quarkus/quarkus-micro-image:2.0

COPY --from=BUILD \
    /lib64/libfreetype.so.6 \
    /lib64/libgcc_s.so.1 \
    /lib64/libbz2.so.1 \
    /lib64/libpng16.so.16 \
    /lib64/libm.so.6 \
    /lib64/libbz2.so.1 \
    /lib64/libexpat.so.1 \
    /lib64/libuuid.so.1 \
    /lib64/

COPY --from=BUILD \
    /usr/lib64/libfontconfig.so.1 \
    /usr/lib64/

COPY --from=BUILD \
    /usr/share/fonts /usr/share/fonts

COPY --from=BUILD \
    /usr/share/fontconfig /usr/share/fontconfig

COPY --from=BUILD \
    /usr/lib/fontconfig /usr/lib/fontconfig

COPY --from=BUILD \
    /etc/fonts /etc/fonts

WORKDIR /work/
RUN chown 1001 /work \
    && chmod "g+rwX" /work \
    && chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

# Permissions fix for Windows
RUN chmod "ugo+x" /work/application

EXPOSE 8080
USER 1001

ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

java.lang.NoSuchMethodError: 'org.apache.logging.log4j.LogBuilder org.apache.logging.log4j.Logger.atDebug()

Quarkus 3.0 , I use poi to hander excel file , quarkus logging implements is jboss logging , poi is log4j-api 2.18.0 ,

at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.parseRelationshipsPart(PackageRelationshipCollection.java:309)
	at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:160)
	at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:130)
	at org.apache.poi.openxml4j.opc.PackagePart.loadRelationships(PackagePart.java:565)
	at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:751)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:322)
	at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:59)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:290)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:286)

DevUI: Updates in Beta2

Beta2 contains a major refactor of DevUI I am creating this placeholder to fix our Dev UI card here when its released.

Page pointed to by guide link does not exist

I notice that the quarkus extension yaml points to https://quarkiverse.github.io/quarkiverse-docs/poi/dev/ as the guides link, but that page doesn't exist. That's causing a dead link on https://quarkus.io/extensions (the quarkus-poi page isn't live, because we block publication if there's a dead link).

Could we please either

  • Add this extension to Antora in the quarkiverse docs repo (quarkiverse/quarkiverse-docs@32b93f3 has an example of how to do it)
  • Switch the link in the extension yaml to point to this repository's readme, and do a new release

I'd do it, but I don't know which is best for this extension.

NoSuchMethodException: org.apache.logging.log4j.message.ReusableMessageFactory

When you have a sheet and you enable the following:

wb.getCreationHelper().createFormulaEvaluator().evaluateAll();

Then you will get a the following error:

"exception": { "refId": 3, "exceptionType": "java.lang.NoSuchMethodException", "message": "org.apache.logging.log4j.message.ReusableMessageFactory.<init>()", "frames": [ { "class": "java.lang.Class", "method": "getConstructor0", "line": 3585 }, { "class": "java.lang.Class", "method": "newInstance", "line": 626 }, { "class": "org.apache.logging.log4j.spi.AbstractLogger", "method": "createDefaultMessageFactory", "line": 228 }, { "class": "org.apache.logging.log4j.spi.AbstractLogger", "method": "<init>", "line": 143 }, { "class": "org.jboss.logmanager.log4j.JBossLogger", "method": "<init>", "line": 48 }, { "class": "org.jboss.logmanager.log4j.JBossLoggerContext", "method": "getLogger", "line": 72 }, { "class": "org.jboss.logmanager.log4j.JBossLoggerContext", "method": "getLogger", "line": 62 }, { "class": "org.apache.logging.log4j.LogManager", "method": "getLogger", "line": 666 }, { "class": "org.apache.poi.ss.formula.WorkbookEvaluator", "method": "<init>", "line": 81 }, { "class": "org.apache.poi.ss.formula.WorkbookEvaluator", "method": "<init>", "line": 89 }, { "class": "org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator", "method": "<init>", "line": 41 }, { "class": "org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator", "method": "<init>", "line": 38 }, { "class": "org.apache.poi.xssf.usermodel.XSSFCreationHelper", "method": "createFormulaEvaluator", "line": 84 }, { "class": "org.apache.poi.xssf.usermodel.XSSFCreationHelper", "method": "createFormulaEvaluator", "line": 32 },

I think the fix is something like this for me. But could you also support this in your plugin?

[
  {
    "name": "org.apache.logging.log4j.message.ReusableMessageFactory",
    "allDeclaredConstructors": true,
    "allPublicConstructors": true,
    "allDeclaredMethods": true,
    "allPublicMethods": true,
    "allDeclaredFields": true,
    "allPublicFields": true
  },
  {
    "name": "org.apache.logging.log4j.message.DefaultFlowMessageFactory",
    "allDeclaredConstructors": true,
    "allPublicConstructors": true,
    "allDeclaredMethods": true,
    "allPublicMethods": true,
    "allDeclaredFields": true,
    "allPublicFields": true
  }
]

Seems like the same issue : quarkusio/quarkus#13575

registerXMLBeansClassesForReflection Error

Hello, I have a small quarkus application that the only thing it does is enable an endpoint in which to obtain an excel file. At first I have used apache POI directly and everything works correctly for me. I wanted to try using quarkus-poi, but it gives me the following error:
Execution failed for task ':quarkusBuild'.

io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkiverse.poi.deployment.POIProcessor#registerXMLBeansClassesForReflection threw an exception: java.lang.NoSuchMethodError: 'java.util.Collection org.jboss.jandex.IndexView.getAllKnownImplementors(java.lang.Class)'
at io.quarkiverse.poi.deployment.POIProcessor.registerXMLBeansClassesForReflection(POIProcessor.java:54)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....

The resource:

@path("/hello")
public class GreetingResource {

@Inject
FicherosService ficherosService;

@Path("/export")
    @GET
    public Response exportAllData() throws IOException {
	   ByteArrayInputStream stream = ficherosService.exportData();    	
	   Response.ResponseBuilder response = Response.ok(stream);
	   response.header(String.valueOf(HttpHeaders.CONTENT_DISPOSITION), "attachment; filename=aplicaciones.xlsx");    	
   return response.build();
}

}

The service class:

@ApplicationScoped
public class FicheroServiceImpl implements FicherosService {

@Override
public ByteArrayInputStream exportData() throws IOException {
	String[] columns = {"Id", "Nombre", "Url"};
	Workbook workbook = new HSSFWorkbook();
	ByteArrayOutputStream stream = new ByteArrayOutputStream();
	Sheet sheet = workbook.createSheet("Lista negra");
	Row row = sheet.createRow(0);
	for(int i=0; i<columns.length; i++) {
		Cell cell = row.createCell(i);
		cell.setCellValue(columns[i]);
	}
	List<Aplicaciones> aplicaciones = Arrays.asList(
			new Aplicaciones(1L, "AAAAAAAAAAAAAAAAAAA", "dd", false),
			new Aplicaciones(2L, "BBBBBBBBBBBBBBBBBBBB", "22", false),
			new Aplicaciones(3L, "CCCCCCCCCC", "", false),
			new Aplicaciones(4L, "DDDDDDDDDDDDD", "", false),
			new Aplicaciones(5L, "EEEEEEEEEEEEEEEEEE", "ff", false),
			new Aplicaciones(6L, "FFFFFFFFFFFFFFFFFFFFF", "", false)
	);
	int initRow = 1;
	for(Aplicaciones app: aplicaciones) {
		row = sheet.createRow(initRow);
		row.createCell(0).setCellValue(app.getId());
		row.createCell(1).setCellValue(app.getName());
		row.createCell(2).setCellValue(app.getUrl());
		initRow++;
	}
	workbook.write(stream);
	workbook.close();
	return new ByteArrayInputStream(stream.toByteArray());
}

}

And model class called Aplicaciones with its constructors, attributes and its getters and setters.
What am I missing or what am I doing wrong?

Setting Auto filter leads to "resource 'functionMetadataCetab.txt' not found

HI Hello:

When i perform sheet.setAutoFilter(new CellRangeAddress(0, 0, 0,10)); on my excel it fails with the following in native mode:

"exception": {
"refId": 1,
"exceptionType": "java.lang.RuntimeException",
"message": "resource 'functionMetadataCetab.txt' not found",
"frames": [
{
"class": "org.apache.poi.ss.formula.function.FunctionMetadataReader",
"method": "readResourceFile",
"line": 88
},
{
"class": "org.apache.poi.ss.formula.function.FunctionMetadataReader",
"method": "createRegistryCetab",
"line": 81
},
{
"class": "org.apache.poi.ss.formula.function.FunctionMetadataRegistry",
"method": "getInstanceCetab",
"line": 53
},
{
"class": "org.apache.poi.ss.formula.function.FunctionMetadataRegistry",
"method": "getFunctionByName",
"line": 104
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "isValidCellReference",
"line": 1289
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "parseSimpleRangePart",
"line": 1047
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "parseRangeable",
"line": 478
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "parseRangeExpression",
"line": 327
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "parseSimpleFactor",
"line": 1556
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "percentFactor",
"line": 1514
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "powerFactor",
"line": 1501
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "Term",
"line": 1875
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "additiveExpression",
"line": 2002
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "concatExpression",
"line": 1986
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "comparisonExpression",
"line": 1943
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "intersectionExpression",
"line": 1916
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "unionExpression",
"line": 1897
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "parse",
"line": 2044
},
{
"class": "org.apache.poi.ss.formula.FormulaParser",
"method": "parse",
"line": 175
},
{
"class": "org.apache.poi.xssf.usermodel.XSSFName",
"method": "setRefersToFormula",
"line": 200
},
{
"class": "org.apache.poi.xssf.usermodel.XSSFSheet",
"method": "setAutoFilter",
"line": 4275
},
{
"class": "org.apache.poi.xssf.usermodel.XSSFSheet",
"method": "setAutoFilter",
"line": 78

Context:

Quarkus: 2.16.5
Apache Poi: 1.0.3
Java: 17

Bug: unwanted build-time third-party classes on classpath cause failure with bean validation supported by Hibernate validator.

Concern

The quarkus-poi extension transitively relies on org.apache.xmlbeans:xmlbeans dependency which exposes runtime and build-time classes. This can cause failures at build-time, or in devmode when reloading, with an application that uses the quarkus-poi extension and does bean validation using the hibernate-validation extension.

More generally, this problem can happen with any constellation which includes the hibernate-validation extension, one Quarkus extension that depends on the org.apache.xmlbeans:xmlbeans dependency, and one DTO class to be validated that has a connection with the AbstractCollection class.

More details

The HibernateValidatorProcessor class recursively scans every class to be validated including their fields to be validated, their subclasses and superclass. Once it recursively meets the AbstractCollection class, it scans every specialization, consequently, it can recursively meets classes from org.apache.xmlbeans, for example the XMLBean$ErrorLogger one, which parent, the XMLBean class, extends the org.apache.tools.ant.taskdefs.MatchingTask build-time class. This latter is not per default on the classpath and then, the Quarkus application fails at build-time and on reload in devmode.

Reproducer

  1. To create an empty Quarkus application.
  2. To declare both quarkus-poi and hibernate-validation extensions in the pom.xml.
  3. To define a DTO class to be validated and that defines a field to be validated of type AbstractCollection.
  4. To annotate both the DTO class and its field with the @Valid annotation.
@Valid
public class Dto {
    String name;
    @Valid
    AbstractCollection<String> items;
}
<dependencies>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-arc</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-hibernate-validator</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkiverse.poi</groupId>
        <artifactId>quarkus-poi</artifactId>
        <version>2.0.5</version>
    </dependency>
</dependencies>

Variants

  • To undeclare the quarkus-poi extensions in the pom.xml, and to check that it builds and restart without failure; it works because the org.apache.xmlbeans dependency is no more transitively present on the classpath.
  • To remove the @Valid annotation from the field; it works because no recursion is done on the field anymore.
  • To explicitly add the org.apache.ant:ant dependency in the pom.xml; it works because the MatchingTask class is present on the classpath. This is not an acceptable and sustainable solution.

Native-Image Schema is missing: org.apache.poi.schemas.ooxml.system.ooxml.shapelayoutelement

Hey,

first, thanks for your amazing work!

Currently I try to upgrade to quarkus 3 with quarkiverse.tika 2.2 and quarkiverse.poi 2.2.

Until now I used quarkus 2, quarkiverse.tike 1.X and poi (but not as quarkus extension). Thats why I had to used native-image tracing agent to getter native-image configs. Hope this extension will now make this obsolete.

I process mainly excel files. In JVM mode all my testfiles works with this extension. In native mode unfortunately one file couldn't process and throws this error:

Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource org/apache/poi/schemas/ooxml/system/ooxml/shapelayoutelement.xsb (org.apache.poi.schemas.ooxml.system.ooxml.shapelayoutelement) - code 0
        at org.apache.xmlbeans.impl.schema.XsbReader.<init>(XsbReader.java:63)
        at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.resolveHandle(SchemaTypeSystemImpl.java:931)
        at org.apache.xmlbeans.SchemaComponent$Ref.getComponent(SchemaComponent.java:111)
        at org.apache.xmlbeans.SchemaGlobalElement$Ref.get(SchemaGlobalElement.java:74)
        at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.findElement(SchemaTypeLoaderBase.java:103)
        at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:993)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:879)
        at org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1597)
        at org.apache.xmlbeans.impl.store.Cur.getUser(Cur.java:2571)
        at org.apache.xmlbeans.impl.store.Cur.getObject(Cur.java:2565)
        at org.apache.xmlbeans.impl.store.Cursor._getObject(Cursor.java:814)
        at org.apache.xmlbeans.impl.store.Cursor.syncWrapHelper(Cursor.java:2529)
        at org.apache.xmlbeans.impl.store.Cursor.syncWrap(Cursor.java:2460)
        at org.apache.xmlbeans.impl.store.Cursor.getObject(Cursor.java:2086)
        at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.read(XSSFVMLDrawing.java:155)
        at org.apache.poi.xssf.usermodel.XSSFVMLDrawing.<init>(XSSFVMLDrawing.java:123)
        at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61)
        at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:661)
        at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:678)
        at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:165)
        at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:260)
        at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:118)
        at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:98)
        at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.create(XSSFWorkbookFactory.java:36)
        at org.apache.poi.ss.usermodel.WorkbookFactory.lambda$create$2(WorkbookFactory.java:224)
        at org.apache.poi.ss.usermodel.WorkbookFactory.wp(WorkbookFactory.java:329)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:224)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:185)
        at io.quarkiverse.poi.it.POIResource.specialFile(POIResource.java:123)
        at io.quarkiverse.poi.it.POIResource_ClientProxy.specialFile(Unknown Source)
        at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:408)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:69)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        ... 17 more

As described here: https://poi.apache.org/help/faq.html XMLBeans should be compiled and available through poi-ooxml-full jar

To use the new OOXML file formats, POI requires a jar containing the file format XSDs, as compiled by XMLBeans. These XSDs, once compiled into Java classes, live in the org.openxmlformats.schemas namespace.

I don't know if this is the right (or the right schema), but when I debug my test (could be used also as reproducer), the following schemas are available in POIProcessor#registerXMLBeansClassesForReflection

  • com.microsoft.schemas.office.office.impl.CTShapeLayoutImpl
  • com.microsoft.schemas.office.office.impl.ShapelayoutDocumentImpl

Reproduce:

  1. clone https://github.com/knuspertante/quarkus-poi/tree/bug/shapelayoutelement
  2. mvn clean verify -Pnative-image

Thanks for your help!

Native Image Issue org.apache.poi.xssf.model.SharedStringsTable

Getting this error using this POI deployment.

I am working on my Extension: https://github.com/quarkiverse/quarkus-primefaces

Getting the following error from POI when building native image

20:59:57,565 INFO  [org.apa.myf.web.StartupServletContextListener] MyFaces Core has started, it took [2946] ms.
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
[2/7] Performing analysis...  [*]                                                                      (232.5s @ 2.01GB)
  24,580 (90.07%) of 27,290 classes reachable
  32,004 (59.82%) of 53,503 fields reachable
 104,513 (36.65%) of 285,141 methods reachable
   4,875 classes, 4,195 fields, and 17,175 methods registered for reflection
       3 native libraries: freetype, m, stdc++

Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error encountered while parsing org.apache.poi.xssf.model.SharedStringsTable.<clinit>() 
Parsing context: <no parsing context available> 

	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.AnalysisError.parsingError(AnalysisError.java:153)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:104)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.ensureFlowsGraphCreated(MethodTypeFlow.java:83)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.getOrCreateMethodFlowsGraph(MethodTypeFlow.java:65)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.typestate.DefaultAnalysisPolicy.staticRootMethodGraph(DefaultAnalysisPolicy.java:182)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis.lambda$addRootMethod$0(PointsToAnalysis.java:320)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.PointsToAnalysis$2.run(PointsToAnalysis.java:507)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:193)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:177)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: org.apache.xmlbeans.XmlOptions.put(java.lang.Object). This error is reported at image build time because class org.apache.poi.xssf.model.SharedStringsTable is registered for linking at image build time by command line
	at parsing org.apache.poi.xssf.model.SharedStringsTable.<clinit>(SharedStringsTable.java:94)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.throwParserError(BytecodeParser.java:2518)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.throwParserError(SharedGraphBuilderPhase.java:110)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3393)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.handleBytecodeBlock(BytecodeParser.java:3345)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:3190)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.build(BytecodeParser.java:1138)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.buildRootMethod(BytecodeParser.java:1030)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.GraphBuilderPhase$Instance.run(GraphBuilderPhase.java:97)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase.run(SharedGraphBuilderPhase.java:84)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.run(Phase.java:49)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:446)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:42)
	at jdk.internal.vm.compiler/org.graalvm.compiler.phases.Phase.apply(Phase.java:38)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.AnalysisParsedGraph.parseBytecode(AnalysisParsedGraph.java:135)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisMethod.ensureGraphParsed(AnalysisMethod.java:685)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.parse(MethodTypeFlowBuilder.java:171)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlowBuilder.apply(MethodTypeFlowBuilder.java:349)
	at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.flow.MethodTypeFlow.createFlowsGraph(MethodTypeFlow.java:93)
	... 13 more
Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: org.apache.xmlbeans.XmlOptions.put(java.lang.Object). This error is reported at image build time because class org.apache.poi.xssf.model.SharedStringsTable is registered for linking at image build time by command line
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.reportUnresolvedElement(SharedGraphBuilderPhase.java:333)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedMethod(SharedGraphBuilderPhase.java:323)
	at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.phases.SharedGraphBuilderPhase$SharedBytecodeParser.handleUnresolvedInvoke(SharedGraphBuilderPhase.java:279)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.genInvokeVirtual(BytecodeParser.java:1721)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.processBytecode(BytecodeParser.java:5286)
	at jdk.internal.vm.compiler/org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:3[385](https://github.com/quarkiverse/quarkus-primefaces/actions/runs/4207468288/jobs/7302300187#step:6:386))
	... 28 more

Dev UI: Add Card

I am working on adding new Dev UI card for this library which I think will be a common pattern for a lot of libraries. I like to know which version without digging through POM files of the library itself not the extension is loaded.

image

giving error 'Could not initialize class' in native image

in pom.xml I've:

io.quarkiverse.poi:quarkus-poi:2.0.5

when running on native image, an error will occur

2024-01-19 05:44:13,746 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-8) HTTP Request to /api/apps/27/items/164:exportData failed, error id: 97bfd904-7986-4988-ac14-bbefb0ae1a60-1: java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
        at [email protected]/java.awt.Color.<clinit>(Color.java:277)
        at org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined.<init>(HSSFColor.java:113)
        at org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined.<clinit>(HSSFColor.java:55)
        at org.apache.poi.hssf.model.InternalWorkbook.createExtendedFormat(InternalWorkbook.java:1385)
        at org.apache.poi.hssf.model.InternalWorkbook.createCellXF(InternalWorkbook.java:871)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.createCellStyle(HSSFWorkbook.java:1297)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.createCellStyle(HSSFWorkbook.java:124)
        at tech.wetech.metacode.infrastructure.poi.ExcelDataExporter.title(ExcelDataExporter.java:245)
        at tech.wetech.metacode.infrastructure.poi.ExcelDataExporter.writeSheet(ExcelDataExporter.java:152)
        at tech.wetech.metacode.infrastructure.poi.ExcelDataExporter.exportAppItemData(ExcelDataExporter.java:86)
        at tech.wetech.metacode.application.AppApplicationService.exportAppItemData(AppApplicationService.java:316)
        at tech.wetech.metacode.application.AppApplicationService_Subclass.exportAppItemData$$superforward(Unknown Source)
        at tech.wetech.metacode.application.AppApplicationService_Subclass$$function$$1.apply(Unknown Source)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:73)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:62)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:136)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:107)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:61)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(Unknown Source)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:30)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:27)
        at tech.wetech.metacode.application.AppApplicationService_Subclass.exportAppItemData(Unknown Source)
        at tech.wetech.metacode.application.AppApplicationService_ClientProxy.exportAppItemData(Unknown Source)
        at tech.wetech.metacode.api.AppResource.exportAppItemData(AppResource.java:118)
        at tech.wetech.metacode.api.AppResource$quarkusrestinvoker$exportAppItemData_d6a1e4c98c92f1217fa6da146bf63aa114036809.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:832)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)

2024-01-19 05:44:25,605 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-8) HTTP Request to /api/apps/27/items/164:exportData failed, error id: 97bfd904-7986-4988-ac14-bbefb0ae1a60-2: java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.hssf.util.HSSFColor$HSSFColorPredefined
        at org.apache.poi.hssf.model.InternalWorkbook.createExtendedFormat(InternalWorkbook.java:1385)
        at org.apache.poi.hssf.model.InternalWorkbook.createCellXF(InternalWorkbook.java:871)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.createCellStyle(HSSFWorkbook.java:1297)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.createCellStyle(HSSFWorkbook.java:124)
        at tech.wetech.metacode.infrastructure.poi.ExcelDataExporter.title(ExcelDataExporter.java:245)
        at tech.wetech.metacode.infrastructure.poi.ExcelDataExporter.writeSheet(ExcelDataExporter.java:152)
        at tech.wetech.metacode.infrastructure.poi.ExcelDataExporter.exportAppItemData(ExcelDataExporter.java:86)
        at tech.wetech.metacode.application.AppApplicationService.exportAppItemData(AppApplicationService.java:316)
        at tech.wetech.metacode.application.AppApplicationService_Subclass.exportAppItemData$$superforward(Unknown Source)
        at tech.wetech.metacode.application.AppApplicationService_Subclass$$function$$1.apply(Unknown Source)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:73)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:62)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:136)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:107)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:61)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
        at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(Unknown Source)
        at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
        at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:30)
        at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:27)
        at tech.wetech.metacode.application.AppApplicationService_Subclass.exportAppItemData(Unknown Source)
        at tech.wetech.metacode.application.AppApplicationService_ClientProxy.exportAppItemData(Unknown Source)
        at tech.wetech.metacode.api.AppResource.exportAppItemData(AppResource.java:118)
        at tech.wetech.metacode.api.AppResource$quarkusrestinvoker$exportAppItemData_d6a1e4c98c92f1217fa6da146bf63aa114036809.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at [email protected]/java.lang.Thread.runWith(Thread.java:1596)
        at [email protected]/java.lang.Thread.run(Thread.java:1583)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:832)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)

when I'm running my project without native image it is running fine.

Output of java -version
21

Quarkus version or git rev
3.6.3

Build tool (ie. output of mvnw --version or gradlew --version)
Apache Maven 3.9.5

poi extension Build native image error

Describe the bug
In my work, I needed to export data to excel, so I adopted quarkus-poi, and there were no errors during the test. When building a local executable, "Windows AWT integration is not ready in native images and Java" is thrown. Lang. UnsatisfiedLinkError: There is no awt in java.library.path.'. But I only want to use excel related functions in poi, not AWT related functions.

Expected behavior
Expect the behavior to build successfully because I'm not going to use the awt functionality

Actual behavior
Building a native executable throws:'Windows AWT integration is not ready in native-image and would result in java.lang.UnsatisfiedLinkError: no awt in java.library.path.'

How to Reproduce?
1:Import the poi extension
io.quarkiverse.poi quarkus-poi 2.0.3
2:mvnw package -Dnative

Output of uname -a or ver
Microsoft Windows [版本 10.0.19045.3570]

Output of java -version
openjdk version "17.0.6" 2023-01-17 OpenJDK Runtime Environment GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13) OpenJDK 64-Bit Server VM GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13, mixed mode, sharing)

Mandrel or GraalVM version (if different from Java)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13, mixed mode, sharing)

Quarkus version or git rev
3.2.0.Final

Build tool (ie. output of mvnw --version or gradlew --version)
Apache Maven 3.9.2 (c9616018c7a021c1c39be70fb2843d6f5f9b8a1c)
Maven home: D:\apache-maven-3.9.2
Java version: 17.0.6, vendor: GraalVM Community, runtime: D:\graalvm-ce-java17-22.3.1
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information
io.quarkiverse.poi quarkus-poi 2.0.3

Request for information: Fontconfig head is null, check your fonts or fonts configuration

Do you happen what i can do to fix this issue below?

exception": {
"refId": 1,
"exceptionType": "java.lang.RuntimeException",
"message": "Fontconfig head is null, check your fonts or fonts configuration",
"frames": [
{
"class": "sun.awt.FontConfiguration",
"method": "getVersion",
"line": 1263
},
{
"class": "sun.awt.FontConfiguration",
"method": "readFontConfigFile",
"line": 221
},
{
"class": "sun.awt.FontConfiguration",
"method": "init",
"line": 105
},
{
"class": "sun.awt.X11FontManager",
"method": "createFontConfiguration",
"line": 696
},
{
"class": "sun.font.SunFontManager$2",
"method": "run",
"line": 352
},
{
"class": "sun.font.SunFontManager$2",
"method": "run",
"line": 309
},
{
"class": "java.security.AccessController",
"method": "executePrivileged",
"line": 129
},
{
"class": "java.security.AccessController",
"method": "doPrivileged",
"line": 319
},
{
"class": "sun.font.SunFontManager",
"method": "",
"line": 309
},
{
"class": "sun.awt.FcFontManager",
"method": "",
"line": 35
},
{
"class": "sun.awt.X11FontManager",
"method": "",
"line": 55
},
{
"class": "sun.font.PlatformFontInfo",
"method": "createFontManager",
"line": 37
},
{
"class": "sun.font.FontManagerFactory",
"method": "getInstance",
"line": 51
},
{
"class": "java.awt.Font",
"method": "getFont2D",
"line": 526
},
{
"class": "java.awt.Font",
"method": "canDisplayUpTo",
"line": 2278
},
{
"class": "java.awt.font.TextLayout",
"method": "singleFont",
"line": 469
},
{
"class": "java.awt.font.TextLayout",
"method": "",
"line": 530
},
{
"class": "org.apache.poi.ss.util.SheetUtil",
"method": "getDefaultCharWidthAsFloat",
"line": 352
},
{
"class": "org.apache.poi.ss.util.SheetUtil",
"method": "getColumnWidth",
"line": 310
},
{
"class": "org.apache.poi.ss.util.SheetUtil",
"method": "getColumnWidth",
"line": 294
},
{
"class": "org.apache.poi.xssf.usermodel.XSSFSheet",
"method": "autoSizeColumn",
"line": 497
},
{
"class": "org.apache.poi.xssf.usermodel.XSSFSheet",
"method": "autoSizeColumn",
"line": 479
},
{
"class": "com.nn.aav.insurance.business.reporting.control.ExcelSupport",
"method": "createExcelColumns",
"line": 91
},
{
"class": "com.nn.aav.insurance.business.reporting.control.ExcelSupport",
"method": "csvToExcelReport",
"line": 60
},
{
"class": "com.nn.aav.insurance.business.reporting.control.IndependerReportRepository",
"method": "createReportForSource",
"line": 85
},
{
"class": "com.nn.aav.insurance.business.reporting.control.IndependerReportRepository",
"method": "createReportForSourceIfNotComplete",
"line": 73
},
{
"class": "com.nn.aav.insurance.business.reporting.boundary.IndependerInsuranceRequestResultReporter",
"method": "lambda$handleRequest$0",
"line": 35
},
{
"class": "java.lang.Iterable",
"method": "forEach",
"line": 75
},
{
"class": "com.nn.aav.insurance.business.reporting.boundary.IndependerInsuranceRequestResultReporter",
"method": "handleRequest",
"line": 32
},
{
"class": "com.nn.aav.insurance.business.reporting.boundary.IndependerInsuranceRequestResultReporter",
"method": "handleRequest",
"line": 17
},
{
"class": "io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder$1",
"method": "processRequest",
"line": 167
},
{
"class": "io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop$1",
"method": "run",
"line": 142
},
{
"class": "java.lang.Thread",
"method": "runWith",
"line": 1596
},
{
"class": "java.lang.Thread",
"method": "run",
"line": 1583
},
{
"class": "com.oracle.svm.core.thread.PlatformThreads",
"method": "threadStartRoutine",
"line": 833
},
{
"class": "com.oracle.svm.core.posix.thread.PosixPlatformThreads",
"method": "pthreadStartRoutine",
"line": 211
}
]
}
}

This in a native quarkus application using version 3.8.2. It's running in AWS as lambda using the latest runtime. I am using Java 21!. I think the latest runtime in AWS does not support fonts anymore.

I will try to set system prop: org.apache.poi.ss.ignoreMissingFontSystem

If this prop works can this also be added as configuration option for quarkus-poi?

Failed to index com.github.javaparser.ast.body.(ClassOrInterfaceDeclaration|MethodDeclaration) if quarkus-poi is present

If quarkus-poi is present as a dependency, you will receive the following message:

Failed to index com.github.javaparser.ast.body.ClassOrInterfaceDeclaration: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: PROD for code-with-quarkus-1.0.0-SNAPSHOT@caa5298
Failed to index com.github.javaparser.ast.body.MethodDeclaration: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: PROD for code-with-quarkus-1.0.0-SNAPSHOT@caa5298

Reproducer

  1. Download reproducer.zip
  2. ./gradlew clean build --rerun-tasks

Is that problematic?

Error log about log4j2 when building native or runnin using quarkus:dev

I am developing an app that uses quarkus-poi, when I run (or perform a native build) I get the following

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

Adding the following dependency to my pom fixes the issue.

<dependency>
  <groupId>org.jboss.logmanager</groupId>
  <artifactId>log4j2-jboss-logmanager</artifactId>
</dependency>

Is that something that could be done within that project as written here; https://quarkus.io/guides/logging#add-a-logging-adapter-to-your-application

This step is unnecessary for libraries that are dependencies of a Quarkus extension where the extension handles it automatically.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.