The Holy Java

Building the right thing, building it right, fast

Posts Tagged ‘troubleshooting’

Kioo: How to Troubleshoot Template Processing

Posted by Jakub Holý on April 8, 2014

So you have created an Om/Reagent/React component using a Kioo template and the result is not as you expected, perhaps just an empty element? Let me share what I have discovered about troubleshooting this (though I am no expert). You will se how to invoke the underlying Clojure function component* manually, how to expand the deftemplate macro, how to call the resulting JavaScript function, and what the intermediate forms look like.

Read the rest of this entry »

Posted in Languages | Tagged: , , | 3 Comments »

Installing & Troubleshooting Google Analytics 2013 (ga / analytics.js)

Posted by Jakub Holý on July 23, 2013

Setting up the new Google Universal Analytics (still in beta) is not completely obvious. You normally won’t be able to send events from localhost and it will claim that “Tracking Not Installed.” Here are some tips how to use Analytics from localhost and test it.

Read the rest of this entry »

Posted in General | Tagged: , , , , | Comments Off

Note To Self: What to Do When a Vagrant Machine Stops Working (Destroy or Up Failing)

Posted by Jakub Holý on March 24, 2012

Sometimes “vagrant destroy” fails with an exception from the depths of the virtualbox Ruby gem or vagrant up freezes for a long time only to fail with SSH connection failure message. Here are some tips how to solve such problems.

See also my Vagrant Notes.

Read the rest of this entry »

Posted in Tools | Tagged: , , , | Comments Off

Inspect Your Webapp in a Live Environment Interactively with GroovyConsole

Posted by Jakub Holý on September 27, 2011

Have you ever needed to check the state of your webapp’s objects/Session/.. to find out why the hell something doesn’t work or have you had to learn a weird 3rd party API that is only available on the server? Then you were doomed … until the publication of GroovyConsole. JeeUtils GroovyConsole provides a JSP page that let you execute any Groovy/Java code on the server side, with access to server-side objects like request/session etc.

Here is a screenshot of my recent troubleshooting session, where I needed to check the state of a session-scoped JSF Managed Bean:

Read the rest of this entry »

Posted in j2ee, Languages, Tools | Tagged: , , , , | Comments Off

Troubleshooting logging configuration (Log4j, commons-logging)

Posted by Jakub Holý on December 7, 2009

Did it ever happen to you that your logging didn’t behave as expected? Here are some tips how to find out what’s going on.

Commons-logging (since 1.1)

Set the system property org.apache.commons.logging.diagnostics.dest to STDOUT (or STDERR or a file name); docs: -Dorg.apache.commons.logging.diagnostics.dest=STDOUT

Extract of a sample output (no commons-logging.properties):

...
[LogFactory from sun.misc.Launcher$AppClassLoader@934873913] [ENV] Application classpath (java.class.path): ..
...
[LOOKUP] No properties file of name 'commons-logging.properties' found
....
Discovering a Log implementation...
...
Log adapter 'org.apache.commons.logging.impl.Log4JLogger' from classloader java.net.URLClassLoader@32689826 has been selected for use.

Extract of a sample output (incorrect commons-logging.properties found):

...
[LogFactory from sun.misc.Launcher$AppClassLoader@934873913] [LOOKUP] Properties file found at 'jar:file:/myproject/lib/test/dbunit-embeddedderby-parenttest-sources.jar!/commons-logging.properties' with priority 0.0
.. [LOOKUP] Properties file at 'file:/myproject/web/WEB-INF/classes/commons-logging.properties' with priority 0.0 does not override file at 'jar:file:/myproject/lib/test/dbunit-embeddedderby-parenttest-sources.jar!/commons-logging.properties' with priority 0.0
.. [LOOKUP] Properties file of name 'commons-logging.properties' found at 'jar:file:/myproject/lib/test/dbunit-embeddedderby-parenttest-sources.jar!/commons-logging.properties"
.. Attempting to load user-specified log class 'org.apache.commons.logging.impl.SimpleLog'...
.. Log adapter 'org.apache.commons.logging.impl.SimpleLog' from classloader sun.misc.Launcher$AppClassLoader@934873913 has been selected for use.
...

Notice that Commons Logging uses the context classloader and not e.g. Class.getClassloader() to locate the implementation to use, which may occassionally lead to some problems.

PS: You may be better of not using commons-logging because of its classloader issues. (SLF4J may be better?)

Log4j

Set the system property log4j.debug to true for Log4j to log the location of the configuration file it’s using and other useful information. You can also set it in in the log4j.properties file:

log4j.debug=true

Or, as mentioned above, pass it as a system property to Java, for example as in

java -Dlog4j.debug=true -jar YourApplication.jar

The debug information will be printed into the System.out, not in any log file you may have configured (Log4j can’t use itself for this logging).

Example output:

log4j: Parsing for [root] with value=[INFO, CONSOLE, filelog].
log4j: Level token is [INFO].
log4j: Category root set to INFO
log4j: Parsing appender named "CONSOLE".
log4j: Parsing layout options for "CONSOLE".
log4j: Setting property [conversionPattern] to [%6rms [%p] ..%0.46c %x- %m%n].
log4j: End of parsing for "CONSOLE".
log4j: Parsed "CONSOLE" options.
log4j: Parsing appender named "filelog".
log4j: Parsing layout options for "filelog".
log4j: Setting property [conversionPattern] to [%6rms [%p] ..%0.46c %x- %m%n].
log4j: End of parsing for "filelog".
log4j: Setting property [file] to [/home/me/mylog.log].
log4j: Setting property [maxBackupIndex] to [5].
log4j: Setting property [maxFileSize] to [50MB].
log4j: setFile called: /home/me/mylog.log, true
log4j: setFile ended
log4j: Parsed "filelog" options.
log4j: Parsing for [eu.ibacz.lqs.uiradrupdater] with value=[DEBUG].
log4j: Level token is [DEBUG].
log4j: Category eu.ibacz.lqs.uiradrupdater set to DEBUG
log4j: Handling log4j.additivity.eu.ibacz.lqs.uiradrupdater=[null]
log4j: Finished configuring.

For the log4j.properties:

log4j.rootCategory=INFO, CONSOLE, filelog

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%6rms [%p] ..%0.46c %x- %m%n

log4j.appender.filelog=org.apache.log4j.RollingFileAppender
log4j.appender.filelog.File=${user.home}/mylog.log
log4j.appender.filelog.MaxFileSize=50MB
log4j.appender.filelog.MaxBackupIndex=5
log4j.appender.filelog.layout=org.apache.log4j.PatternLayout
log4j.appender.filelog.layout.ConversionPattern=%6rms [%p] ..%0.46c %x- %m%n

log4j.logger.eu.ibacz.lqs.uiradrupdater=DEBUG

Posted in Languages, Tools | Tagged: , , , , , | Comments Off

Troubleshooting Class/Resource Loading on an Application Server

Posted by Jakub Holý on January 25, 2007

If you need to find out where is a certain class loaded from or where a class has loaded a resource (typically a configuration file) from, you can use the JSP below – just put it to your web app and point a browser to it.

Note: The resource loading tracking assumes that the loading class uses getClass().getResource – this doesn’t need to be always the case, it could also use the context class loader (Thread.currentThread().getContextClassLoader()) or load it as a system resource (ClassLoader.getSystemResource).

Update 08/11/06:  You can now get the ClassLoaderViewer.jsp from SF.net.


Posted in j2ee, Languages | Tagged: , , , | Comments Off

DB2: Find out current locks, long transactions etc. [snapshot]

Posted by Jakub Holý on October 19, 2006

To find out current locks in a DB and other information about its current state, you need to take a “snapshot”:

db2 "attach to  user  using "
db2 "get snapshot for applications on "  > mydatabase_snapshot.txt

Look into the resulting mydatabase_snapshot.txt for “Application ID holding”  (if there is a lock, this will read the ID of the aplication holding the lock). To find long queries [that are currently running], look for “Executing”.

Posted in Databases | Tagged: , , | Comments Off