Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.aspose.cells.b.a.b.zh

@rselvarajan ,

We can produce the same exception on Alpine docker with openjdk17 installed:

# Start with the bare Alpine base image
FROM alpine:latest

# Set environment variables for Java
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk \
    PATH=$JAVA_HOME/bin:$PATH

# Install only the minimal OpenJDK 17 package
RUN apk add --no-cache openjdk17-jdk \
    && java -version

We tried to handle some exceptions, but it breaks lots of places which are related to Font while rendering text.
After installing packages fontconfig and ttf-dejavu, it works OK. We tried some solutions, but only this one works.

sure thanks for keeping updated on the solutions

@rselvarajan,

You are welcome. Please do what is necessary as suggested, and it will resolve your issue. Feel free to write back if you have any further queries or comments.

hi @amjad.sahi
am getting additional errors like below when trying to zip files with names like DE language characters like
“Berichtsübersicht”
com.aspose.cells.CellsException: Error for ZipFile
at com.aspose.cells.zbcu.a(Unknown Source)
at com.aspose.cells.a.f.zj.(Unknown Source)
at com.aspose.cells.a.f.zj.a(Unknown Source)
at com.aspose.cells.FileFormatUtil.a(Unknown Source)
at com.aspose.cells.FileFormatUtil.a(Unknown Source)
at com.aspose.cells.FileFormatUtil.detectFileFormat(Unknown Source)
at com.aspose.cells.CellsHelper.mergeFiles(Unknown Source)
at

Caused by: java.io.IOException: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /tmp/report/11EF-CD8B-9EF52A11-BD83-96E44B451C3C-1736318540/Berichtsübersicht-B63F5E9C-0FD9-42DA-91FF-3933813CDA02.xlsx
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1397)
at java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:716)
at java.base/java.util.zip.ZipFile.(ZipFile.java:250)
at java.base/java.util.zip.ZipFile.(ZipFile.java:179)
at java.base/java.util.zip.ZipFile.(ZipFile.java:150)
at com.aspose.cells.a.f.zf.(Unknown Source)
at com.aspose.cells.a.f.ze.a(Unknown Source)
… 21 more
Caused by: java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /tmp/report/11EF-CD8B-9EF52A11-BD83-96E44B451C3C-1736318540/Berichtsübersicht-B63F5E9C-0FD9-42DA-91FF-3933813CDA02.xlsx
at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:121)
at java.base/sun.nio.fs.UnixPath.(UnixPath.java:68)
at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
at java.base/java.io.File.toPath(File.java:2387)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1394)
… 27 more

am not sure which package is required for the above. I tried few packages like language-pack-de, locales but still same errror.

@rselvarajan
Would you like to provide your sample file and complete test code? We will check it soon.

hi @John.He Ours is proprietary code cannot be shared. you can try to generate file with any german characters like “Berichtsübersicht” as filename and then zipping. this will fail with java17

@rselvarajan

We have tested below code with our latest version 24.12 and it works fine without any exception:

CellsHelper.mergeFiles(new String[]{"Berichtsübersicht.xlsx","Berichtsübersicht2.xlsx"},null,"combined.xlsx");

Would you please try it at your end? Maybe you have other operations which may cause the mergeFiles() fail. If so, we are afraid we need your runnable code to reproduce the issue so we can figure the issue out.

Our code also similar only as given below.

sheetNames: [Berichtsübersicht, Transaktionsaggregat, Finanzielle Daten, Krypto, Generosity Network, Transaktionen, Glossar]

CellsHelper.mergeFiles(files.stream().map(f → f.getAbsolutePath()).toArray(String[]::new),
“cache”, reportDestination);

can you please try with aspose-cells-20.9.8 and java17 and check?

Also pasting the external link reference where it seems related to some locale setting - linux - java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters when using national characters - Stack Overflow

I tried the recommendation but still not successful

@rselvarajan,

We apologize, but we do not evaluate issues with older versions of the APIs, nor can we resolve any issues in those versions. The fixes are based on latest APIs set only. As suggested earlier, please upgrade to our latest version, Aspose.Cells for Java v24.12, as it functions properly on our side we tested.

HI @amjad.sahi we need to upgrade our license to incorporate new versions which is currently not planned by our organization. so we will have to use existing version only.

@rselvarajan,

We are sorry, but as we told you, it is difficult for us to evaluate issues in older versions and to fix them (if it is a bug or other limitations in the older versions).

HI @amjad.sahi
In the below notes, i could see the related error. can you please give more details

CELLSJAVA-43275 Aspose.Cell for Java 20.8 com.aspose.cells.CellsException: Error for ZipFile

@rselvarajan,

This was an internal issue but for other scenario (the case is not same with yours) reported by another developer working on other Aspose modules.
The exception (“com.aspose.cells.CellsException: Error for ZipFile”) was encountered but using the code segment:

com.aspose.cells.FileFormatInfo cellsFileFormatInfo =  com.aspose.cells.FileFormatUtil.detectFileFormat(new FileInputStream("sample01.xlsx));

@rselvarajan

We also tested 20.9.8 you attached and cannot find the exception. It can work fine and give the combined result. So we think the issue may be caused by some special settings of your environment. If so, it will be very difficult for us to trace such kind of issue.

Maybe at first you may test at your end whether your template file can be loaded correctly by Java’s Zip apis(without reference to our component). We think it is possible that your template file cannot be processed successfully with Java’s zip apis.

And anyways, you also can test our latest version in evaluation mode to check whether your issue can be solved.

Thanks for checking the issue. we also have one more person reported same issue when normal file load as well.
But what am looking for support from this forum is which package installation is required to avoid this issue in java17 environment. Tried few suggestions given in google but none is working. Please note we are manually installing fontconfig package so could it be related to some missing fonts.

@rselvarajan ,

We reviewed the code of aspose-cells-20.9.8 and the exception stack you shared, the exception is thrown at

new java.util.zip.ZipFile(String name)

However, we can’t reproduce the exception with the DE-filename you provided.

Please just try the above code with the path of your Excel files and let us know your feedback.

i tried the below code to check the charset.

String encoding = System.getProperty(“native.encoding”); // Populated on Java 18 and later
java.nio.charset.Charset cs = (encoding != null) ? java.nio.charset.Charset.forName(encoding) : java.nio.charset.Charset.defaultCharset();

Am getting response as US-ASCII

Can you please try with above settings? we are trying to override as UTF-8 but it seems we cant override in java17

@rselvarajan ,

Both java.nio.charset.Charset.forName(encoding) and java.nio.charset.Charset.defaultCharset() retrurn “UTF-8” on our side.

It seems that you have located the root cause. Please share more details. Also, please try new java.util.zip.ZipFile(String name) on your side.

@rselvarajan
We run the following code to test it on JDK1.8 and get"UTF-8" result. Perhaps you can consider upgrading the JDK version to solve the issue.

String encoding = System.getProperty("native.encoding"); // Populated on Java 18 and later
java.nio.charset.Charset cs = (encoding != null) ? java.nio.charset.Charset.forName(encoding) : java.nio.charset.Charset.defaultCharset();

System.out.println(cs.displayName());

The output:

UTF-8

Our organization currently uses only jdk 17 and we cannot have our own version of jdk. Can you please change your charset to US-ASCII and try if you could reproduce the issue.

Also we are getting error during mergeFiles as given below. but how does changing to “new java.util.zip.ZipFile(String name)” can help?
CellsHelper.mergeFiles(files.stream().map(f → f.getAbsolutePath()).toArray(String[]::new),
“cache”, reportDestination);

also which version of jdk you are currently using?