siasia/xsbt-web-plugin — Issue #63: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener when using customConfiguration
Author: ambisoft
Created: 2011-12-23 02:51:48+00:00
State: open

Hello,

I'm running into a problem when trying to use custom configuration for the container.

The main objective is to change the default port to 9090 plus to add the secure connector (https) for port 9091 and configure corresponding keystore.

I've created a full jetty config file and put it under etc/jetty.xml, relative to the project dir. And verified that it works correctly when it's used with an external Jetty invoked from a command line.

I'm using Jetty 6.1.24 and have the following dependencies in build.sbt:

```
"org.mortbay.jetty" % "jetty" % "6.1.24" % "container",
"javax.servlet" % "servlet-api" % "2.5" % "provided->default",
```

The project runs fine in this scenario (changing port to 9090 and missing the SSL connector):

```
scanDirectories in Compile := Nil

port in container.Configuration := 9090

customConfiguration in container.Configuration := false

//configurationFiles in container.Configuration := Seq(file("etc/jetty.xml"))
```

When I enable the custom configuration, the connectors are configured properly, but deployment of the .war fails:

```
scanDirectories in Compile := Nil

//port in container.Configuration := 9090

customConfiguration in container.Configuration := true

configurationFiles in container.Configuration := Seq(file("etc/jetty.xml"))
```

I'm getting a handful of exceptions when doing container:start:

```
> container:start
2011-12-23 03:37:12.587:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
[info] jetty-6.1.24
...
[warn] failed org.mortbay.jetty.webapp.WebAppContext@4f54fbfe{/app,file:/Users/mark/programming/web/webapps/app.war}: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
[warn] failed ContextHandlerCollection@f120b3d: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
[warn] failed HandlerCollection@44385f8c: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
[warn] Error starting handlers
[info] Started SelectChannelConnector@0.0.0.0:9090
[info] Started SslSocketConnector@0.0.0.0:9091
```

ServletContextListener should be provided by the container, and it's declared properly as a dependency - so that's strange. The "etc/jetty.xml" file works fine too when the app is deployed a stand-alone Jetty (6.1.24, same version)

```
java -jar start.jar etc/jetty.xml (with app.war thrown under webapps/)
```

Thanks for the help!

best regards
Mark