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

STORESCU fails on opencv_java #1341

Open
jssuttles opened this issue Aug 30, 2023 · 11 comments
Open

STORESCU fails on opencv_java #1341

jssuttles opened this issue Aug 30, 2023 · 11 comments

Comments

@jssuttles
Copy link

jssuttles commented Aug 30, 2023

Describe the bug
When using the storescu process, we get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: <file path>\opencv_java.dll: Can't find dependent libraries
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:315)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:287)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2422)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at org.opencv.osgi.OpenCVNativeLoader.init(OpenCVNativeLoader.java:17)
at org.dcm4che3.opencv.StreamSegment.(StreamSegment.java:76)
at org.dcm4che3.opencv.NativeImageReader.getNativeImage(NativeImageReader.java:260)
at org.dcm4che3.opencv.NativeImageReader.read(NativeImageReader.java:251)
at org.dcm4che3.imageio.codec.Decompressor.decompressFrame(Decompressor.java:299)
at org.dcm4che3.imageio.codec.Decompressor.writeFrameTo(Decompressor.java:285)
at org.dcm4che3.imageio.codec.Decompressor.writeTo(Decompressor.java:269)
at org.dcm4che3.imageio.codec.Decompressor$1.writeTo(Decompressor.java:202)
at org.dcm4che3.io.DicomOutputStream.writeAttribute(DicomOutputStream.java:213)
at org.dcm4che3.io.DicomOutputStream.writeAttribute(DicomOutputStream.java:189)
at org.dcm4che3.data.Attributes.writeTo(Attributes.java:3123)
at org.dcm4che3.data.Attributes.writeTo(Attributes.java:3062)
at org.dcm4che3.io.DicomOutputStream.writeDataset(DicomOutputStream.java:150)
at org.dcm4che3.net.DataWriterAdapter.writeTo(DataWriterAdapter.java:67)
at org.dcm4che3.net.PDUEncoder.writeDIMSE(PDUEncoder.java:475)
at org.dcm4che3.net.Association.invoke(Association.java:1286)
at org.dcm4che3.net.Association.invoke(Association.java:1274)
at org.dcm4che3.net.Association.cstore(Association.java:939)
at org.dcm4che3.tool.storescu.StoreSCU.send(StoreSCU.java:511)
at org.dcm4che3.tool.storescu.StoreSCU.sendFiles(StoreSCU.java:415)
at org.dcm4che3.tool.storescu.StoreSCU.main(StoreSCU.java:294)

This causes the store process to stop and fail.

To Reproduce
We're not sure what causes this and how to reproduce this behavior.

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Java Version: 17.0.5

Additional context
The storescu process works for some studies but fails for others. We've had this issue intermittently occur on certain other machines as well starting as far back as May 18th 2023.

@jssuttles
Copy link
Author

We are still investigating this issue, but we're not as familiar with Java and OpenCV and a direction would certainly be helpful.

@nroduit
Copy link
Member

nroduit commented Sep 1, 2023

Do you mean the command line storescu or with the Java API?

@jssuttles
Copy link
Author

@nroduit Command line StoreSCU

@nroduit
Copy link
Member

nroduit commented Sep 1, 2023

Did you modify the bat file? because I do not understand why you get "<file path>\opencv_java.dll"

Or do you change the environment variable %DCM4CHE_HOME% or %JAVA_OPTS%

To debug, add "echo %JAVA_OPTS%" before the last command line of the bat file to show the command option.

@jssuttles
Copy link
Author

Thanks for guidance. We do change the bat file. I'll take a look at this soon.

@jssuttles
Copy link
Author

@echo off
rem -------------------------------------------------------------------------
rem storescu  Launcher
rem -------------------------------------------------------------------------

if not "%ECHO%" == ""  echo %ECHO%
if "%OS%" == "Windows_NT"  setlocal

set MAIN_CLASS=org.dcm4che3.tool.storescu.StoreSCU
set MAIN_JAR=dcm4che-tool-storescu-5.29.2.jar

set DIRNAME=.\
if "%OS%" == "Windows_NT" set DIRNAME=%~dp0%

rem Read all command line arguments

set ARGS=
:loop
if [%1] == [] goto end
        set ARGS=%ARGS% %1
        shift
        goto loop
:end

if not "%DCM4CHE_HOME%" == "" goto HAVE_DCM4CHE_HOME

set DCM4CHE_HOME=%DIRNAME%..

:HAVE_DCM4CHE_HOME

set JAVA=%DIRNAME%..\..\java\bin\java

set CP=%DCM4CHE_HOME%\etc\storescu\
set CP=%CP%;%DCM4CHE_HOME%\etc\certs\
set CP=%CP%;%DCM4CHE_HOME%\lib\%MAIN_JAR%
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-core-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-net-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-image-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-imageio-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-imageio-opencv-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-imageio-rle-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\dcm4che-tool-common-5.29.2.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\weasis-core-img-4.6.0.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\jai_imageio-1.2-pre-dr-b04.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\clibwrapper_jiio-1.2-pre-dr-b04.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\slf4j-api-1.7.32.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\slf4j-simple-1.7.32.jar
set CP=%CP%;%DCM4CHE_HOME%\lib\commons-cli-1.4.jar

rem Setup native library path
"%JAVA%" -version 2>&1 | findstr 64-Bit >nul && set "OS=windows-x86-64" || set "OS=windows-x86"
set JAVA_LIBRARY_PATH=%DCM4CHE_HOME%\lib\%OS%

set JAVA_OPTS=%JAVA_OPTS% -Djava.library.path="%JAVA_LIBRARY_PATH%"

if not "%IMAGE_READER_FACTORY%" == "" ^
 set JAVA_OPTS=%JAVA_OPTS% -Dorg.dcm4che3.imageio.codec.ImageReaderFactory=%IMAGE_READER_FACTORY%

if not "%IMAGE_WRITER_FACTORY%" == "" ^
 set JAVA_OPTS=%JAVA_OPTS% -Dorg.dcm4che3.imageio.codec.ImageWriterFactory=%IMAGE_WRITER_FACTORY%

rem Required from JDK 16 with legacy image API (Decompressor and Compressor)
set JAVA_OPTS=%JAVA_OPTS% -XX:+IgnoreUnrecognizedVMOptions --add-opens=java.desktop/javax.imageio.stream=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED

"%JAVA%" %JAVA_OPTS% -cp "%CP%" %MAIN_CLASS% %ARGS%

We haven't upgraded to the latest version yet.
We use slf4j-simple instead of logback.
We use a packaged version of Java.
I'll return with the java opts echo.

@jssuttles
Copy link
Author

echo -Djava.library.path="<filepath>\dcm4che\bin..\lib\windows-x86-64" -XX:+IgnoreUnrecognizedVMOptions --add-opens=java.desktop/javax.imageio.stream=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED
-Djava.library.path="<filepath>\dcm4che\bin..\lib\windows-x86-64" -XX:+IgnoreUnrecognizedVMOptions --add-opens=java.desktop/javax.imageio.stream=ALL-UNNAMED

@jssuttles
Copy link
Author

jssuttles commented Sep 1, 2023

To clarify: <filepath> is me replacing my computer's file path with <filepath>. That's not how it shows up in the error. (I just don't want my computer's file path available on the internet.)

@jssuttles
Copy link
Author

(I hope you don't mind if I ping you @nroduit.)

@nroduit
Copy link
Member

nroduit commented Sep 8, 2023

Please check with the original file first, as we cannot respond to issues that contain modifications.

@jssuttles
Copy link
Author

Ok. I don't think I'll be able to do that where the issue occurs, but I'll see what I can do.

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

2 participants