Ashok
Ashok

Reputation: 611

Californium CoAP Server Error on addEndpoints

I am trying one of example CoAP server program from https://github.com/eclipse/californium.core/tree/master/cf-helloworld-server/src/main/java/org/eclipse/californium/examples/HelloWorldServer.java

I have used library CoAP from http://mvnrepository.com/artifact/org.eclipse.californium/californium-core/1.0.1

When I run below code to addEndpoints, I get an exception:

 private void addEndpoints() {
        for (InetAddress addr : EndpointManager.getEndpointManager().getNetworkInterfaces()) {
            // only binds to IPv4 addresses and localhost
            if (addr instanceof Inet4Address || addr.isLoopbackAddress()) {
                System.out.println("addr: "+addr.toString());
                InetSocketAddress bindToAddress = new InetSocketAddress(addr, COAP_PORT);
                System.out.println("bindToAddress: "+bindToAddress.toString());
                addEndpoint(new CoapEndpoint(bindToAddress));
            }
        }
    }

Here is the Exception:

Jan 20, 2016 3:24:58 PM org.eclipse.californium.core.network.config.NetworkConfig createStandardWithFile INFO: Storing standard properties in file Californium.properties

addr: /127.0.0.1 bindToAddress: /127.0.0.1:5683

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/californium/elements/RawDataChannel
    at HelloWorldServer.addEndpoints(HelloWorldServer.java:53)
    at HelloWorldServer.main(HelloWorldServer.java:34)
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)
    ... 2 more

I see no file in GitHub Source org/eclipse/californium/elements/RawDataChannel.java is that is the problem !?

I tried to clean and rebuild the project still same issue. Created project again, don't work

Thanks in advance

Upvotes: 0

Views: 622

Answers (1)

en1010
en1010

Reputation: 1300

The answer is old, though maybe the answer will be useful for someone..

There was lack of element-connector library. I'd recommend to use Maven and add californium as a dependency to pom.xml

Upvotes: 0

Related Questions