0

I have a Java web project using jMUPdf library as an external dependency. As I was not able to find jMUPdf in any public maven repository, I tried to install it to my local m2 repository using install-file

jMUPdf uses jmupdf.jar and a dependent jmupdf64.dll, so I did this:

mvn install:install-file -Dfile=jmupdf.jar -DgroupId=jmupdf -DartifactId=jmupdf -Dversion=0.4.1 -Dpackaging=jar

mvn install:install-file -Dfile=jmupdf64.dll -DgroupId=jmupdf -DartifactId=jmupdfdll64 -Dversion=0.4.1 -Dpackaging=dll

I can see both libraries in my local m2 repository.

This is an excerpt from my pom.xml

    <dependency>
        <groupId>jmupdf</groupId>
        <artifactId>jmupdfdll64</artifactId>
        <version>0.4.1</version>
        <scope>runtime</scope>
        <type>dll</type>
    </dependency>
    <dependency>
        <groupId>jmupdf</groupId>
        <artifactId>jmupdf</artifactId>
        <version>0.4.1</version>
    </dependency>

BUT: After compiling my project (which generates a war file) I only see the jmupdf.jar in \WEB-INF\lib and the DLL is missing. That's of course the reason for a runtime exception regarding the missing jmupdf64.dll

How can I make sure that the dll is part of the resulting war file?

EDIT: ... and that it will also be deployed correctly (e.g. into webapps/MYAPP/WEB-INF/lib on my Tomcat)?

devnull69
  • 16,402
  • 8
  • 50
  • 61
  • You may find a solution here: http://stackoverflow.com/questions/1611357/how-to-make-a-jar-file-that-includes-dll-files; consider that the usage of the *dll* is restricted to the system loading – fantaghirocco Aug 24 '15 at 15:46
  • Hmm I can't see how this would help me. In my case the DLL should be packaged into the war and then (on Tomcat deployment) also be extracted to the webapps folder /WEB-INF/lib in order to be usable – devnull69 Aug 24 '15 at 16:17
  • that's what I mean: I think that the library can't be used in that place unless the app provides its own loading mechanism through JNI. I may be wrong... – fantaghirocco Aug 25 '15 at 07:10
  • @devnull69 ... did you ever find an answer to this? Including a dll in a war file? Thanks :) – Nova Jan 31 '17 at 01:31

1 Answers1

0

This is my simple solution for my need of integrated security using ms-jdbc...

    <dependencies>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc_auth</artifactId>
        <version>8.4.1.x64</version>
        <type>dll</type>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>8.4.1.jre14</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <excludeScope>provided</excludeScope>
                        <includeTypes>dll</includeTypes>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
J.C
  • 11
  • 1