1

I have below simple function in an adapter, when i am calling it from the App, it hangs the WL Studio and gives recursive exceptions.

Adapter Function

function listSummaries3009Details(param){
       var obj = com.MQNotifier.SimplePTP();
       var result = obj.getListSummaries3009(param) ;
       WL.Logger.debug("inside adapter :" + result);

       var xmlDoc = new XML(result);
     return { result : xmlDoc }; 
}

Exception:

Error for /apps/services/api/myApp/common/query; java.lang.StackOverflowError
Error for /apps/services/api/myApp/common/query
     com.worklight.server.integration.api.JSObjectConverter.scriptableToJSON(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.getRecursiveValue(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.createJSONObject(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.nativeObjectToJSON(Unknown Source)
                                      com.worklight.server.integration.api.JSObjectConverter.scriptableToJSON(Unknown Source)
                                      com.worklight.server.integration.api.InvocationResult.toJSON(Unknown Source)
                                      com.worklight.gadgets.serving.handler.query.JSONFeedGenerator.generateFeed(Unknown Source)
                                      com.worklight.gadgets.serving.handler.BackendQueryHandler.getContent(Unknown Source)
                                      com.worklight.gadgets.serving.handler.BackendQueryHandler.doPost(Unknown Source)
                                      com.worklight.gadgets.serving.GadgetAPIServlet.doGetOrPost(Unknown Source)
                                      com.worklight.gadgets.serving.GadgetAPIServlet.lockedGetOrPost(Unknown Source)
                                      com.worklight.gadgets.serving.GadgetAPIServlet.doPost(Unknown Source)
                                      javax.servlet.http.HttpServlet.service(Unknown Source)
                                      javax.servlet.http.HttpServlet.service(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.FilterChainImpl.doFilter(Unknown Source)
                                      com.worklight.core.auth.impl.AuthenticationFilter$1.execute(Unknown Source)
                                      com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(Unknown Source)
                                      com.worklight.core.auth.impl.AuthenticationFilter.doFilter(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.FilterRegistration.doFilter(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.FilterChainImpl.doFilter(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(Unknown Source)
                                      org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(Unknown Source)
                                      javax.servlet.http.HttpServlet.service(Unknown Source)
                                      org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(Unknown Source)
                                      org.mortbay.jetty.servlet.ServletHolder.handle(Unknown Source)
                                      org.mortbay.jetty.servlet.ServletHandler.handle(Unknown Source)
                                      org.mortbay.jetty.servlet.SessionHandler.handle(Unknown Source)
                                      org.mortbay.jetty.handler.ContextHandler.handle(Unknown Source)
                                      org.mortbay.jetty.handler.HandlerWrapper.handle(Unknown Source)
                                      org.mortbay.jetty.Server.handle(Unknown Source)
                                      org.mortbay.jetty.HttpConnection.handleRequest(Unknown Source)
                                      org.mortbay.jetty.HttpConnection$RequestHandler.content(Unknown Source)
                                      org.mortbay.jetty.HttpParser.parseNext(Unknown Source)
                                      org.mortbay.jetty.HttpParser.parseAvailable(Unknown Source)
                                      org.mortbay.jetty.HttpConnection.handle(Unknown Source)
                                      org.mortbay.io.nio.SelectChannelEndPoint.run(Unknown Source)
                                      org.mortbay.thread.QueuedThreadPool$PoolThread.run(Unknown Source)

now if I run the above adapter function like the below one then it works fine.

function listSummaries3009Details(param){
       var obj = com.MQNotifier.SimplePTP();
       var result = obj.getListSummaries3009(param) ;
       WL.Logger.debug("inside adapter :" + result);

       var xmlDoc = new XML(result);
     return { result : result }; 
}

Please suggest how to get out of this?

Thanks

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
AAhad
  • 2,805
  • 1
  • 25
  • 42

1 Answers1

1

You have no way to stop the recursion. This is a bug in your code. You should have something at the beginning of the function to terminate it.

rooftop
  • 3,031
  • 1
  • 22
  • 33
  • Can you please highlight where the bug is? and how to fix it. I know the listSummaries3009Details function has issue but i dont know how i handle the xml object and process it. Currently i am using "new XML()" to create xml parser object, which perfectly works and even then i can parse or get any item from it. But in my case i have to send back whole xml converted object, where it fails and goes into recursion. Thanks – AAhad Jun 10 '13 at 08:50