Tuesday, 19 April 2011

Solving Tomcat 7 memory problems.

Hudson builds
I started running Hudson builds again, looking for the cause of these out of memory errors.
The project builds, but then fails after each Maven project has built :

 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] expiryTracker ..................................... SUCCESS [5.516s]
[INFO] model ............................................. SUCCESS [29.813s]
[INFO] API for expiry tracker ............................ SUCCESS [4.797s]
[INFO] maven-importer .................................... SUCCESS [3.500s]
[INFO] expirytracker-hib ................................. SUCCESS [3.343s]
[INFO] webapp Maven Webapp ............................... SUCCESS [4.453s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 58.266s
[INFO] Finished at: Tue Apr 19 21:21:22 BST 2011
[INFO] Final Memory: 20M/49M
[INFO] ------------------------------------------------------------------------
maven builder waiting
channel stopped
Archiving artifacts
Deploying artifacts to http://server:8082/archiva/repository/snapshots/
uniqueVersion == false is not anymore supported in maven 3
Deploying the main artifact pom.xml
FATAL: PermGen space
java.lang.OutOfMemoryError: PermGen space
 at sun.net.www.protocol.http.HttpURLConnection.getServerAuthentication(Unknown Source)
 at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
 at java.net.HttpURLConnection.getResponseCode(Unknown Source)
 at org.apache.maven.wagon.providers.http.LightweightHttpWagon.finishPutTransfer(LightweightHttpWagon.java:185)
 at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:413)
 at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:392)
 at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:365)
 at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
 at org.apache.maven.repository.legacy.DefaultWagonManager.putRemoteFile(DefaultWagonManager.java:543)
 at org.apache.maven.repository.legacy.DefaultWagonManager.putArtifact(DefaultWagonManager.java:494)
 at hudson.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:160)
 at hudson.maven.reporters.MavenArtifactRecord.deployMavenArtifact(MavenArtifactRecord.java:139)
 at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:126)
 at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:128)
 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
 at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:622)
 at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:601)
 at hudson.maven.MavenModuleSetBuild$RunnerImpl.post2(MavenModuleSetBuild.java:762)
 at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:548)
 at hudson.model.Run.run(Run.java:1386)
 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:405)
 at hudson.model.ResourceController.execute(ResourceController.java:88)
 at hudson.model.Executor.run(Executor.java:145)


VisualVM

At this point, I'm not sure whats going on.
In an effort to diagnose, I installed Java's memory viewer, VisualVM. I've used it precursor before, when it was first bundled with early versions of Netbeans 6.
Installing is straightforward, but found that Tomcat didn't show up as a process running under the VM. When Tomcat runs as a service, even if it's running under the same user account that you used to launch VisualVM, Tomcat won't appear by default in the VisualVM process list. I found the answer here, at Matt Woodward's blog , which included the vital information about including

-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false


in the Java Options box on the Java options tab.
With the steps from that and a restart of Tomcat, I now have Tomcat 7 being monitored by VisualVM.

Friday, 1 April 2011

Rush just about over

In the last month, I've now racked up about 60+ hours overtime. Combined with time in lieu from last year, that makes it about 10 days time in lieu I'm owed. Sweet.
And next week, can get back to my own project.