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

Mention some specific information about TwelveMonkeys ImageIO and Apache Ant #231

Closed
ghost opened this issue Mar 18, 2016 · 3 comments
Closed
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Mar 18, 2016

TwelveMonkeys ImageIO works flawlessly with Ant when calling a class that uses it with the Java target and by setting the "fork" attribute to true. Otherwise, the SPIs are never loaded (it's not a bug):

java.lang.IllegalArgumentException: image == null! 
    at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:925) 
    at javax.imageio.ImageIO.getWriter(ImageIO.java:1591) 
    at javax.imageio.ImageIO.write(ImageIO.java:1520) 

Maybe another workaround consists in modifying the system classloader of Ant with ant-classloadertask but I haven't tested it yet. A less smart solution would consist in putting the necessary JARs directly inside Ant.

In my humble opinion, it should be mentioned in the documentation of this library. It's neither a limitation nor a bug, it's something that an Apache Ant user should know.

@haraldk
Copy link
Owner

haraldk commented Mar 29, 2016

Hi Julien,

I'm not an Apache Ant user myself, so I'm not really sure if this is something that needs to be covered in the documentation... From what I understand about the stack trace you see, It is a common ImageIO plugin thing, based on how the SPI mechanism work.

Adding ImageIO.scanForPlugins() somewhere in your code (or custom Ant target) should make the SPIs registered, even without the fork attribute.

Harald K

@haraldk haraldk self-assigned this Mar 29, 2016
@ghost
Copy link
Author

ghost commented Mar 29, 2016

Hi Harald

Thank you for the trick, I should have read more carefully the Java documentation of the standard API. It's up to you to decide whether to put it into the documentation but I understand your objection and I confirm that this isn't specific to your library, it could have happened with any library based on the SPI mechanism.

@haraldk
Copy link
Owner

haraldk commented Apr 25, 2021

Hasn't been much issues with Ant use lately, closing.

@haraldk haraldk closed this as completed Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant