Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » OM2M » Router Internal Error when running tutorial application
Router Internal Error when running tutorial application [message #1750076] Thu, 15 December 2016 18:46 Go to next message
Yu-Hao Hsu is currently offline Yu-Hao HsuFriend
Messages: 15
Registered: July 2016
Junior Member
Hi,

I followed the tutorial: Develop oneM2M applications to create application to test REST API. I run the MySensor.java, MyActuator.java and then run the MyManager.java.
To my understanding, MyManager.java will subscribe mysensor/data and send notification to /in-cse/in-name/mymanager.

But when I run MyManager.java, I got the following error message:

Quote:

[INFO] - org.eclipse.om2m.core.notifier.Notifier
Sending notify request to: /in-cse/in-name/mymanager
[INFO] - org.eclipse.om2m.core.notifier.Notifier
Sending notify request...
[INFO] - org.eclipse.om2m.core.router.Router
Received request in Router: RequestPrimitive [operation=5,
from=admin:admin,
content={
"m2m:sgn" : {
"nev" : {
"rep" : {
"rn" : "cin_266403336",
"ty" : 4,
"ri" : "/mn-cse/cin-266403336",
"pi" : "/mn-cse/cnt-81533083",
"ct" : "20161216T022158",
"lt" : "20161216T022158",
"st" : 0,
"cnf" : "application/text",
"cs" : 3,
"con" : "293"
},
"rss" : 1
},
"sud" : false,
"sur" : "/mn-cse/mn-name/mysensor/data/managersub"
}
},
requestContentType=application/json,
]
[INFO] - org.eclipse.om2m.core.router.Router
missing ContentType isnull
[INFO] - org.eclipse.om2m.core.router.Router
No Accept parameter set, setting to default: application/xml
[INFO] - org.eclipse.om2m.core.router.Router
Request targeting another CSE, forwarding to Redirector: null
[INFO] - org.eclipse.om2m.core.redirector.Redirector
RemoteCSE found: /in-cse
[ERROR] - org.eclipse.om2m.core.router.Router
Router internal error
java.lang.NullPointerException
at org.eclipse.om2m.core.redirector.Redirector.sendRedirectorRequest(Redirector.java:138)
at org.eclipse.om2m.core.redirector.Redirector.retarget(Redirector.java:84)
at org.eclipse.om2m.core.router.Router.doRequest(Router.java:165)
at org.eclipse.om2m.core.notifier.Notifier.notify(Notifier.java:162)
at org.eclipse.om2m.core.notifier.Notifier$NotificationWorker$1.run(Notifier.java:291)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[INFO] - org.eclipse.om2m.core.router.Router
Response in Router= ResponsePrimitive [responseStatusCode=5000,
content=Router internal error,
to=admin:admin,
from=/mn-cse,
contentType=text/plain,
]


Can anyone give me the instruction to fix this error?
Thank you.
Re: Router Internal Error when running tutorial application [message #1750242 is a reply to message #1750076] Mon, 19 December 2016 09:22 Go to previous messageGo to next message
Guillaume Garzone is currently offline Guillaume GarzoneFriend
Messages: 54
Registered: April 2015
Member
Hi,

Be sure to pull the latest version of the code (mater branch) and recompile the project. This looks a lot like a bug we encountered recently and we corrected it.

Hope this helps,
Guillaume
Re: Router Internal Error when running tutorial application [message #1750308 is a reply to message #1750242] Mon, 19 December 2016 19:05 Go to previous messageGo to next message
Yu-Hao Hsu is currently offline Yu-Hao HsuFriend
Messages: 15
Registered: July 2016
Junior Member
Hi Guillaume Garzone,

Thank you! After I pull the latest version, it works!
But I found that the tutorial code has some error.
In the MyHandler class of MyActuator.java, MyManager.java and MyMonitor.java, when we want to transfer String requestBody to JSONObject,
JSONObject json = new JSONObject(requestBody);

there will have the error message:
A JSONObject text must begin with '{' at 1 [character 2 line 1]

It seems that requestBody is a string with XML format, so it didn't start form '{', it start from '<'.

So then I change the code so that it can transfer XML format to JSONObject
JSONObject json = XML.toJSONObject(requestBody);

then it can works.

But there is another part seems not make sense. In the MySensor.java, it send sensorValue, which is Integer format, to my sensor/data(container). But in the MyHandler of MyManager.java, tutorial use the following code:
String con = rep.getString("con");  
int sensorValue = Integer.parseInt(con);

It use the getString to get the Integer format, I think there may be some error need to be fixed.

Howard

[Updated on: Mon, 19 December 2016 19:06]

Report message to a moderator

Re: Router Internal Error when running tutorial application [message #1750368 is a reply to message #1750308] Tue, 20 December 2016 12:44 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Hello Yu-Hao,
I think getString convert the input to a String value then return it.
The example works in my machine. Did you tried it ?
Re: Router Internal Error when running tutorial application [message #1750602 is a reply to message #1750368] Fri, 23 December 2016 08:27 Go to previous messageGo to next message
Yu-Hao Hsu is currently offline Yu-Hao HsuFriend
Messages: 15
Registered: July 2016
Junior Member
hello Mandi,

when I test the original sample code, I get the following error message in the MyHandler of MyManager.java:

Quote:
org.json.JSONException: JSONObject["con"] not a string.
at org.json.JSONObject.getString(JSONObject.java:721)
at org.eclipse.om2m.app.MyManager$MyHandler.handle(MyManager.java:100)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Did you know why will be this error message happen?
I try to print out the JSONObject rep, but it looks fine like the following:

rep:{"cs":3,"ct":"20161223T162404","st":0,"con":320,"ty":4,"ri":"/mn-cse/cin-284654618","lt":"20161223T162404","pi":"/mn-cse/cnt-795693924","cnf":"application/text","rn":"cin_284654618"}


Re: Router Internal Error when running tutorial application [message #1750606 is a reply to message #1750602] Fri, 23 December 2016 08:44 Go to previous messageGo to next message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Maybe because your "con" is of type integer and so the code should be updated.
Re: Router Internal Error when running tutorial application [message #1750638 is a reply to message #1750606] Fri, 23 December 2016 14:39 Go to previous messageGo to next message
Yu-Hao Hsu is currently offline Yu-Hao HsuFriend
Messages: 15
Registered: July 2016
Junior Member
Mandi,

Yes, I think the problem is just like you said that.
So I replace the code
String con = rep.getString("con");  						
int sensorValue = Integer.parseInt(con);

with the following code:
int sensorValue = rep.getInt("con");


then it works.
Re: Router Internal Error when running tutorial application [message #1750639 is a reply to message #1750638] Fri, 23 December 2016 14:53 Go to previous message
Mahdi Ben Alaya is currently offline Mahdi Ben AlayaFriend
Messages: 229
Registered: November 2013
Senior Member
Nice! Feel free to improve the wiki.
Previous Topic:Security in OM2M release1
Next Topic:MN-CSE dynamic IP
Goto Forum:
  


Current Time: Thu Mar 28 10:55:51 GMT 2024

Powered by FUDForum. Page generated in 0.02271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top