簡體   English   中英

回調文件系統和“ java.library.path中沒有jnicbfs”錯誤

[英]Callback File System and “no jnicbfs in java.library.path” error

enter code here我使用standart安裝包中的示例創建了一個簡單的代碼,用於將虛擬磁盤安裝到系統中。 Java示例。 因此,在我創建了一些單元測試之后,第一個是將磁盤安裝到系統中並檢查是否已安裝了磁盤,第二個試圖安裝磁盤並嘗試創建簡單文件來檢查創建/打開等事件。文件,因此,如果我僅使用一個測試,則一切工作正常,如果兩個都收到錯誤no jnicbfs in java.library.path可以有人幫助我解決此問題嗎? PS-許可證正在試用-下面的簡單代碼

  @Override
    public boolean createVirtualDisk(String diskLetter) {

        CallbackFileSystem callbackFileSystem;
        boolean isCreated = true;

        try {

            // create CbFS instance
            callbackFileSystem = new CallbackFileSystem(new CloudFileSystemEventHandler());

            //initialize system properties
            initCallBackFileSystemProperties(diskLetter, callbackFileSystem);

            // mount point
            callbackFileSystem.mountMedia(0);

        } catch (ECBFSError e) {
            LOGGER.error(e.getMessage(), e);
            isCreated = false;
        }

        return isCreated;
    }

    private void initCallBackFileSystemProperties(String volumeKey, CallbackFileSystem callbackFileSystem) throws ECBFSError {
        callbackFileSystem.setRegistrationKey(cloudFileSystemProperties.getLicenseKey());
        callbackFileSystem.setSerializeCallbacks(cloudFileSystemProperties.isSerializeCallbacks());
        callbackFileSystem.setThreadPoolSize(cloudFileSystemProperties.getThreadPoolSize());
        callbackFileSystem.setProcessRestrictionsEnabled(cloudFileSystemProperties.isProcessRestrictionsEnabled());
        callbackFileSystem.createStorage();
        callbackFileSystem.disableMetaDataCache(cloudFileSystemProperties.isMetaDataCacheDisable());
        callbackFileSystem.addMountingPoint(volumeKey);
    }

測試1:

        CbFSProperties cbFSProperties = createCloudFileSystemProperties();
        // create CloudFileSystemImpl context
        CloudFileSystemContext cloudFileSystemContext = new CloudFileSystemContext(cbFSProperties);


        // create volume
        CloudFileSystem cloudFileSystem = new CloudFileSystemImpl(cloudFileSystemContext);
//
        boolean isCreated = cloudFileSystem.createVirtualDisk("R:");

        // check if volume was created correctly
        CallbackFileSystem callbackFileSystem = new CallbackFileSystem();
        callbackFileSystem.setRegistrationKey(cbFSProperties.getLicenseKey());

        // check created or not
        Assert.assertEquals(true, isCreated);

        // the same assertion
        Assert.assertEquals("R", callbackFileSystem.getMountingPoint(0));

2:

 CbFSProperties cbFSProperties = createCloudFileSystemProperties();
// create CloudFileSystemImpl context
CloudFileSystemContext cloudFileSystemContext = new CloudFileSystemContext(cbFSProperties);

// create volume
CloudFileSystem cloudFileSystem = new CloudFileSystemImpl(cloudFileSystemContext);

boolean isCreated = cloudFileSystem.createVirtualDisk("S:");

if (isCreated)
    createFileOnDisk("S:\\test.txt");
else
    Assert.assertTrue("The disk was not created.", false);

具有java.library.path的Maven文件

http://maven.apache.org/maven-v4_0_0.xsd“>

<dependencies>

    <dependency>
        <groupId>eldos</groupId>
        <artifactId>eldos.cbfs</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>

    <!--&lt;!&ndash; Testing&ndash;&gt;-->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
    <!--Other -->
</dependencies>


<build>
    <resources>
        <!-- standard Maven folder -->
        <resource>
            <directory>src/main/resources</directory>
        </resource>
        <!-- plus root folder -->
        <resource>
            <directory>.</directory>
            <includes>
                <include>plugin.xml</include>
                <include>META-INF/*</include>
            </includes>
        </resource>
        <resource>
            <directory>${basedir}/target/dependency</directory>
            <targetPath>.</targetPath>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${source.target.version}</source>
                <target>${source.target.version}</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>eldos</groupId>
                                <artifactId>eldos.cbfs</artifactId>
                                <version>1.0.0</version>
                                <!--<classifier>eldos.cbfs</classifier>-->
                                <type>jar</type>
                                <overWrite>true</overWrite>
                                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <systemProperties>
                    <property>
                        <name>java.library.path</name>
                        <value>target/lib/</value>
                    </property>
                </systemProperties>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <useDefaultManifestFile>true</useDefaultManifestFile>
            </configuration>
        </plugin>
    </plugins>
</build>

我使用了系統屬性,但是未設置java.library.path ,在此之后,我嘗試使用特殊屬性,並且所有屬性都可以正常工作,如博客所述

工作的Maven插件是

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
         <forkMode>once</forkMode>
         <workingDirectory>target</workingDirectory>
        <argLine>-Djava.library.path=${basedir}/lib</argLine>
    </configuration>
</plugin>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM