Spring Insight

| | Comments (0) | TrackBacks (0)
In trying to profile my grails application I stumbled upon a video that discusses how to use Spring Insight to really get into what is taking the time to deliver a page.

The first issue I ran into is I could not get Maven to deploy my grails app into the running tomcat. The default developer tc server has not defined users. I modified it to:

<tomcat-users>
<role rolename="manager"/>
<user username="admin" password="" roles="manager"/>
</tomcat-users>  

That was not quite enough. I ultimately ended up using the gui manager to deploy the war. If I get it solved I will post it up.
Add the reference to the run/debug configurations.

Specifically add this to the VM Parameters:
-javaagent:/path/to/newrelic/newrelic.jar -Dnewrelic.environment=development


When you restart your grails app the information will be sent to newrelic.


MongoDB and Grails Integration testing

| | Comments (0) | TrackBacks (0)
Ran into an interesting problem today.

The integration tests I was writing for the new Grails app were failing. The objects seemed to be created properly but nothing was persisting to Mongo. I was going through lots of different ways to instantiate the domain object and nothing seemed to work. 

But I got an idea when some debugging statements were coming through the grails testing reports (if you look towards the bottom of the reports that grails generates... the system.out and the system.err). It was successfully running the service and coming back with nothing in the layer. Perhaps it was not hitting mongo?

I watched the mongo server and it was getting a connection, but still nothing happened. Perhaps my objects were not being instantiated or being rolled back as part of transaction even though I had commented out my teardown code. No go, even existing objects were missing.

Turns out that the Hibernate plugin had been re-enabled. When the Hibernate plugin for Grails is enabled the mongodb plugin seems to be missing the hooks for the integration tests to work.

TLDR: If your Grails integration tests are failing and you are using Mongo, consider deleting your Hibernate plugin.

Evernote on Linux

| | Comments (0) | TrackBacks (0)
Ang and I have wanted some way to share notes and to-do lists online. We tried quite a few of them and most have some serious limitations. Between us we are on Windows, Linux, Mac, iPhone, and Android and not much works on all of them. Evernote is the closest but Evernote does not work on Linux.

Or does it?

While taking a closer look at some of the online alternatives (OneNote, which crashes and has other annoyances on the Chrome browser) I noticed that someone had successfully installed Evernote on Wine. 

So I gave it a shot. It did install just fine. Evernote even automatically retrieved all of my notes from the online database which was really nice to see.

But, then the problems started. It does not look very good. Not a huge deal but certainly looks clunky. It was really really slow, And, it used quite a bit of cpu and disk. Still, perhaps good enough if I can make most of my updates via my Android.

The next day there was an alert on my screen. My filesystem had only a few megs of space left.

Apparently, Evernote was causing silent errors to get logged. 28GB of hidden log files! So, Evernote on Linux works... kinda.

But it is not worth the effort.

ColdFusion JRun Error

| | Comments (0) | TrackBacks (0)
Another great bug.

I was logged into a little app I was writing and an error was appended to every page at the very bottom after all of the debugging information. I created a new blank.cfm page with nothing in it and the error still occurred. The first suspect was the application.cfm as it is the only thing that was being run (I never use the end.cfm). Ripping line by line it turns out that the cfapplication itself is the only tag required to cause the problem. Not only is it the only tag required but if you change the application name the problem goes away. Curious.

Revert back to the base case and restart the server but change the app name and it appears to work for the login page. But if you login or even fail a login the error comes back. Lovely, there is something that happens at login that crashes/corrupts the application. If you change the application name afterwards then you are logged in and your errors disappear. 

There are actually a few different possibilities:
  • Something is wrong with your access to the clientstore (specifically the CDATA).
  • Something evil has happened to your client variable.
In our case a new CF developer had used structdelete on the client variable to log them out. When you reach the end of the page the JRun calls a persist on the client variable and that call is failing.

This is what the error looks like:
<head><title>JRun Servlet Error</title></head><h1>500 null</h1><body> </body>

In the JRun you will see this: "java.lang.NullPointerException" and the important line is: coldfusion.runtime.ClientScopeServiceImpl.PersistClientVariablesForRe
quest(ClientScopeServiceImpl.java:226)


Coldfusion Data Source Issue

| | Comments (0) | TrackBacks (0)
"The data source named "Cookie" is not a valid client storage DSN."

A very interesting error. The call looks like this:

<cfapplication name="myApplication"
    setdomaincookies="no"
    clientmanagement="Yes"
    sessionmanagement="NO"
    setclientcookies="YES"
    clientstorage="Cookie">

Nothing unusual at all. In fact, the file had not been changed in 2 years. It turns out that the neo-clientstore.xml had the reference to the cookie removed. You need to have an entry that looks like this:

<var name='Cookie'>
    <struct type='coldfusion.server.ConfigMap'>
        <var name='type'><string>COOKIE</string></var>
        <var name='name'><string>Cookie</string></var>
        <var name='description'><string>Client based text file.</string></var>
        <var name='timeout'><number>10.0</number></var>
        <var name='disable_globals'><boolean value='false'/></var>
        <var name='purge'><boolean value='true'/></var>
    </struct>
</var>

Without it the server does not know what the cookie type is for that tag.

JBoss Subscription Management

| | Comments (0) | TrackBacks (0)
The default management tools for a queue or topic is pretty poor.

Specifically we really want to be able to create/list/delete subscriptions through a lightweight app. I wrote one that automatically spots all of the topics and will make the required calls to list off the current subscriptions and make it easy to duplicate/delete/add subscriptions.

We got a chance to use it live this past weekend and it worked like a charm.

Bonus.... I rolled it into it's own war so deployment was killer easy (embedding it in a producer can be painful).

Need to post the code sometime soon.

Topic is stopped.

| | Comments (0) | TrackBacks (0)
WARN  [org.jboss.jms.server.destination.TopicService] Topic is stopped.

-- and --

WARN  [org.jboss.jms.server.destination.QueueService] Queue is stopped.


We got these in the logs this morning and it was associated with a JBoss server not working properly. There is not a lot of information on these available via Google and we needed to find out what the problem was with the topics. 

In the logs we could see each of the topics and queues starting and then a few of these mystery messages about the Topic being stopped. Afterwards we started to get some errors like "There is no administratively defined topic with name:myTopic". 

The answer turned out to be that it is based on time. That WARN is thrown inside of several messaging routines when the server/messaging/topic is not started yet. As we have put more subscriptions on the topic it has taken longer to start and the warnings that come in are just the requests to do something on the topic that is not ready yet.

Ultimately the server took about 18 minutes to start up, once it started it was fine. If you are seeing this warning/error you may want to look at ways to improve the database performance behind the startup. We are going to add indexes on a few of the key columns to improve startup times.




Blackberry Emulator PIN

| | Comments (0) | TrackBacks (0)
If you develop for the Blackberry you may have run into a registration problem. The blackberry emulator has a fixed PIN and many applications use this PIN as the key for their security routines. SyncJE does it for their mobile syncronization software. This is fine as we have purchased several licenses but we have multiple developers trying to get the software to work on the emulator and we needed a way to change the BlackBerry Emulator PIN.

Turns out it is pretty easy. There is a .BAT file that starts up the emulator and the pin it uses is embedded in that file. On the second line you should see: "/pin=0x2100000A" towards the end of the line. Just change that to something else (valid hex) and restart the emulator. Anything that is registered to the old pin will be broken... but it will allow you to register new apps with the custom pin.


PHP FOpen and RSS feeds

| | Comments (0) | TrackBacks (0)
Do not use FOpen for reading streams over http. 

While working on a change for one of our associated sites I noticed that in staging the RSS feeds were not showing up and we were getting bad characters in the XML. At first I thought that we could be dealing with the Byte-Order-Marker (BOM) that unicode files have before the start of the actual document. I could see the text before the XML declaration (which was causing the problem) and could trap for it... but it did not look like a BOM.

That worked, for a little while. What was odd was that production did not have a similar problem and it had the same version of just about everything. What broke it again was a longer XML post. The RSS feed got to be a few characters longer.

The problem was http 1.0 vs http 1.1. Our production self calls are forced to http 1.0 and everywhere else is http 1.1. With 1.1 the data comes in chunks with a size. Those size declarations were breaking the XML. The underlying problem is that PHP's fopen cannot handle http 1.1 correctly and you need to either write your own handler for the data capturing the size information and behaving appropriately or move to some other method which is better suited for opening http streams like CURL.

Lesson? FOpen is cool and while it can be used to read web streams... use it for files and use CURL for web transfer.