I am trying to start Jetty in embedded mode to deploy a war file. I am using jetty lib versioned 9.4.6
I have following task created in Gradle for starting Jetty and deploying the web application.
println 'Starting Jetty............'
project.ext.server = new Server();
ServerConnector connector = new ServerConnector(project.ext.server);
connector.setPort(jettyPort);
project.ext.server.addConnector(connector);
WebAppContext webapp = new WebAppContext()
webapp.setContextPath('/')
def warPath = 'build/libs/';
warPath += 'test-' + project.version + '.war';
println("Deploying WAR File : --> ${warPath}");
webapp.setWar(warPath)
project.ext.server.setHandler(webapp);
project.ext.server.start();
println 'Server started, waiting...'
new StopMonitor(jettyStopPort, project.ext.server).start();
println 'Jetty started.'
but above script fails with following error
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.server.session.SessionHandler
Exact line from the script which is failing is
WebAppContext webapp = new WebAppContext()
Even if I keep this line as the single line in the script and remove everything, I get the same error.
Interestingly, the class for which it is complaining is present in the jar file jetty-server. Same script used to work with jetty libs 8.1
Note: In order to make the script work with jetty 9.4, i had to use ServerConnector class instead of BlockingConnectot, which was removed in jetty 9.4, rest of the script is same.
I am not sure why this failing.