Wednesday, March 15, 2006

Tips for new Jetty users

Redeploying my application on Tomcat 5.5.15 on my 1.25Ghz G4 Powerbook 1GB ram was getting painstakingly slow so I decided to take a look at Jetty to see if it would help the cause.

Here are two things I came across in getting started and which I couldn't find much help on Mortbay's site/wiki/docs

1. If you use Log4J in your application and get this error:

Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d1c778 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@d1c778 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))

You simply need to grab the logj4 jar file your application uses and drop it in the jetty.home/ext directory. I don't know why this necessary when the jar file itself is deployed within the webapp's WEB-INF/lib directory but it works.


2. Debugging
I got used to Tomcat's startup scripts so obviously I looked for the Jetty equivalent of 'catalina.sh jpda start' but I couldn't find anything and nary a mention of it on Google or Jetty's docs.

Well it turns out that Jetty is a java application so you can simply start it's JVM with the following standard debug options and then connect your IDE to the JVM for debugging:

java -Djava.home=$JAVA_HOME -Xdebug -Xrunjdwp:transport=dt_socket, server=y, suspend=n, address=5005 -jar start.jar



Even with a 1Gb ram, the speed of my laptop is becoming unbearable. After only 2yrs, I'm having a hard time convincing myself that I should shell out the bucks and get a MacBookPro, especially considering I built myself a AMD64 workstation within those 2yrs. I guess I'll console myself and force myself to wait for the next revision of the MBP's.

*editted to include the debug settings

2 comments:

Matt Raible said...

My MacBook Pro is actually faster than my AMD dual-core. I'd definitely recommend getting one.

http://raibledesigns.com/page/rd?anchor=macbook_pro_kicking_ass_and

My PowerBook was unbearably slow before - and now I don't even notice my MacBook b/c I never see a beach ball anymore. ;-)

Anonymous said...

For me it worked like that:
java -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -jar start.jar