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

Loading ImageReaderFactory.properties fails when using the Java Module System #1371

Open
jczwo opened this issue Nov 20, 2023 · 1 comment
Open

Comments

@jczwo
Copy link

jczwo commented Nov 20, 2023

Describe the bug
I am trying to use dcm4che in a modularized app based on Java 17. To modularize the dcm4che packages I used the moditect-maven-plugin. So far this works fine.

Now I try to use the decompressor class and get the following error:

java.lang.RuntimeException: Failed to load Image Reader Factory configuration from: org/dcm4che3/imageio/codec/ImageReaderFactory.properties
at dcm4che.imageio@5.31.0/org.dcm4che3.imageio.codec.ImageReaderFactory.initDefault(Unknown Source)
at dcm4che.imageio@5.31.0/org.dcm4che3.imageio.codec.ImageReaderFactory.getDefault(Unknown Source)
at dcm4che.imageio@5.31.0/org.dcm4che3.imageio.codec.ImageReaderFactory.getImageReaderParam(Unknown Source)
at dcm4che.imageio@5.31.0/org.dcm4che3.imageio.codec.Decompressor.(Unknown Source)
at dcm4che.imageio@5.31.0/org.dcm4che3.imageio.codec.Decompressor.decompress(Unknown Source)

In the dcm4che source code I can see that the resource ImageReaderFactory.properties is not loaded directly by the ImageReaderFactory class, but indirectly via class ResourceLocator.

The ResourceLocator class is located in the org.dcm4che3.util module and tries to access the ImageReaderFactory.properties resource from the org.dcm4che3.imageio.codec module.

As far as I understand it, it is no longer possible to access resources of another module when using the Java Module System.

Is that correct? Is there a suggestion for a workaround?

To Reproduce
Steps to reproduce the behavior:

  1. Modularize dcm4che packages
  2. Use Decompressor class
@jczwo
Copy link
Author

jczwo commented Nov 20, 2023

I found a workaround by adding some add-opens to my startup arguments:

--add-opens dcm4che.imageio/org.dcm4che3.imageio.codec=dcm4che.core
--add-opens java.desktop/javax.imageio.stream=dcm4che.imageio.opencv
--add-opens java.base/java.io=dcm4che.imageio.opencv

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

1 participant