floriangrundig / karma-test-runner

Grails plugin to run javascript tests with karma in grails lifecycle "test-app"
Apache License 2.0
7 stars 5 forks source link

Jetty Conflict when using Geb and Selenium #11

Closed todd-idea closed 9 years ago

todd-idea commented 9 years ago

I am working to add support for Karma testing to a Grails 2.3.8 project that currently uses Geb and Selenium tests. When I add in the karma-test-runner and attempt to run the tests in my project, I am getting a dependency resolution error (classpath loading):

| java.lang.IncompatibleClassChangeError: class org.eclipse.jetty.server.AbstractConnector has interface org.eclipse.jetty.http.HttpBuffers as super class at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:171) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:171) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at org.codehaus.groovy.tools.RootLoader.oldFindClass(RootLoader.java:171) at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at de.is24.util.karmatestrunner.jetty.ResultReceiverServer.(ResultReceiverServer.java:19) at de.is24.util.karmatestrunner.JSTestExecutionServer.tryToStartResultReceiverServer(JSTestExecutionServer.java:83) at de.is24.util.karmatestrunner.JSTestExecutionServer.beforeTests(JSTestExecutionServer.java:32) at de.is24.util.karmatestrunner.junit.KarmaTestSuiteRunner$3.evaluate(KarmaTestSuiteRunner.java:186) at de.is24.util.karmatestrunner.junit.KarmaTestSuiteRunner$2.evaluate(KarmaTestSuiteRunner.java:168) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runners.Suite.runChild(Suite.java:127) at org.junit.runners.Suite.runChild(Suite.java:26) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at de.is24.grails.tools.KarmaTestType.doRun(KarmaTestType.groovy:52) at TestApp$_run_closure1.doCall(TestApp:102) at TestApp$_run_closure1.doCall(TestApp.groovy:32)

My assumption is that it is because karma-test-runner (or rather junit-karma-testrunner) includes its dependencies in the distribution jar file (in this case, org.eclipse.jetty.server.* classes).

Note: I am able to run the tests without a problem using karma on the command line. I am also able to create a fresh Grails project and run with karma-test-runner as long as the Geb and Selenium dependencies are not added to the project.

todd-idea commented 9 years ago

I made a slight change to the junit-karma-testrunner Maven pom.xml to turn on shading for the Jetty classes and that seems to have fixed the issue.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <relocations>
                            <relocation>
                              <pattern>org.eclipse.jetty</pattern>
                              <shadedPattern>org.shaded.jetty</shadedPattern>
                            </relocation>
                        </relocations>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <finalName>${artifactId}-${version}</finalName>
            </configuration>
        </plugin>

Not sure how to do a pull-request yet but I might try that.

floriangrundig commented 9 years ago

Hi - I released a new version 0.2.3 which uses raw tcp socket communication instead of a jetty with websockets. Therefore I will close this issue - please keep in mind that if you update, you have to update the npm karma-remote-reporter module manually....

todd-idea commented 9 years ago

Thanks; I will give the new version a try.