Search code examples
javamavendockerfitnessefitnesse-slim

Fitnesse error when used with spotify maven plugin and docker


I am using spotify maven plugin to create a fitnesse docker image and run it on a container. I am able to bring the fitnesse up and run the tests successfully locally without using spotify maven plugin and docker but not when I use those. I get the following error when I start the fitnesse Error message

Here is the contents of FrontPage fitnesse wiki which generally generally takes care of resolving dependencies as per http://blog.xebia.com/fitnesse-and-dependency-management-with-maven/

!contents

!define TEST_SYSTEM {slim} !pomFile pom.xml

!note Release ${FITNESSE_VERSION}

Here is the contents of my pom.xml:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>

                        <shadeTestJar>true</shadeTestJar>
                        <transformers>
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                            <transformer
                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                <mainClass>fitnesseMain.FitNesseMain</mainClass>
                            </transformer>
                        </transformers>                         
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <configuration>
                <baseImage>${docker.registry.host.slash}mcpi/service</baseImage>
                <entryPoint>["java","-jar","${serviceBin}/${finalJarName}.jar","-p","8000"]</entryPoint>
                <imageName>mcpi/${project.name}</imageName>
                <runs>
                    <run>mkdir -p ${serviceHome}</run>
                </runs>
                <workdir>${serviceHome}</workdir>
                <resources>
                    <resource>
                        <targetPath>${serviceHome}</targetPath>
                        <directory>${basedir}/src/test/resources</directory>
                    </resource>
                    <resource>
                        <targetPath>${serviceBin}</targetPath>
                        <directory>${basedir}/target</directory>
                        <include>${finalJarName}.jar</include>
                    </resource>
                    <resource>
                        <targetPath>${serviceBin}</targetPath>
                        <directory>${basedir}/target</directory>
                        <include>${finalTestJarName}.jar</include>
                    </resource>
                    <resource>
                        <targetPath>${serviceBin}</targetPath>
                        <directory>${basedir}</directory>
                        <include>pom.xml</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>

Solution

  • I believe your problem might be that you don't include your maven settings and repository in the docker image, so the !pomFile does not work inside your docker image.

    Having said that: you probably don't need it, since you bundle all your classes and dependencies (at least I assume that what the 'shade plugin' does for you). So you can probably disable the 'maven class path plugin, to prevent the problem you experience now. Disabling the maven classpath plugin can be done by adding -Dfitnesse.wikitext.widgets.MavenClasspathSymbolType.Disable=true to your Java command line starting FitNesse in docker (or by removing the line from the wiki page of course, but that impacts how you work locally).

    But I don't know whether your tests will work immediately, or that you have to do something extra to ensure the generated 'final jar' is on the class path of the Java process that is started once an actual test is started (but you can try that locally by running with the !pomFile removed and starting from the jar created by the shade plugin).