• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

RESTful webservice not reliable

New Here ,
Jun 01, 2014 Jun 01, 2014

Copy link to clipboard

Copied

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?

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 02, 2014 Jun 02, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 03, 2014 Jun 03, 2014

Copy link to clipboard

Copied

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(WebApplicationContext.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(RootResourceClassesRule.java:84)

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

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

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

  at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.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(CFRestServlet.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:28)

  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.java: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.java: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.java: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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 21, 2015 Sep 21, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2019 Jan 14, 2019

Copy link to clipboard

Copied

LATEST

My guess is you didn't see an application timeout in the Application.cfc, so it is defaulting to whatever is the default application life.  Create an Application.cfc in what you selected as the rest root directory and at least include the "applicationTimeout" value.  In the example below it is set to 1 day with a session timeout of 4 hours.

<cfscript>

        this.applicationTimeout = createTimeSpan(1,0,0,0);

        this.clientmanagement= "yes";

        this.loginstorage = "session" ;

        this.name = "myRestAppName">

        this.datasource = "restDb">

        this.sessiontimeout = createTimeSpan(0,4,0,0);

        this.sessionmanagement = "yes";

</cfscript>

You can run the rest service without an Application.cfc, but if you do you might run into the problems you are encountering.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation