I'm facing an issue when trying to run Functional Mock-up Units (FMUs) on my Ubuntu 22.04 server using a JavaFmi wrapper within a Docker container based on a Wine image (version 9.0) because i have some fmus (.dll ) others (.so)
the error :
Trying (via loadLibrary) jnidispatch
Found jnidispatch on system path
2024-10-09T14:57:33.937Z ERROR 1 --- [simulation-win-ms] [nio-8066-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/fmu_58a0f513_0f68_4f3e_b420_04f673a1754dtest_FMU/binaries/win64/test_FMU.dll': Native library (tmp/fmu_58a0f513_0f68_4f3e_b420_04f673a1754dtest_FMU/binaries/win64/test_FMU.dll) not found in resource path ([])] with root cause
java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/fmu_58a0f513_0f68_4f3e_b420_04f673a1754dtest_FMU/binaries/win64/test_FMU.dll': Native library (tmp/fmu_58a0f513_0f68_4f3e_b420_04f673a1754dtest_FMU/binaries/win64/test_FMU.dll) not found in resource path ([])
I'm getting this error message indicating that the native library (DLL) cannot be found, even though I can access the FMU files within the Docker container using docker exec -it. I've already tried explicitly setting the JNA library path, but the problem persists. Additionally, I can't set a fixed path for the FMU files because their names contains uuid generated automatically with each execution.
and here is my wine dockerfile :
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends \
wget \
gnupg2 \
software-properties-common \
curl \
file \
xvfb \
&& wget -nc https://dl.winehq.org/wine-builds/winehq.key && \
apt-key add winehq.key && \
add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ jammy main' && \
apt-get update && \
apt-get install -y --install-recommends \
winehq-stable \
openjdk-18-jdk \
cabextract \
p7zip-full \
unzip \
wine32 \
wine64 \
winbind \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV WINEDEBUG=-all
ENV WINEPREFIX=/root/.wine
ENV WINEARCH=win64
RUN wget -O /usr/bin/winetricks https://raw.githubusercontent.com/Winet ... winetricks && \
chmod +x /usr/bin/winetricks
RUN winetricks --self-update
RUN winecfg
ENV JAVA_HOME=/usr/lib/jvm/java-18-openjdk-amd64
ENV PATH=$JAVA_HOME/bin:$PATH
# Set JNA_LIBRARY_PATH to point to the native library location
ENV JNA_LIBRARY_PATH="/tmp"
and then my microservice dockerfile based on that built wine image :
FROM docker24/wine:latest
WORKDIR /
COPY /target/simulation_win_microservice-1.0-SNAPSHOT.jar /app.jar
COPY src/main/resources/win32-x86-64/libjnidispatch.so /tmp
RUN cd /tmp && ls
RUN chmod -R 777 /tmp
RUN cd /tmp && ls -al
ENV JNA_LIBRARY_PATH="/tmp"
ENTRYPOINT ["java","-Djava.library.path=/tmp:/usr/lib:/lib:/usr/lib:/lib:/usr/lib/jvm/java-18-openjdk-amd64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ,"-Djna.library.path=/tmp:/tmp/fmu_*/binaries/win64/*.dll" ,"-jar", "/app.jar"]
Am I using the appropriate Wine configuration for my application? Are there specific Wine configurations or settings that might be influencing the loading of native libraries? Is there a possibility of dynamically loading the FMU DLL based on the automatically generated UUID?