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

Missing image reader #29

Open
fmarisa opened this issue Nov 21, 2016 · 4 comments
Open

Missing image reader #29

fmarisa opened this issue Nov 21, 2016 · 4 comments

Comments

@fmarisa
Copy link

fmarisa commented Nov 21, 2016

Hi,

Trying to load the plugin JPEG2000 the JPEG2000 reader is not loaded and it later results in an exception :

org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JPEG2000 image: Java Advanced Imaging (JAI) Image I/O Tools are not installed
at org.apache.pdfbox.filter.Filter.findImageReader(Filter.java:128)
at org.apache.pdfbox.filter.JPXFilter.readJPX(JPXFilter.java:72)
at org.apache.pdfbox.filter.JPXFilter.decode(JPXFilter.java:56)
at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:69)

The issue seems to be that the ServiceRegistry class does not contain the jpeg class, simply because it is not in the classpath. Why is it not in the classpath? Well we're not certain. It is present in the jar we're launching but not in the classpath.

However if we add the jar jpeg2000 to the classpath before our jar-with-dependencies then it does get loaded... eg this works

java -cp jai-imageio-jpeg2000-1.3.0.jar:my-jar-with-dependencies.jar ...

this does not work

java -cp my-jar-with-dependencies.jar ...

Even though my-jar-with-dependencies.jar contains the classes in jai-imageio-jpeg2000-1.3.0.jar

@lobsangludd
Copy link

Plugins are loaded via META-INF/services/javax.imageio.spi.ImageReaderSpi - DOCS

Since you're putting multiple plugins in the same jar, this file is overwritten. You'll have to register them manually:

IIORegistry registry = IIORegistry.getDefaultInstance();
registry.registerServiceProvider(new com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi()); 

@JamzTheMan
Copy link

OMG thank you! I had a similiar issue dealing after adding TwelveMonkeys PSD/ImageIO plugins and this solved the issue when building the app in an uber-jar!

Thought this deserved a shot out as it took an hour of Google-foo to get here lol

@michi88
Copy link

michi88 commented Apr 5, 2018

If you're using the maven shade plugin you can also use the following transformer:

<transformers>
    <!-- needed for jpeg2000 services to be included properly -->
    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>

@shrutibidada
Copy link

Plugins are loaded via META-INF/services/javax.imageio.spi.ImageReaderSpi - DOCS

Since you're putting multiple plugins in the same jar, this file is overwritten. You'll have to register them manually:

IIORegistry registry = IIORegistry.getDefaultInstance();
registry.registerServiceProvider(new com.github.jaiimageio.jpeg2000.impl.J2KImageReaderSpi()); 

This worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants