Hopefully someone can help as I have just about torn whats left of my hair out, and worn out my fingers searching google and various forums trying to find a solution ...
I am putting together a home automation system based on the OpenZWave libraries, my system is Debian Linux, I am running a TomcatV7 Server to which I communicate with from an Android app, all this is working ok, all software is being built using Eclipse INDIGO. I have wrapped the OpenZWave library with a library called OpenZWrap which will have its methods exposed as extern 'C's for access by code running under tomcat. At the moment to simplify things I have removed all references to OpenZWave from the wrapper library and just have a simple no parameter test method which does a printf.
// Test Code extern "C" void test1() { printf(">>> test1 called <<<\n"); }
The JNA interface is as follows:
package com.birdsoft.birdhouse.control.interfaces; import com.sun.jna.Library; import com.sun.jna.Native; public interface OpenZWrapJNA extends Library { OpenZWrapJNA INSTANCE = (OpenZWrapJNA) Native.loadLibrary("OpenZWrap", OpenZWrapJNA.class); void test1(); }
Ihave code which runs on startup of Tomcat which tries to use the JNA interface
// Test connection to OpenZWrap OpenZWrapJNA jnaIf = OpenZWrapJNA.INSTANCE; jnaIf.test1();
When the 'OpenZWrapJNA jnaIf = OpenZWrapJNA.INSTANCE;' line above is executed when the server starts I get :
EVERE: Exception sending context initialized event to listener instance of class com.birdsoft.birdhouse.control.startup.HardwareInt erfaceController
java.lang.NoClassDefFoundError: com/sun/jna/NativeLibrary
at com.birdsoft.birdhouse.control.startup.HardwareInt erfaceController.contextInitialized(HardwareInterf aceController.java:33)
at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInte rnal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(Lifec ycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.java:1566)
at org.apache.catalina.core.ContainerBase$StartChild. call(ContainerBase.java:1556)
at java.util.concurrent.FutureTask$Sync.innerRun(Futu reTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.jav a:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.NativeLibrary
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1711)
at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1556)
... 11 more
26-Apr-2012 11:57:54 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
26-Apr-2012 11:57:54 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/BirdhouseControlService] startup failed due to previous errors
Context Destroyed
26-Apr-2012 11:57:54 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8081"]
In the TomcatServer project settings I have added the JavaNativeLibray JNA.jar and under this the location my OpenZWrap library.
Any guidance gratefully received .. I thought I new java quite well but this has stumped me so far!