3 Replies Latest reply on Sep 21, 2015 7:37 PM by RyanISD196

    RESTful webservice not reliable

    RJacobs Level 1

      I've successfully created/registered a rest service, but I'm having trouble keeping it alive.

       

      I can understand that a change in code needs a refresh of the service (in administrator or restinitapplication), but the following situations also break a service

       

      • "clear template cache" button in administrator
      • restart of server

       

      And the only way to handle this, is to write a scheduled task which polls the service and calls restinitapplication when it does not respond.

       

      Even if I set the scheduled task to run every 5 minutes, it's still possible that the service is totally unavailable for 4+ minutes.

       

      Other frameworks like Taffy does not have this problem.

       

      Why should i opt for REST if SOAP works many times better? Or am I missing something?

        • 1. Re: RESTful webservice not reliable
          Steve Sommers Level 4

          Need more data. From your request it seems you're focusing more on the bandage than the cause or cure. I have written both REST and SOAP handlers that are running on production servers without any issues keeping them alive. I would start by checking the web server logs, followed by checking the ColdFusion logs. Also I have found over the years to be generous with my own logging using log4j or simply using the cflog tag.

          • 2. Re: RESTful webservice not reliable
            RJacobs Level 1

            Thanks for the feedback Steve. I agree it sounds more like a bandage.

             

            Directory layout:

            application.cfc

            /API

                 rootSVC.cfc

             

            I use the following code:

             

            Application.cfc

            <cfcomponent>

              <cfset This.name = "restExample">

              <cfset this.restsettings.cfclocation = "API" />

                <cfset this.restsettings.skipCFCWithError = true />

              <cffunction name="onApplicationStart">

              <cfset initapp()/>

              </cffunction>

              <cffunction name="onRequestStart">

              <cfif isdefined("url.initapp")><cfset initapp()/></cfif>

              </cffunction> 

              <cffunction name="INITAPP">

              <cfset restinitapplication(expandpath("."), "example")/>

              </cffunction>

            </cfcomponent>

             

            rootSVC.cfc

            component rest=true restpath="/" {

              remote void function get() httpmethod="get" produces="text/json" {

              var result = { 'ts'= now() };

              restSetResponse({status=200,content=serializejson(result)});

              }

            }

             

             

            Steps to reproduce:

            Step 1: register rest service (administrator or restinitapplication)

            Step 2: call /rest/example/ -> everything OK

            Step 3: clear template cache in administrator

            Step 4: call /rest/example/ -> empty response with header 'server-error:true' ; no logging possible in the application because it doesn't exist apparently. It also returns http 200 OK and not even a 500, so 3rd party clients think everything was ok, but in reality no data was processed.

             

            The only way to get the service going again is to either manually refresh in the administrator or call restinitapplication.

             

             

             

             

            Coldfusion-out.log says:

            Jun 3, 2014 12:34:06 PM Error [ajp-bio-8014-exec-6] - The CFC C:\DATA\WWWROOT\test\API\rootSVC.cfc is modified and the application is not refreshed.Refresh the application. The specific sequence of files included or processed is: C:\DATA\WWWROOT\test\API\rootSVC.cfc''

             

            Coldfusion-error.log

            Jun 03, 2014 12:34:06 PM com.sun.jersey.server.impl.application.WebApplicationImpl _handleRequest

            SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container

            coldfusion.rest.component.CFComponentProvider$ModifiedResourceException: The CFC C:\DATA\WWWROOT\test\API\rootSVC.cfc is modified and the application is not refreshed.

              at coldfusion.rest.component.CFComponentProvider.getInstance(CFComponentProvider.java:130)

              at coldfusion.rest.component.CFComponentProvider.getInstance(CFComponentProvider.java:70)

              at com.sun.jersey.server.impl.application.WebApplicationContext.getResource(WebApplicationCo ntext.java:238)

              at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)

              at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)

              at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRu le.java:84)

              at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationIm pl.java:1511)

              at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationIm pl.java:1442)

              at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImp l.java:1391)

              at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImp l.java:1381)

              at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)

              at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)

              at coldfusion.rest.servlet.CFRestServletContainer.service(CFRestServletContainer.java:141)

              at coldfusion.rest.servlet.CFRestServletContainer.service(CFRestServletContainer.java:86)

              at coldfusion.rest.servlet.CFRestServlet.serviceUsingAlreadyInitializedContainers(CFRestServ let.java:556)

              at coldfusion.rest.servlet.CFRestServlet.invoke(CFRestServlet.java:434)

              at coldfusion.rest.servlet.RestFilter.invoke(RestFilter.java:58)

              at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94)

              at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8)

              at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)

              at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)

              at coldfusion.rest.servlet.CFRestServlet.invoke(CFRestServlet.java:409)

              at coldfusion.rest.servlet.CFRestServlet.service(CFRestServlet.java:400)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

              at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:303)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

              at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 )

              at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:241)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:422)

              at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:198)

              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.jav a:607)

              at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)

              at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

              at java.lang.Thread.run(Unknown Source)

            1 person found this helpful
            • 3. Re: RESTful webservice not reliable
              RyanISD196

              Any progress on this issue, or did you ditch CF REST services? I'm running into something similar, where the service randomly thinks something was modified, but really nothing has been. "500 The application ___ is modified and not refreshed." I found a bug talking about cache being cleared, which makes me think garbage collection. Seems that the issue cannot be caught by the Application.cfc onError() handler either!

               

              https://bugbase.adobe.com/index.cfm?event=bug&id=3850183