... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2010-06-22

Debugging Output in T-SQL

Here is a useful way to get debugging output while using SQL Server T-SQL:

DECLARE @message NVARCHAR(MAX)
SELECT @message = (
  SELECT something, andSomethingElse
  FROM someTable
  FOR XML AUTO
)
SELECT @message = REPLACE(@message, '><', '>'+CHAR(13)+'<')
RAISERROR(@message, 16, 1)

It is pretty cheesey, but it works in difficult contexts (e.g. restricted privileges, many tiers between you and the SQL server, unit tests that run in rolled back transactions).

2010-06-10

Apache CXF (née XFire)

XFire, the SOAP engine, is now known as Apache CXF.

One advantage of CXF/XFire over Apache Axis is that the client supports NTLM using ambient credentials on Windows. This is because CXF uses the native JDK NTLM support, whereas Axis uses a pure Java reverse-engineered implementation of NTLM 1.0 (with no 2.0+ support on the horizon).

2010-06-08

Leading Slash vs. ClassLoader.getResource()

When using the Java API ClassLoader.getResource(), be sure that your resource path does not start with a slash. If you do, then the result will be null. This behaviour is different from Class.getResource(), where a leading slash has special meaning.

At least, this is how Sun's implementation behaves. The Javadoc for ClassLoader.getResource() is not too clear on this point (although the implication is there). I found this out by reading the source.

I found this problem while troubleshooting a pesky unit test that would work within Eclipse when run as a JUnit Plug-in Test, but would fail when run as a basic JUnit Test. It turns out that the Eclipse implementation of ClassLoader.getResource() is tolerant of the leading slash. Almost everywhere in the code base, the resource names were correct and did not have a leading slash. In the particular case in point, however, a leading slash had been inadvertently added -- a difficult mistake to spot.

Blog Archive