Cannot use Log when Implementing Input / Output Transformer

This is more of an educational post rather than how to do something, but I was wondering why I got the following error message when trying to Implement IPSItemOutputTransformer and IPSRequestPreProcessor (and then setting this up in the pre-processing and post-processing tabs on a content type in workbench):


[com.percussion.server.PSServerLogHandler] appid: 0 type: 1 time: Fri Jan 23 11:10:57 EST 2009 msg: An internal error (end-condition) was encountered. An unexpected exception occurred:
An unexpected exception occurred. The reason was: java.lang.NullPointerException. Please consult the log for further information..
The call-stack was:
java.lang.NullPointerException
at location.to.my.class.processResultDocument(MyClassName.java:41)
	at com.percussion.data.PSExtensionRunner.processResultDoc(Unknown Source)
	at com.percussion.data.xb.runPostProcessingExtensions(Unknown Source)
	at com.percussion.data.xb.runPostProcessingExtensions(Unknown Source)
...

I tracked the problem down to the fact that i was using a logger via:


protected static final Log LOGGER = LogFactory.getLog(MyClassName.class);

What threw me off was when I implemented the preprocessor class and then called it in the “Input Transform” tab, it worked. I was only getting the error if I called the extension in the pre-processing/post-processing tabs. (However, i want my extension to fire every time it goes through the workflow for reasons that i might make another post about) Removing the logging allows the extension to work without throwing that error.

Can some java guru explain what is going on behind the scenes that causes this error?

Thanks!
Jit

Jit,

Just curious, did you have “Tracing” enabled in your editor application?

The code you are failing in appears to be related to tracing, but I cannot tell without some further info.

Also, what happens if your Logger is “private” rather than “protected”?

Dave

Dave,
I am not sure what you mean by

“Tracing” enabled in your editor application?

Do you mean in the logging via log4j?

Changing the Logger to private still causes the null pointer exception to show up. The interesting thing is that while the editing screen of a pre-existing content item will display (but on submission will display that error), trying to create a new item will immediately display that error (ie no form fields)

I have noticed that in extensions supplied in RX (ie PSFileInfo.java) you use:

request.setParameter(paramName + "_size",String.valueOf(filesize));

as opposed to explicitly specifying the logger.

Oh I didn’t actually give you the whole picture in terms of what throws the actual error. While the PSServerLogHander throws an “INFO” in the server log

2009-01-23 11:10:57,540 INFO  [com.percussion.server.PSServerLogHandler] appid: 0 type: 1 ...

The actual error that causes processing to stop is:


2009-01-23 11:10:57,540 ERROR [com.percussion.Cms] An unexpected exception occurred. The reason was: java.lang.NullPointerException. Please consult the log for further information.

Thanks again,
Jit

Jit,

By “Tracing” I meant the old XML application tracing, which you enable from the “Debugging” menu in the workbench.

It appears that for Content Editors, this debugging menu is disabled, and tracing is only available from the console command line. I don’t think this is likely to be your problem.

I don’t understand the correlation between “setParameter()” and logging. Setting a Parameter attaches the parameter to the request, so that the parameter is available to subsequent code that may get called with that request. This doesn’t have anything to do with logging. Is there something I’m missing here?

Dave

Dave,
in regards to .setParameter(), sorry, copied the wrong line…it should have read:

  
//For debugging only
request.printTraceMessage(
                  "PSFileInfo.preProcessRequest filename==" + filename);

How does one turn on logging for extensions (for use with request.printTrace())? I see where it could possibly be done for applications in WB (right click > debug), but have no clue on extensions (such as the pre-processor).