Hi,

I've got a problem using java native libraries with mvn. The tests that fail with mvn run with ant.

Any ideas? Other things to try?

Thanks,

Craig

Apache Ant version 1.7.0 compiled on August 25 2008

Maven version: 2.0.6

Test set: testsuite.clusterj.FindByPrimaryKeyTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.011 sec <<< FAILURE! testFindByPrimaryKey(testsuite.clusterj.FindByPrimaryKeyTest) Time elapsed: 0.001 sec <<< ERROR!
java.lang.UnsatisfiedLinkError: no ndbj in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)
        at java.lang.Runtime.loadLibrary0(Runtime.java:822)
        at java.lang.System.loadLibrary(System.java:993)
at testsuite.clusterj.ClusterJTest.getProperties(ClusterJTest.java:79) at testsuite.clusterj.ClusterJTest.createSession(ClusterJTest.java:70)

Here's the failing code:
    /** Create a file from a property name. */
    Properties getProperties(String fileName) {
        String libpath = System.getProperty("java.library.path");
        System.out.println("java.library.path is " + libpath);
        System.loadLibrary("ndbj");
        Properties result = null;

Here's the pom:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd ">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.mysql.clusterj</groupId>
 <artifactId>clusterj</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>clusterj</name>
 <url>http://maven.apache.org</url>
 <build>
   <plugins>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-compiler-plugin</artifactId>
       <configuration>
         <source>1.5</source>
         <target>1.5</target>
       </configuration>
     </plugin>
     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
       <configuration>
         <systemProperties>
           <property>
             <name>java.library.path</name>
<value>/Users/clr/launchpad/ndb-bindings/working/ java/.libs</value>
           </property>
         </systemProperties>
       </configuration>
     </plugin>
   </plugins>
   <resources>
     <resource>
       <directory>src/test/resources</directory>
     </resource>
   </resources>
  </build>
  <dependencies>
   <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>3.8.1</version>
     <scope>test</scope>
   </dependency>
   <dependency>
     <groupId>ndbj</groupId>
     <artifactId>ndbj</artifactId>
     <version>6.3.17</version>
     <scope>compile</scope>
   </dependency>
   <dependency>
     <groupId>javax.transaction</groupId>
     <artifactId>transaction-api</artifactId>
     <version>1.1</version>
   </dependency>
 </dependencies>
 <properties>
<netbeans.hint.useExternalMaven>true</ netbeans.hint.useExternalMaven>
   </properties>
</project>

When I run this:
mvn test

I get this:
...
[INFO] Surefire report directory: /Users/clr/ndb/clusterj/trunk/ clusterj/target/surefire-reports

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testsuite.clusterj.QueryAndDisplayTest
java.library.path is /Users/clr/ndb/clusterj/trunk/clusterj/target/ classes/.libs java.library.path is /Users/clr/ndb/clusterj/trunk/clusterj/target/ classes/.libs Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.067 sec <<< FAILURE!

I can run the same tests from ant in the same directory:

<project name="cndb-java" basedir="." default="test">

 <property file="${user.home}/.${ant.project.name}-build.properties"/>
 <property file="${user.home}/.build.properties"/>
 <property file="build.properties"/>

        <path id="project.cp">
                <pathelement path="target/classes"/>
                <pathelement path="target/test-classes"/>
<pathelement path="/Users/clr/.m2/repository/ndbj/6.3.17/ ndbj-6.3.17.jar"/> <pathelement path="/Users/clr/.m2/repository/javax/transaction/ transaction-api/1.1/transaction-api-1.1.jar"/>
        </path>

        <target name="test">
                <junit printsummary="true" haltonfailure="false"
                        haltonerror="false" fork="true">
                        <classpath>
                                <path refid="project.cp"/>
                        </classpath>

                        <formatter type="plain" usefile="false"/>

                        <test name="testsuite.clusterj.FindTest"/>

<sysproperty key="java.library.path" value="/Users/clr/ndb/clusterj/ trunk/clusterj/target/classes/.libs"/>
                        <sysproperty key="com.mysql.jdbc.testsuite.url"
                                value="${jdbcurl}"/>
                </junit>
        </target>

</project>
...
   [junit] ------------- Standard Output ---------------
   [junit] java.library.path is target/classes/.libs


Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to