0

I've tried to send a CoAP message to IN-CSE in OM2M but IN-CSE printed NullpointerException like the picture I've uploaded.

I solved the problem by modifying CoAPServer class in OM2M source code.

I think the problem is "to=coap://localhost/~/in-cse" so I modified requestPrimitive.setTo(request.getURI()) to request.Primivice.setTo(request.getOptions().getURIString()) in CoAPServer class.

I think this way is not good, I don't know how to solve the problem without modifying the code...

If anyone knows any other way, let me know.

Thanks

-- append

I found the solution to remove the error.

First, I checked the OM2M version released. and I tried to send CoAP message to old version(1.0.0). then It was transferred well without problem. but the latest version had an error. So I compared the two codes.( I focused on CoapServer.java in org.eclipse.om2m.binding.coap)

In Coapserver.java, service() create a requestPrimitive object and transfer to Router.java. and It puts the targetId as a "to" variable in the requestPrimitive object via setTargetId() (setTargetId() calls setTo()) in 1.0.0 version. but In the latest version, it puts the string returned getURI() as a "to" variable in the requestPrimitive object. (and in the latest version it does not seem to use targetId unless I use it.)

targetId contained "/in-cse" and getURI() returned "coap://localhost/~/in-cse".

enter image description here

enter image description here

The lastest version removed setTargetId() in reqeustPrimitive class. so when I modified setTo(getURI()) to setTo(targetId), it was transferred well.

enter image description here

enter image description here

Is this the bug of the lastest version? or am I doing something wrong?

김소용
  • 1
  • 2
  • 1
    Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Yassin Hajaj May 27 '18 at 13:19
  • NullPointerException because in [`CoapServer.java:281`](https://git.eclipse.org/c/om2m/org.eclipse.om2m.git/tree/org.eclipse.om2m.binding.coap/src/main/java/org/eclipse/om2m/binding/coap/CoapServer.java#n281): `if (statusCode.equals(ResponseStatusCode.OK)) {` the parameter `statusCode` is `null`. – howlger May 27 '18 at 14:17
  • Perhaps you should ask this question in the [Eclipse om2m forum](https://www.eclipse.org/forums/index.php?t=thread&frm_id=280). – Andreas Kraft May 27 '18 at 20:58

0 Answers0