0

I am trying to setup CoAP Server using Java library from http://mvnrepository.com/artifact/org.eclipse.californium/californium-core/1.0.1

public class HelloWorldServer extends CoapServer {

    private static final int COAP_PORT = 5683; 
    /*
     * Application entry point.
     */
    public static void main(String[] args) {

        try {

            // create server
            HelloWorldServer server = new HelloWorldServer();
            // add endpoints on all IP addresses
            server.addEndpoint(new CoAPEndpoint(new InetSocketAddress("127.0.0.1", COAP_PORT)));
            server.start();

        } catch (SocketException e) {
            System.err.println("Failed to initialize server: " + e.getMessage());
        }
    }

adding endpoints to server causing below Exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/californium/elements/RawDataChannel at com.landisgyr.chardonnay.HelloWorldServer.main(HelloWorldServer.java:35) Caused by: java.lang.ClassNotFoundException: org.eclipse.californium.elements.RawDataChannel at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more

Is there anyone who go CoAP server working with Californium Java library ?

Ashok
  • 601
  • 1
  • 17
  • 32
  • Possible duplicate of [Californium CoAP Server Error on addEndpoints](http://stackoverflow.com/questions/34896969/californium-coap-server-error-on-addendpoints) – kiranpradeep Feb 08 '16 at 15:57

2 Answers2

2

You need to import element-connector into your Eclipse project.

0

It looks like some parts of the project are missing.

Here is a step-by-step tutorial to run the CoAP HelloWorldServer.

Requirements : Eclipse (+ Egit & Maven Integration Extenstions) , Git , Maven

  1. Open Terminal and execute following commands:

sudo git clone https://github.com/eclipse/californium.core.git

sudo mvn clean install
  1. Open Eclipse and import the Maven Project

  2. After import launch the "HelloWorldServer.java". If anything done correctly it should work.

Endpoint started and working

  1. To test if the resource is avaiable i recommend the Firefox extension "Cupper" which is able to speak CoAP. You just need to open the following URI: coap://localhost:5683
pdunker
  • 263
  • 2
  • 12