1 Reply Latest reply on Jul 23, 2015 1:58 PM by M G

    NoSuchMethodError in Guava class when using weld + testfx

    M G Newbie



      I'm developping a JavaFX app based on a framework called "mvvmfx" [1]. This framework uses CDI (Weld ) for dependency injection. For GUI tests, I wanted to use the testfx library [2], which provides a fluent API to test the GUI.


      Here's where it gets interesting:

      Depending on the loading order of testfx and weld-se jars, I get a NoSuchMethodError for Guava FluentIterable.toSet() deep down in a testfx method (Guava is a dependency of testfx [3]):

      java.lang.NoSuchMethodError: com.google.common.collect.FluentIterable.toSet()Lcom/google/common/collect/ImmutableSet;

        at org.testfx.service.query.impl.NodeQueryUtils.rootOfWindow(NodeQueryUtils.java:66)

        at org.testfx.service.query.impl.NodeQueryUtils.rootsOfWindows(NodeQueryUtils.java:59)

        at org.testfx.service.finder.impl.NodeFinderImpl.rootsOfWindows(NodeFinderImpl.java:116)

        at org.testfx.service.finder.impl.NodeFinderImpl.fromAll(NodeFinderImpl.java:77)

        at org.testfx.service.finder.impl.NodeFinderImpl.lookup(NodeFinderImpl.java:62)

        at org.testfx.api.FxRobot.lookup(FxRobot.java:297)

        at org.testfx.api.FxRobot.pointOfVisibleNode(FxRobot.java:961)

        at org.testfx.api.FxRobot.clickOn(FxRobot.java:574)

        at io.iqe.testfxweld.AppTest.test(AppTest.java:18)

      There are no transient dependencies from weld-se to Guava, so there's only one Guava-version (18.0) in the classpath. This version does have the FluentIterable.toSet() method!


      I built a minimal sample project that shows the behavior. What's interesting is, that it is enough to have weld-se in the classpath to cause the NoSuchMethodError.


      Steps to reproduce the problem:

      1. Unzip testfxweld.zip

      2. Run mvn clean install (In JDK 8, I'm on Win 7, 64Bit)

      3. The build fails with the exception described above.


      4. Change the ordering of weld-se and testfx-core in pom.xml

      5. Run mvn clean install

      6. The build succeeds


      I'm not sure whether this is a bug in weld or testfx, but would be very grateful if someone had a look at it.


      Thank you!


      [1] sialcasa/mvvmFX · GitHub

      [2] TestFX/TestFX · GitHub

      [3] guava-libraries - Guava: Google Core Libraries for Java 1.6+ - Google Project Hosting

        • 1. Re: NoSuchMethodError in Guava class when using weld + testfx
          M G Newbie

          After letting the problem rest for a few hours, the solution is of course rather simple: The weld-se jar does indeed contain a private copy of Guava, at version 13.0.1. This version does not contain the FluentIterable.toSet() method.


          So I guess I have to include the weld-core, exclude its guava dependency and hope that Guava 18.0 does not break Weld.