Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] First experiences using Jetty for unittest

I have a number of unittest of a servlet running against Tomcat. This is not practical because it requires Tomcat to be started (manually) before the unittest can run. Since I'm also using Maven, so I'd like to start the webapp container as part of the unittest, so I figured I'd give Jetty a try.

Initially I googled Jetty 6 and added the corresponding dependency to my pom, and it downloaded fine. But then during the browsing of the documentation I saw that there is a Jetty 7 hosted by Eclipse. So I wanted to change my dependency to match that. But is seems there is no single pom-artifact that just adds a full installation of Jetty 7. Very unpractical! For unittesting it is not required to have a lean Jetty, just roll it in.

I worked around that by adding the embedded-test artifact as a dependency. And started to setup Jetty; that was quite simple and I quickly had a server that should be able to start my webapp. Great! But then JAR hell broke lose. Everytime I started the server I needed another JAR; initially the JSP implementation was missing. So I copied the dependencies from the embedded-test directly into my pom and tried adding the JSP component. After that was ok, I got a missing Apache Juli, com.sun.org.apache.commons.Log, and I stopped at: java.lang.NoSuchMethodError: org.apache.xerces.xni.Augmentations.removeAllItems()

So I switched back to Jetty 6, which was a nice and single dependency. But I ran into the same missing third party jars. Further investigation is needed to determine why all these problems occur (remember that the project is compiling and working fine ATM under Tomcat). I'll try again in another project someday, but this was a frustrating ride so far.

If anyone can give pointers on what I may have done wrong, please do!

Tom


Back to the top