How to trace Coldfusion template execution in details? - coldfusion

I have some 'spaghetti'-style code that is generously saused with Custom tags and Stored procedures calls. Templates include each other, custom tags nested and stored procedures are callind other stored procedures in their place.
Problem is that one template call is hanging somewhere in between. I cannot get any error out and cannot see debug output. What is best way to debug such 'hanging' request with as much detail as possible ?
Thanks!

If you are using CF 8+, you can use the Step Debugging tools in Eclipse to step through the code: http://www.adobe.com/devnet/coldfusion/articles/debugger.html
If you are using an earlier version, you can use a 3rd party product like Fusion Debug ( http://www.fusion-debug.com/fd/ ) to do the same thing.
If you are using CF8, you can also use the CF Admin Server Monitor to see where a thread is hanging as well: http://www.adobe.com/devnet/coldfusion/articles/monitoring_pt1.html

If the built-in debugger is of no use cause the request just hang the other quick way is to just start with a cfabort at the top and keep moving it down until you hit the file causing the request to hang.

CFTrace is a great tool for this. It is native and reports time information as well.

Have you looked at the standard coldfusion server log files to see what might be in there?
Have you run the server in a console window so you can see what is appearing in the console as the templates are running (or not as the case might be)?

You could Take jvm thread dumps. You can do from command line or via server monitoring if you have Enterprise 8+

Related

Timeout when starting a Service in Windows

We're currently facing some issues trying to start a Service in Windows, which is an executable file and the output of a compiling process using .NET framework for C++ (Windows\Microsoft.NET\Framework\v2.0.50727).
We are able to compile, start and execute the exact same service in our DEV Environment, which consists of Windows 7 installed in Virtual Box with VisualStudio2005 (it's old software, I know...).
When we do it in our Test environment, we get a timeout error when trying to start the Service (1053: The Service Did Not Respond to the Start or Control Request in a Timely Fashion.). The server is running WindowsServer 2008 R2 Standard. We already tried to change the timeout time, without success. We also compiled the source code using the same Visual Studio 2005 SW and although we were able to compile it successfully we are still getting the same timeout message.
We are currently trying to understand what's objectively causing the different behaviour. The most obvious difference is the windows version, naturally, but since the compilation output appears identical and there are no errors during the compilation process in both environments and both output logs are identical as well we are running low on ideas to identify and validate objective differences. Our latest approach consists in trying to understand if by using Dependency Walker (dependencywalker.com) we are able to identify any issue regarding DLLs (we also checked if there is any corrupt DLL or system file in the environment and there isn't any, using the windows command for it). We're also checking some of the suggestion made on the following post: Error 1053 the service did not respond to the start or control request in a timely fashion.
Any one faced a similar issues? If so, can you suggest any kind of approach to identify the reason why the service isn't staring, other than the ones here mentioned?
Thanks in advance.
We ended up extending the timeout time regarding Service startup in Windows to 10 minutes followed by the necessary restart and we managed to start the service normally and almost immediately, which makes us think that the timeout time was never really an issue here. Although we haven't been able to pinpoint the exact cause we are still inclined to think that it was a Windows/Server related issue.

Profiling a Play framework application (2.0.2) through VisualVM

I'm having some serious problems regarding my Play! Applications performance. I already tried to change the server and the data base, but the slowness persists.
Using Firebug to measure my http requests I found out that they are taking around 20 seconds just to start replying.
So my last hope is to use VisualVM to profile my application and find its bottle necks. But I don't know the proper way of passing some arguments like -Dcom.sun.management.jmxremote without messing with the global JAVA_OPTS variable.
Thanks again!
It looks like Metrics handles this automatically.
Add the following to your Build.scala app dependencies:
"com.yammer.metrics" % "metrics-core" % "2.1.2"
And start instrumenting your code. Then start up the application with "play run" -- VisualVM should show your JVM process and you can just connect to it directly (assuming you have the VisualVM-MBeans plugin). Check to see if you have at least 1.3.4. This is what I see when I start up:
the xsbt.boot.Boot process is Play.
More generally, this article really helps when debugging Akka based frameworks like Play.
In case someone needs to profile a Play 2.3.x app:
Put your JAVA_OPTS settings in ~/.activator/activatorconfig.txt (c.f. https://typesafe.com/activator/docs):
-Dcom.sun.management.jmxremote.port=1234
-Dcom.sun.management.jmxremote.rmi.port=1234
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=127.0.0.1
In VisualVM, add a Local JMX connection to localhost:1234

How do I get a `callFrameID` to pass to `Debugger.evaluateOnCallFrame`?

WebKit's Remote Debugging Protocol went 1.0 recently and I've been playing around with it a little, mostly out of curiosity and interest. I've thrown together a very basic recreation of Chrome's developer tools console as a replacement front-end, but I'm a little confused as to how I can execute code in a specific frame/window like Chrome's Dev Tools allow you to.
At the moment, I'm using the Runtime.evaluate method to execute my console input. This seems inadequate because of the aforementioned problem and it doesn't provide the command line API. I've discovered the Debugger.evaluateOnCallFrame method, which requires a callFrameID parameter. The only problem is, it doesn't seem possible to remotely acquire a list of callFrame objects to pass to this method.
I have a feeling I'm completely missing something here. Does anyone know the solution?
Have a look at the Debugger.paused event, which will give you an array of current call frames.

Selenium wait for download?

I'm trying to test the happy-path for a piece of code which takes a long time to respond, and then begins writing a file to the response output stream, which prompts a download dialog in browsers.
The problem is that this process has failed in the past, throwing an exception after this long amount of work. Is there a way in selenium to wait-for-download or equivalent?
I could throw in a Thread.sleep, but that would be inaccurate and unnecessarily slow down the test run.
What should I do, here?
I had the same problem. I invented something to solve the problem. A tempt file is created by Python with '.part' extension. So, if still we have the temp, python can wait for 10 second and check again if the file is downloaded or not yet.
while True:
if os.path.isfile('ts.csv.part'):
sleep(10)
elif os.path.isfile('ts.csv'):
break
else:
sleep(10)
driver.close()
So you have two problems here:
You need to cause the browser to download the file
You need to measure when the downloaded file is complete
Neither problemc an be directly solved by Selenium (yet - 2.0 may help), but both are solvable problems. The first problem can be solved by GUI automation toolkits, such as AutoIT. But they can also be solved by simply sending an automated keypress at the OS level that simulates the enter key (works for Firefox, a little harder on some versions of Chrome and Safari). If you're using Java, you can use Robot to do that. Other languages have similar toolkits to do such a thing.
The second issue is probably best solved with some sort of proxy solution. For example, if your browser was configured to go through a proxy and that proxy had an API, you could query the proxy with that API to ask when network activity had ended.
That's what we do at http://browsermob.com, which is a a startup I founded that uses Selenium to do load testing. We've released some of the proxy code as open source, available at http://browsermob.com/tools.
But two problems still persist:
You need to configure the browser to use the proxy. In Selenium 2 this is easier, but it's possible to do it with Selenium 1 as well. The key is just making sure that your browser launcher brings up the browser with the right profile/settings.
There currently is no API for BrowserMob proxy to tell you when network traffic has stopped! This is a big hole in the concept of the project that I want to fix as soon as I get the time. However, if you're keen to help out, join the Google Group and I can definitely point you in the right direction.
Hope that helps you identify your various options. Best of luck!
This is Chrome-testing-only solution for controlling the downloads with javascript..
Using WebDriver (Selenium2) it can be done within Chrome's chrome:// which is HTML/CSS/Javascript:
driver.get( "chrome://downloads/" );
waitElement( By.CssSelector("#downloads-summary-text") );
// next javascript snippet cancels the last/current download
// if your test ends in file attachment downloading
// you'll very likely need this if you more re-instantiated tests left
((JavascriptExecutor)driver).executeScript("downloads.downloads_[0].cancel_();");
There are other Download.prototype.functions in "chrome://downloads/downloads.js"
This suites you if you just need to test some info note eg. caused by file attachment starting activity, and not the file itself.
Naturally you need to control step 1. - mentioned by Patrick above - and by this you control step 2. FOR THE TEST, not for the functionality of actual file download completion / cancel.
See also : Javascript: Cancel/Stop Image Requests which is relating to Browser stopping.
This falls under the "things that can't be automated" category. Selenium is built with JavaScipt and due to JavaScript sandbox restrictions it can't access downloads.
Selenium 2 might be able to do this once Alerts/Prompts have been implemented but that this won't happen for the next little while yet.
If you want to check for the download dialog, try with AutoIt. I use that for uploading and downloading the files. Using AutoIt with Se RC is easier.
def file_downloaded?(file)
while File.file?(file) == false
p "File downloading in progress..."
sleep 1
end
end
*Ruby Syntax

Using OSSOLOG in scratchbox (maemo development)

I am building a sharing-service for maemo5. In the example plugin they are calling ULOG_INFO_L at a lot of places, so I have adopted this for my service as well. The problem is that I can't find where the messages goes.
Reading osso-log.h I should define DEBUG or OSSOLOGCOMPILE, which I do and OSSOLOG_STDOUT or OSSOLOG_SYSLOG. I have tried both settings but can't get anything on syslog or stdout (I have no idea where stdout should end up since I am only calling af-sb-init.sh start), and it's not there anyway :-)
Anyone know where I can find my log?
I found out that when using OSSOLOG_SYSLOG it actually logs to the host machine, not the scratchbox environment.