Saturday, December 25, 2010
Ignorance - Courage - Wisdom
Ignorance is Past,
Courage is Present,
Wisdom is Future.
Courage is Present,
Wisdom is Future.
Tuesday, December 14, 2010
gnu-hylafax: scheduler NAK'd request ?
Working with gnu-hylafax library is a great, but if you don't pay careful attention it can blow your mind and keep you awake the whole night!
I kept wonder why sendfax command works fine but application built using gnu-hylafax library ends up with exception.
On reason for this was missing call to job.setKillTime("value"); (preferable to set value as 00259) This translates to JPARAM LASTTIME value command.
How to trace the issue?
Enable Log4JLogger for the application, you should be able to get the trace of all the TELNET commands executed. Verify the same with (sendfax -vv ...)
Sample log4j.properties file with gnu.hylafax.ClientProtocol logger:
I kept wonder why sendfax command works fine but application built using gnu-hylafax library ends up with exception.
460 Failed to submit job *: Unspecified reason (scheduler NAK'd request).
at gnu.hylafax.HylaFAXClientProtocol.jsubm(HylaFAXClientProtocol.java:702)
at gnu.hylafax.HylaFAXClient.submit(HylaFAXClient.java:632)
...
On reason for this was missing call to job.setKillTime("value"); (preferable to set value as 00259) This translates to JPARAM LASTTIME value command.
How to trace the issue?
Enable Log4JLogger for the application, you should be able to get the trace of all the TELNET commands executed. Verify the same with (sendfax -vv ...)
Sample log4j.properties file with gnu.hylafax.ClientProtocol logger:
#set the level of the root logger to DEBUG and set its appender as an appender named X
log4j.rootLogger = DEBUG, X
log4j.logger.X = DEBUG, X
log4j.logger.gnu.hylafax.ClientProtocol = DEBUG, X
#set the appender named X to be a console appender
log4j.appender.X=org.apache.log4j.ConsoleAppender
#set the layout for appender named X to be a pattern layout
log4j.appender.X.layout=org.apache.log4j.PatternLayout
Commons Logging - Log4J Configuration
If you use commons-logging in your java application, make sure to have log4j library (jar) and log4j.properties file on the class path. You really don't need much tweaking to get started :)
Simple log4j.properties file:
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
To learn more on jump to log4j manual
Simple log4j.properties file:
# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
To learn more on jump to log4j manual