I am trying to setup Fitnesse in my project but I am facing some issues with Guava jars This is how my pom.xml looks like:
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.fitnesse/fitnesse -->
<dependency>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId>
<version>20161106</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.fitnesse.plugins</groupId>
<artifactId>maven-classpath-plugin</artifactId>
<version>1.9</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>integration-test</id>
<properties>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<profile>
<id>standalone</id>
<properties>
<skip.unit.tests>true</skip.unit.tests>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>start-fitnesse</id>
<phase>test</phase>
<configuration>
<tasks>
<echo taskname="fitnesse" message="Starting FitNesse..."/>
<java classname="fitnesseMain.FitNesseMain"
classpathref="maven.runtime.classpath" fork="true">
<arg line="-p 9090"/>
<arg line="-d ."/>
<arg line="-o"/>
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
</dependencies>
</profile>
</profiles>
I am using the maven-classpath-plugin
to set up the classpath in Fitnesse. This plugin transitively uses org.sonatype.sisu:sisu-guava:jar:0.9.9:runtime
jar. And I also need the Guava jar for my project.
Maven dependency tree:
[INFO] --- maven-dependency-plugin:3.0.1:tree (default-cli) @ testProject ---
[INFO] com.rdm:testProject:jar:1.0-SNAPSHOT
[INFO] +- com.google.guava:guava:jar:23.0:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
[INFO] | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] +- org.fitnesse:fitnesse:jar:20161106:runtime
[INFO] | +- org.htmlparser:htmlparser:jar:2.1:runtime
[INFO] | +- org.htmlparser:htmllexer:jar:2.1:runtime
[INFO] | +- org.apache.velocity:velocity:jar:1.7:runtime
[INFO] | +- commons-lang:commons-lang:jar:2.6:runtime
[INFO] | +- commons-collections:commons-collections:jar:3.2.2:runtime
[INFO] | +- org.json:json:jar:20151123:runtime
[INFO] | +- com.googlecode.java-diff-utils:diffutils:jar:1.3.0:runtime
[INFO] | +- org.apache.ant:ant:jar:1.9.6:runtime
[INFO] | | \- org.apache.ant:ant-launcher:jar:1.9.6:runtime
[INFO] | \- junit:junit:jar:4.12:runtime
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:runtime
[INFO] \- org.fitnesse.plugins:maven-classpath-plugin:jar:1.9:runtime
[INFO] \- org.apache.maven:maven-embedder:jar:3.0.4:runtime
[INFO] +- org.apache.maven:maven-settings:jar:3.0.4:runtime
[INFO] +- org.apache.maven:maven-core:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-model:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-settings-builder:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-repository-metadata:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-artifact:jar:3.0.4:runtime
[INFO] | +- org.apache.maven:maven-aether-provider:jar:3.0.4:runtime
[INFO] | | \- org.sonatype.aether:aether-spi:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-impl:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-api:jar:1.13.1:runtime
[INFO] | +- org.sonatype.aether:aether-util:jar:1.13.1:runtime
[INFO] | \- org.codehaus.plexus:plexus-interpolation:jar:1.14:runtime
[INFO] +- org.apache.maven:maven-plugin-api:jar:3.0.4:runtime
[INFO] +- org.apache.maven:maven-model-builder:jar:3.0.4:runtime
[INFO] +- org.apache.maven:maven-compat:jar:3.0.4:runtime
[INFO] | \- org.apache.maven.wagon:wagon-provider-api:jar:2.2:runtime
[INFO] +- org.codehaus.plexus:plexus-utils:jar:2.0.6:runtime
[INFO] +- org.codehaus.plexus:plexus-classworlds:jar:2.4:runtime
[INFO] +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:runtime
[INFO] | \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:runtime
[INFO] | \- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:runtime
[INFO] | \- org.sonatype.sisu:sisu-guava:jar:0.9.9:runtime
[INFO] +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:runtime
[INFO] +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:runtime
[INFO] +- org.sonatype.plexus:plexus-cipher:jar:1.7:runtime
[INFO] \- commons-cli:commons-cli:jar:1.2:runtime
This is the error I get when I try to bring up the fitnesse server:
[fitnesse] Starting FitNesse...
[java] SEVERE: Error while starting the FitNesse [Unable to instantiate component for type fitnesse.wikitext.widgets.MavenClasspathSymbolType]
[java] fitnesse.components.ComponentInstantiationException: Unable to instantiate component for type fitnesse.wikitext.widgets.MavenClasspathSymb
olType
[java] at fitnesse.components.ComponentFactory.createComponent(ComponentFactory.java:75)
[java] at fitnesse.plugins.PropertyBasedPluginFeatureFactory$8.register(PropertyBasedPluginFeatureFactory.java:152)
[java] at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forEachClass(PropertyBasedPluginFeatureFactory.java:144)
[java] at fitnesse.plugins.PropertyBasedPluginFeatureFactory.forEachObject(PropertyBasedPluginFeatureFactory.java:150)
[java] at fitnesse.plugins.PropertyBasedPluginFeatureFactory.registerSymbolTypes(PropertyBasedPluginFeatureFactory.java:75)
[java] at fitnesse.plugins.PluginsLoader.loadSymbolTypes(PluginsLoader.java:87)
[java] at fitnesse.ContextConfigurator.makeFitNesseContext(ContextConfigurator.java:151)
[java] at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:69)
[java] at fitnesseMain.FitNesseMain.launchFitNesse(FitNesseMain.java:58)
[java] at fitnesseMain.FitNesseMain.mai
[java] n(FitNesseMain.java:38)
[java] Caused by: java.lang.reflect.InvocationTargetException
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[java] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[java] at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
[java] at fitnesse.components.ComponentFactory.createComponent(ComponentFactory.java:72)
[java] ... 9 more
[java] Caused by: java.lang.NoSuchMethodError: com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/c
oncurrent/ConcurrentMap;
[java] at com.google.inject.internal.Annotations$AnnotationChecker.<init>(Annotations.java:104)
[java] at com.google.inject.internal.Annotations.<clinit>(Annotations.java:122)
[java] at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:362)
[java] at com.google.inject.Key.strategyFor(Key.java:354)
[java] at com.google.inject.Key.get(Key.java:222)
[java] at org.sonatype.guice.bean.binders.ParameterKeys.<clinit>(ParameterKeys.java:23)
[java] at org.codehaus.plexus.DefaultPlexusContainer$ContainerModule.configure(DefaultPlexusContainer.java:801)
[java] at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
[java] at com.google.inject.spi.Elements.getElements(Elements.java:103)
[java] at com.google.inject.spi.Elements.getElements(Elements.java:80)
[java] at org.sonatype.guice.bean.binders.MergedModule.configure(MergedModule.java:54)
[java] at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:229)
[java] at com.google.inject.spi.Elements.getElements(Elements.java:103)
[java] at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
[java] at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
[java] at com.google.inject.Guice.createInjector(Guice.java:94)
[java] at com.google.inject.Guice.createInjector(Guice.java:71)
[java] at com.google.inject.Guice.createInjector(Guice.java:61)
[java] at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:470)
[java] at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:196)
[java] at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:160)
[java] at fitnesse.wikitext.widgets.MavenClasspathExtractor.buildPlexusContainer(MavenClasspathExtractor.java:219)
[java] at fitnesse.wikitext.widgets.MavenClasspathExtractor.buildPlexusContainer(MavenClasspathExtractor.java:215)
[java] at fitnesse.wikitext.widgets.MavenClasspathExtractor.<init>(MavenClasspathExtractor.java:51)
[java] at fitnesse.wikitext.widgets.MavenClasspathSymbolType.<init>(MavenClasspathSymbolType.java:39)
[java] ... 14 more
Now if declare the Guava dependency after the maven-classpath-plugin, then I do not run into this issue, however my unit tests and integration tests fails with MethodNotFoundException
and if I declare the Guava dependency above maven-classpath-plugin then the fitnesse server won't come up with the error as shown above.
I see a similar issue Drools 6 sisu-guava conflicts with guava
Any suggestions or work-around would be really helpful.
EDIT: Found out an easier solution - I added the following dependecy in my pom.xml:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.5.0</version>
<scope>runtime</scope>
</dependency>
which stops the transitive download of sisu-guava. Now both the tests and the fitnesse server works
This seems very similar to Fitnesse Maven Classpath error. Use one of the two approaches I mention there to deal with dependency conflicts between the libraries for the wiki and the fixtures running your tests.