Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: That old JNA NoClassDefFound Error

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Location
    Somerset, UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default That old JNA NoClassDefFound Error

    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!


  2. #2
    Junior Member
    Join Date
    Apr 2012
    Location
    Somerset, UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: That old JNA NoClassDefFound Error

    Fixed the problem at the expense of the rest of my hair .. I added the jna.jar file to the classpath in the the service run configuration.

Similar Threads

  1. NoClassDefFound
    By Javabeginner in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 5th, 2010, 07:40 AM