Tuesday, August 27, 2013

Spring Insight on Tomcat failing to start

Spring Insight is a powerful tool to record timing data for web applications deployed on a Spring server, but can also be used on Tomcat.
However, it does require a large amount of configuration before it will run correctly on a Tomcat deployment.
One exception that caused me a large amount of grief was the descriptive java.lang.NullPointerException at java.io.File.(File.java:222) at com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader.readInsightConfig(TomcatWeavingInsightClassLoader.java:67) at com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader.start(TomcatWeavingInsightClassLoader.java:50)
  Fortunately the source code for all Spring products is available to download at http://maven.springframework.org/release/com/springsource/ I am using Insight 1.5.1.SR2, and the source for the TomcatWeavingInsightClassLoader class is in the insight-collection project at http://maven.springframework.org/release/com/springsource/insight/insight-collection-tcserver/1.5.1.SR2/insight-collection-tcserver-1.5.1.SR2-sources.jar Examining the class, on line 67 we can see the following File insightDir = new File(System.getProperty("insight.base")); So Insight is looking for the insight root directory in your deployment, which can be set at run time. To resolve the problem, add the system parameter "insight.base" to your tomcat startup with the value of the insight directory in the deployment, e.g. "-Dinsight.base=C:\tomcat\insight"

No comments: