java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.http.HttpGenerator

1,368 views
Skip to first unread message

Semenu Aggor

unread,
Jun 23, 2015, 8:22:41 AM6/23/15
to thucydid...@googlegroups.com
Hello,

This is my first attempt to use Serenity but I hit a blocker at the very start... I'm using gradle to build my project and I have a target named 'regressionTest'
So to run my test I do:  $ gradle clean regressionTest
It all works fine until I added serenity as a dependency then I run into a no class def found error:

23 Jun 2015 11:26:09,286 [Thread-2] INFO  spark.webserver.SparkServer - == Spark has ignited ...
23 Jun 2015 11:26:09,287 [Thread-2] INFO  spark.webserver.SparkServer - >> Listening on 0.0.0.0:8080
Exception in thread "Thread-2" java.lang.NoClassDefFoundError: Could not initialize class org.eclipse.jetty.http.HttpGenerator
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:340)
at org.apache.logging.log4j.core.util.Loader.initializeClass(Loader.java:285)
at org.apache.logging.log4j.core.impl.ThrowableProxy.loadClass(ThrowableProxy.java:500)
at org.apache.logging.log4j.core.impl.ThrowableProxy.toExtendedStackTrace(ThrowableProxy.java:621)
at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:146)
at org.apache.logging.log4j.core.impl.Log4jLogEvent.getThrownProxy(Log4jLogEvent.java:323)
at org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter.format(ExtendedThrowablePatternConverter.java:64)
at org.apache.logging.log4j.core.pattern.PatternFormatter.format(PatternFormatter.java:36)
at org.apache.logging.log4j.core.layout.PatternLayout.toSerializable(PatternLayout.java:189)
at org.apache.logging.log4j.core.layout.PatternLayout.toSerializable(PatternLayout.java:53)
at org.apache.logging.log4j.core.layout.AbstractStringLayout.toByteArray(AbstractStringLayout.java:52)
at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:104)
at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:97)
at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:428)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:407)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:410)
at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:365)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:112)
at org.apache.logging.slf4j.Log4jLogger.log(Log4jLogger.java:374)
at org.eclipse.jetty.util.log.JettyAwareLogger.log(JettyAwareLogger.java:607)
at org.eclipse.jetty.util.log.JettyAwareLogger.warn(JettyAwareLogger.java:431)
at org.eclipse.jetty.util.log.Slf4jLog.warn(Slf4jLog.java:69)
at org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:212)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at spark.webserver.SparkServer.ignite(SparkServer.java:140)
at spark.SparkBase$3.run(SparkBase.java:368)
at java.lang.Thread.run(Thread.java:745)

My dependencies are as follows with serenity commented out:

dependencies {

    compile "org.slf4j:slf4j-api:1.7.12"
    compile "org.slf4j:log4j-over-slf4j:1.7.12"
    compile "org.slf4j:jcl-over-slf4j:1.7.12"
    compile "org.apache.logging.log4j:log4j:2.0.2"
    compile "org.apache.logging.log4j:log4j-core:2.0.2"
    compile "org.apache.logging.log4j:log4j-slf4j-impl:2.0.2"
    compile "org.apache.logging.log4j:log4j-web:2.0.2"

    compile "com.google.code.gson:gson:2.3.1"

    providedCompile "javax.servlet:javax.servlet-api:3.0.1"

    compile ("com.sparkjava:spark-core:2.2") {
        exclude group: "org.slf4j"
    }
    providedCompile "org.eclipse.jetty:jetty-server:9.0.2.v20130417"
    providedCompile "org.eclipse.jetty:jetty-webapp:9.0.2.v20130417"

    compile "com.wordnik:swagger-servlet_2.10:1.3.12"

    testCompile "junit:junit-dep:4.11"
    testCompile "org.hamcrest:hamcrest-all:1.3"
    testCompile "org.mockito:mockito-core:1.9.5"

//    testCompile "net.serenity-bdd:serenity-junit:1.0.58"

    compile "org.apache.httpcomponents:fluent-hc:4.5"
    compile "org.apache.httpcomponents:httpclient:4.5"
    compile "org.apache.httpcomponents:httpasyncclient:4.1"
    compile "org.apache.httpcomponents:httpmime:4.5"
    testCompile ("com.github.tomakehurst:wiremock:1.56") {
        exclude group: "org.apache.httpcomponents", module: "httpclient"
    }

}

My first thought is that Serenity is pulling a version of Jetty that conflicts with the version I've defined, so I tried to exclude Jetty coming in via Serenity

    testCompile ("net.serenity-bdd:serenity-junit:1.0.58") {
        exclude group: "org.seleniumhq.selenium"
        exclude group: "org.mortbay.jetty"
    }

but this didn't help.

Has anybody seen this before?  Any help would be greatly appreciated.

Many thanks in advance.

Semenu

John Smart

unread,
Jun 23, 2015, 8:28:33 AM6/23/15
to Semenu Aggor, thucydid...@googlegroups.com
It's certainly a dependency conflict: try running the dependencyInsite task, e.g.

gradle -q dependencyInsight --configuration compile --dependency jetty

--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
___________________________________________________
John Smart | Wakaleo Consulting  |  +61 407 247 642
Optimizing your software development process
http://www.wakaleo.com  |  john....@wakaleo.com
___________________________________________________

We love breaking down silos and helping smart teams collaborate better! Ask about our tailored on-site workshops in Agile Requirements Discovery, Behaviour Driven Development, Agile Development Practices, and Test Automation!
___________________________________________________

Semenu Aggor

unread,
Jun 23, 2015, 9:06:13 AM6/23/15
to thucydid...@googlegroups.com
Thanks John.
A different version of Jetty was being transitively brought in via serenity-core -> htmlunit -> jetty websocket
Reply all
Reply to author
Forward
0 new messages