windows - Maven, Tomcat, java.library.path og\% PATH\%: En mærkelig kærlighedsaffære

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg har kæmpet for dage for at genkende hvad der foregår med mit nuværende Java Maven-projekt, der bruger Tomcat og eksterne biblioteker (JCo).
Af en eller anden grund matcher resultatet System.getProperty("java.library.path") ikke med stierne fra min omgivelsesvariabel \%PATH\% (standard).
Jeg har ikke til hensigt at ændre værdien java.library.path eller overhovedet , jeg vil bare vide hvorfor det er IKKE DEFAULTER til\% PATH\% variabel.


Her er hvordan jeg identificerede det:


public static void main(String[] args) {
    for (String path : System.getProperty("java.library.path")) {
        System.out.println(path);
    }
}


Ovenstående uddrag resulterer i:


C:Program FilesJavajre1.8.0\_131in C:WINDOWSSunJavain C:WINDOWSsystem32 C:WINDOWS C:/Program Files/Java/jre1.8.0\_131/bin/server C:/Program Files/Java/jre1.8.0\_131/bin C:/Program Files/Java/jre1.8.0\_131/lib/amd64 C:ProgramDataOracleJavajavapath C:Program FilesDockerDockerResourcesin C:Python27 C:Python27Scripts C:Program FilesGitin C:Program FilesGitcmd C:Program Files (x86)InteliCLS Client C:Program FilesInteliCLS Client C:Windowssystem32 C:Windows C:WindowsSystem32Wbem C:WindowsSystem32WindowsPowerShellv1.0 C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL C:Program FilesIntelIntel(R) Management Engine ComponentsDAL C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT C:Program FilesIntelIntel(R) Management Engine ComponentsIPT C:UsersUnknown.dnxin C:Program FilesMicrosoft DNXDnvm C:Program FilesMicrosoft SQL Server120ToolsBinn C:Program FilesMicrosoft SQL Server130ToolsBinn C:Program Files (x86)Windows Kits10Windows Performance Toolkit C:Program Files (x86)Microsoft Emulator Manager1.0 C:Program Files (x86)NVIDIA CorporationPhysXCommon C:Program Files (x86)Microsoft SQL ServerClient SDKODBC110ToolsBinn C:Program Files (x86)Microsoft SQL Server120ToolsBinnManagementStudio C:Program Files (x86)Microsoft SQL Server120ToolsBinn C:Program FilesGitcmd C:Program Files (x86) odejs C:WINDOWSsystem32 C:WINDOWS C:WINDOWSSystem32Wbem C:WINDOWSSystem32WindowsPowerShellv1.0 C:Program Files (x86)SkypePhone C:Program FilesJavajdk1.8.0\_112in D:Arquivos de ProgramasApache Software FoundationMaven 3.3.9in C:Pro C:UsersUnknownAppDataRoaming pm C:UsersUnknownAppDataLocalMicrosoftWindowsApps C:Program FilesEclipse Neon .


... mens echo \%PATH\% producerer følgende resultater:


C:Program FilesDockerDockerResourcesin C:Python27 C:Python27Scripts C:WEEEEEEEEEEEIRDPAAAAAAAATHHHHHHFOR MAVEN EXAMPLE C:Program FilesGitin C:Program FilesGitcmd C:Program Files (x86)InteliCLS Client C:Program FilesInteliCLS Client C:Windowssystem32 C:Windows C:WindowsSystem32Wbem C:WindowsSystem32WindowsPowerShellv1.0 C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL C:Program FilesIntelIntel(R) Management Engine ComponentsDAL C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT C:Program FilesIntelIntel(R) Management Engine ComponentsIPT C:UsersUnknown.dnxin C:Program FilesMicrosoft DNXDnvm C:Program FilesMicrosoft SQL Server120ToolsBinn C:Program FilesMicrosoft SQL Server130ToolsBinn C:Program Files (x86)Windows Kits10Windows Performance Toolkit C:Program Files (x86)Microsoft Emulator Manager1.0 C:Program Files (x86)NVIDIA CorporationPhysXCommon C:Program Files (x86)Microsoft SQL ServerClient SDKODBC110ToolsBinn C:Program Files (x86)Microsoft SQL Server120ToolsBinnManagementStudio C:Program Files (x86)Microsoft SQL Server120ToolsBinn C:Program FilesGitcmd C:Program Files (x86) odejs C:WINDOWSsystem32 C:WINDOWS C:WINDOWSSystem32Wbem C:WINDOWSSystem32WindowsPowerShellv1.0 C:Program Files (x86)SkypePhone C:Program FilesJavajdk1.8.0\_112in D:Arquivos de ProgramasApache Software FoundationMaven 3.3.9in D:Arquivos de ProgramasSAPJCo C:Program Files (x86)InteliCLS Client C:Program FilesInteliCLS Client C:Windowssystem32 C:Windows C:WindowsSystem32Wbem C:WindowsSystem32WindowsPowerShellv1.0 C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL C:Program FilesIntelIntel(R) Management Engine ComponentsDAL C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT C:Program FilesIntelIntel(R) Management Engine ComponentsIPT C:UsersUnknown.dnxin C:Program FilesMicrosoft DNXDnvm C:Program FilesMicrosoft SQL Server120ToolsBinn C:Program FilesMicrosoft SQL Server130ToolsBinn C:Program Files (x86)Windows Kits10Windows Performance Toolkit C:Program Files (x86)Microsoft Emulator Manager1.0 C:Program Files (x86) odejs C:Program Files (x86)SkypePhone C:Program Files (x86)NVIDIA CorporationPhysXCommon C:Program Files (x86)Microsoft SQL ServerClient SDKODBC110ToolsBinn C:Program Files (x86)Microsoft SQL Server120ToolsBinnManagementStudio C:Pro C:UsersUnknownAppDataRoaming pm C:UsersUnknownAppDataLocalMicrosoftWindowsApps


Som vi kan se, vises 'C: \ WEEEEEEEEEEEIRD \ PAAAAAAAATHHHHHH \ FOR MAVEN EXAMPLE' fra \%PATH\% ikke i java.library.path. Denne sti indeholder den nødvendige DLL for mit projekt.


Hvad kunne være forkert? Mange tak på forhånd!


Jeg bruger:



  • Windows 10 x64

  • Maven 3.3.9

  • Tomcat 9

  • Java 8

  • Eclipse Neon

  • JCo 3 (SAP Java Connector)

  • Hibersap 1.3.0 (JCo 'wrapper')



pom.xml:


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>br.com.nooder</groupId>
    <artifactId>Hibersap</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Hibersap</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.hibersap</groupId>
            <artifactId>hibersap-core</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibersap</groupId>
            <artifactId>hibersap-jco</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- mvn install:install-file -DgroupId=org.hibersap -DartifactId=com.sap.conn.jco.sapjco3 -Dversion=3.0.16 -Dpackaging=jar -Dfile="C:somewheresapjco3.jar" -->
        <dependency>
            <groupId>org.hibersap</groupId>
            <artifactId>com.sap.conn.jco.sapjco3</artifactId>
            <version>3.0.16</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <systemPropertyVariables>
                        <propertyName>java.library.path</propertyName>
                        <buildDirectory>D:Arquivos de ProgramasSAPJCo</buildDirectory>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            -->
        </plugins>
    </build>
</project>

Bedste reference