You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Craig L Russell <Cr...@Sun.COM> on 2008/11/02 16:36:58 UTC
Trouble with Java Native Libraries
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:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
Re: Trouble with Java Native Libraries
Posted by Dan Tran <da...@gmail.com>.
see if this would help
http://svn.codehaus.org/mojo/trunk/mojo/maven-native/native-maven-plugin/src/it/jni/java-win32/pom.xml
On Tue, Nov 4, 2008 at 10:35 AM, Wendy Smoak <ws...@gmail.com> wrote:
> On Tue, Nov 4, 2008 at 9:27 AM, Wendy Smoak <ws...@gmail.com> wrote:
>
>> ...but it only works if the library is sitting in the base directory
>> of the Maven project. If I move it into some other directory and then
>> configure Surefire to pass java.library.path to the tests, I get the
>> same thing Craig was seeing:
>>
>> java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
>
> Craig added a build.xml to the example, so we have it working with Ant
> and failing with Maven/Surefire:
> http://wush.net/svn/wsmoak/testing/trunk/jnitest
>
> There is build output in the README file. At this point someone more
> familiar with JNI and Surefire internals will have to take over. :)
> Craig, if you want to open a JIRA issue, feel free to point to this
> example.
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Trouble with Java Native Libraries
Posted by Kalle Korhonen <ka...@gmail.com>.
This is how we set the java.library.path for surefire, works fine for us:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<workingDirectory>target</workingDirectory>
<argLine>-Djava.library.path=lib</argLine>
Kalle
On Tue, Nov 4, 2008 at 11:35 AM, Wendy Smoak <ws...@gmail.com> wrote:
> On Tue, Nov 4, 2008 at 9:27 AM, Wendy Smoak <ws...@gmail.com> wrote:
>
> > ...but it only works if the library is sitting in the base directory
> > of the Maven project. If I move it into some other directory and then
> > configure Surefire to pass java.library.path to the tests, I get the
> > same thing Craig was seeing:
> >
> > java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
>
> Craig added a build.xml to the example, so we have it working with Ant
> and failing with Maven/Surefire:
> http://wush.net/svn/wsmoak/testing/trunk/jnitest
>
> There is build output in the README file. At this point someone more
> familiar with JNI and Surefire internals will have to take over. :)
> Craig, if you want to open a JIRA issue, feel free to point to this
> example.
>
> --
> Wendy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Trouble with Java Native Libraries
Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Nov 4, 2008 at 9:27 AM, Wendy Smoak <ws...@gmail.com> wrote:
> ...but it only works if the library is sitting in the base directory
> of the Maven project. If I move it into some other directory and then
> configure Surefire to pass java.library.path to the tests, I get the
> same thing Craig was seeing:
>
> java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
Craig added a build.xml to the example, so we have it working with Ant
and failing with Maven/Surefire:
http://wush.net/svn/wsmoak/testing/trunk/jnitest
There is build output in the README file. At this point someone more
familiar with JNI and Surefire internals will have to take over. :)
Craig, if you want to open a JIRA issue, feel free to point to this
example.
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Trouble with Java Native Libraries
Posted by Wendy Smoak <ws...@gmail.com>.
On Mon, Nov 3, 2008 at 9:40 PM, Wendy Smoak <ws...@gmail.com> wrote:
> I was (eventually, with help from Craig and Henri,) able to follow the
> JNI 'Hello World' example [1] and get it to work both at the command
> line and in a test run with Maven.
...but it only works if the library is sitting in the base directory
of the Maven project. If I move it into some other directory and then
configure Surefire to pass java.library.path to the tests, I get the
same thing Craig was seeing:
java.lang.UnsatisfiedLinkError: no HelloWorld in java.library.path
with
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.library.path</name>
<value>${basedir}/lib</value>
</property>
</systemProperties>
</configuration>
</plugin>
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Trouble with Java Native Libraries
Posted by Wendy Smoak <ws...@gmail.com>.
On Sun, Nov 2, 2008 at 9:36 AM, Craig L Russell <Cr...@sun.com> wrote:
> 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?
...
> Maven version: 2.0.6
Can you reproduce it with 2.0.9 or the latest 2.0.10 release candidate?
I was (eventually, with help from Craig and Henri,) able to follow the
JNI 'Hello World' example [1] and get it to work both at the command
line and in a test run with Maven.
[1] http://java.sun.com/docs/books/jni/html/start.html
--
Wendy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org