Add dependecy to Maven and set to $CATALINA_HOME/shared/lib

空扰寡人 提交于 2020-01-15 09:38:47

问题


I'm using Matlab MCR in web project so I imported these dependecies to pom.xml

<!-- Matlab client tool library -->
    <!--  <dependency>
            <groupId>DataConcatenation</groupId>
            <artifactId>DataConcatenation</artifactId>
            <version>0.0.5-SNAPSHOT</version>
        </dependency> -->
<!--        <dependency>
            <groupId>DataConcatenator</groupId>
            <artifactId>DataConcatenator</artifactId>
            <version>0.0.5-SNAPSHOT</version>
        </dependency> -->
<!--        <dependency>
            <groupId>DataConversion</groupId>
            <artifactId>DataConversion</artifactId>
            <version>0.0.5-SNAPSHOT</version>
        </dependency> -->
        <dependency>
            <groupId>DataConverter</groupId>
            <artifactId>DataConverter</artifactId>
            <version>0.0.5-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <artifactId>DataConcatenation</artifactId>
                    <groupId>DataConcatenation</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>DataConcatenator</artifactId>
                    <groupId>DataConcatenator</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>DataConversion</artifactId>
                    <groupId>DataConversion</groupId>
                </exclusion>
            </exclusions>
        </dependency> 

The first problems is that I have to exclude the other tree dependencies even if I use only DataConverter, But I need only dataConverter and this library doesn't have other dependecies. The second and most important problem is this error:

Threw exception in ZipAndMat::createZipAndMat: java.lang.UnsatisfiedLinkError: Native Library /usr/v81/bin/glnxa64/libnativedl.so already loaded in another classloader

I read a lot of guide and I understand that I have to put this jar into $CATALINA_HOME/shared/lib so all the class loader share the same jar. But how can I add this dependecy to the above path? This is the first time that I have to implement this configuration. I use tomcat on my server and deploy project through war file. Thanks


回答1:


You can place the jar into $CATALINA_HOME/shared/lib, and then specify in your POM the dependency's <scope> as provided:

<dependency>
        <groupId>DataConverter</groupId>
        <artifactId>DataConverter</artifactId>
        <version>0.0.5-SNAPSHOT</version>
        <scope>provided</scope>
        <exclusions>
            ...
        </exclusions>
    </dependency> 

This method is often used for jars which contain JDBC drivers when running on Tomcat; the jdbc jar is placed in $CATALINA_HOME/shared/lib (so all WARs can find it), yet each project list’s the JDBC jar as a dependency with provided as the scope.

See this post for more information on provided.



来源:https://stackoverflow.com/questions/38636439/add-dependecy-to-maven-and-set-to-catalina-home-shared-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!