Comments (8)
com.sun.media.imageioimpl.plugins.pnm.PNMImageReader
I believe this is the JAI ImageIO PNM plugin from Sun/Oracle (ie. not the one from your dependencies above).
from twelvemonkeys.
Any idea how to resolve it ? @haraldk it's a blocker currently.
from twelvemonkeys.
This error has nothing to do with TwelveMonkeys or the sun plugin itself. The error gives the answer:
Caused by: java.lang.IllegalAccessError: class com.sun.media.imageioimpl.plugins.pnm.PNMImageReader (in unnamed module @0x48524010) cannot access class sun.security.action.GetPropertyAction (in module java.base) because module java.base does not export sun.security.action to unnamed module @0x48524010
This is caused by the Java Module System (introduced in Java 9) which became more strict in Java 17. Your code access an internal class, com.sun.media.imageioimpl.plugins.pnm.PNMImageReader
which you never should do.
For details and how to fix it, see https://blogs.oracle.com/javamagazine/post/a-peek-into-java-17-continuing-the-drive-to-encapsulate-the-java-runtime-internals
from twelvemonkeys.
@rmuller I somewhat understand that, but the error was thrown specifically at the line ImageIO.read(inputStream).... but what's stranger is that I didn't change anything, and now the code runs fine on my local. Will test it out on the server... but it's more scary as a developer that something fails, and it automatically starts working fine the next day, without any change :-)
from twelvemonkeys.
@rmuller Thanks!
You are correct about this (and that it is not a TwelveMonkeys issue):
This is caused by the Java Module System (introduced in Java 9) which became more strict in Java 17.
For the record, TwelveMonkeys is tested with all Java LTS versions plus the current latest version (8, 11, 17 and 20, soon replaced by 21).
However, I don't think this is the case:
Your code access an internal class,
com.sun.media.imageioimpl.plugins.pnm.PNMImageReader
which you never should do.
I don't think @kunalbarchha does, that class is just used by ImageIO
(as it should, when JAI ImageIO is installed). It is the com.sun...PNMImageReader
that is the culprit, because it accesses sun.security.action
which is not allowed. This is a problem using old, outdated and discontinued products like JAI (Java Advanced Imaging)...
The issue with the code suddenly running fine on your local machine is actually related*. Because you have both JAI ImageIO and the TwelveMonkeys ImageIO PNM plugin in your dependencies (on class path), you have two plugins that are capable of reading the PNM format. When you attempt to read a PNM file using ImageIO.read(..)
, ImageIO
will pick the first PNM plugin. If you don't add specific code to order these, the order is undefined. It might work when you run the program once, and fail the next, even with no changes in code.
The easy fix is to remove any dependency on JAI ImageIO. If you don't have an explicit dependency, you might need to exclude it (consult Maven documentation as needed) or remove it from class path. If you need JAI ImageIO for other formats/functionality you can also work around the issue by setting the order so that the TwelveMonkeys PNM reader is picked first, as described in this SO answer.
*) Could of course also be that you don't have JAI ImageIO on your local machine, only on the server you tested. In either case, getting rid of JAI ImageIO will fix the problem.
from twelvemonkeys.
@haraldk Ah yes, this could definitely be the reason. I am not using anything else except TwelveMonkey, but there might some depencency having PNM related functionalities. I will check it out.. Thanks a lot.
from twelvemonkeys.
Even if unintentional, the error message you first posted indicate you are using JAI ImageIO.
from twelvemonkeys.
from twelvemonkeys.
Related Issues (20)
- Problematic inconsistence in JPEG color space detection: TwelveMonkey vs standard Java API HOT 9
- Wrong colors with CMYK JPEG HOT 1
- Webp: cannot decode grayscale images HOT 5
- NPE while read a PSD file HOT 3
- Unable to modify a JPEGImage10Metadata comment value HOT 17
- JPEG: Preserve metadata when writing CMYK HOT 5
- The OSGi support only exports the ImageReaderSpi services and not the ImageWriterSpi services HOT 1
- BMP: Write support for more ARGB types HOT 1
- Some malformed PSD images never return from `ImageIO.read()` using 3.10.0 HOT 2
- WebP: Images decoded with yellow tint HOT 1
- Possible bug in Half.shortBitsToFloat HOT 5
- Troubleshooting with ImageIO plugin registry issue (NoClassDefFoundErrors) without web.xml file HOT 1
- YCCK JPEG from a PDF with wrong colors HOT 5
- TIFF: Support SAMPLEFORMAT_COMPLEXINT (5) HOT 3
- WebP plugin stops working when other plugins are enabled too HOT 2
- PSD: Get layer kind (type) to metadata HOT 1
- Twelvemonkeys Servlet should support Jakarta HOT 6
- JPEGImageReader read invalid image without throwing exception HOT 4
- PSD: When make PNG from PSD using TwelveMonkeys, it's different from Photoshop. HOT 4
- Change Maven GPG plugin to use Bouncy Castle signer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twelvemonkeys.