Git Product home page Git Product logo

Comments (8)

haraldk avatar haraldk commented on June 16, 2024

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.

kunalbarchha avatar kunalbarchha commented on June 16, 2024

Any idea how to resolve it ? @haraldk it's a blocker currently.

from twelvemonkeys.

rmuller avatar rmuller commented on June 16, 2024

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.

kunalbarchha avatar kunalbarchha commented on June 16, 2024

@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.

haraldk avatar haraldk commented on June 16, 2024

@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.

kunalbarchha avatar kunalbarchha commented on June 16, 2024

@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.

haraldk avatar haraldk commented on June 16, 2024

Even if unintentional, the error message you first posted indicate you are using JAI ImageIO.

from twelvemonkeys.

kunalbarchha avatar kunalbarchha commented on June 16, 2024

from twelvemonkeys.

Related Issues (20)

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.