NoSuchMethodError with Hamcrest 1.3 and Maven on GAE

120 views
Skip to first unread message

Daniel via StackOverflow

unread,
Apr 18, 2014, 5:31:44 PM4/18/14
to google-appengin...@googlegroups.com

I've already found three questions which should relate to the same problem, but somehow they didn't quite solve my problem.

NoSuchMethodError with Hamcrest 1.3 & JUnit 4.11

NoSuchMethodError: org.hamcrest.Matchers.hasXPath when I run tests in eclipse

Getting "NoSuchMethodError: org.hamcrest.Matcher.describeMismatch" when running test in IntelliJ 10.5

Here's the console output

     java.lang.NoSuchMethodError: org.hamcrest.core.IsInstanceOf.any(Ljava/lang/Class;)Lorg/hamcrest/Matcher;
        at org.hamcrest.Matchers.any(Matchers.java:371)
        at com.jayway.restassured.filter.log.ResponseLoggingFilter.<init>(ResponseLoggingFilter.java:94)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
        at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl.logWith(ResponseLogSpecificationImpl.groovy:85)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl.this$3$logWith(ResponseLogSpecificationImpl.groovy)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl$this$3$logWith.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl.all(ResponseLogSpecificationImpl.groovy:45)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl.all(ResponseLogSpecificationImpl.groovy)
        at com.jayway.restassured.specification.LogSpecification$all.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl.all(ResponseLogSpecificationImpl.groovy:41)
        at com.jayway.restassured.internal.ResponseLogSpecificationImpl.all(ResponseLogSpecificationImpl.groovy)
        at de.uniluebeck.collaboratex.test.service.ProjectServiceTests.testDeleteNonExistingProject(ProjectServiceTests.java:84)

And the pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <groupId>de.uniluebeck.collaboratex</groupId>
    <artifactId>CollaboraTex</artifactId>

    <name>CollaboraTex</name>

    <pluginRepositories>
        <pluginRepository>
            <id>google-staging</id>
            <name>Google Staging</name>
            <url>https://oss.sonatype.org/content/repositories/comgoogleappengine-1004/</url>
        </pluginRepository>
    </pluginRepositories>

    <properties>
        <appengine.target.version>1.9.2</appengine.target.version>
        <datanucleus.version>3.1.3</datanucleus.version>
        <jersey.version>2.6</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3</version>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- Jersey WS-RS dependencies -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-grizzly2-http</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
            <artifactId>jersey-test-framework-provider-external</artifactId>
            <version>${jersey.version}</version>
        </dependency>

        <!-- JPA dependencies -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- JPA Data Nucleus dependencies -->
        <dependency>
            <groupId>com.google.appengine.orm</groupId>
            <artifactId>datanucleus-appengine</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>${datanucleus.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- needed to solve JPA Data Nucleus validation error -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.2</version>
        </dependency>

        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jpa</artifactId>
            <version>${datanucleus.version}</version>
        </dependency>

        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>${datanucleus.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jpa_2.0_spec</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-jsr107cache</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>net.sf.jsr107cache</groupId>
            <artifactId>jsr107cache</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>2.3.0</version>
            <exclusions>
                <!-- Exclude Groovy because of classpath issue -->
                <exclusion>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy</artifactId>
                </exclusion>
            </exclusions>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <!-- Needs to be the same version that REST Assured depends on -->
            <version>2.2.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-labs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <!-- in order to interpolate version from pom into appengine-web.xml -->
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>  
                <version>2.6</version>  
                <configuration>  
                    <includes>  
                        <include>**/*ServiceTests.java</include>  
                    </includes>  
                </configuration>  
                <executions>
                    <execution>  
                        <id>it</id>
                        <phase>integration-test</phase>
                        <goals>  
                            <goal>integration-test</goal>  
                        </goals>  
                    </execution>  
                </executions>  
            </plugin>

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <!-- 
                <configuration>
                    <port>7378</port>
                    <offline>true</offline>
                </configuration>
                -->
                <executions>
                    <execution>
                        <id>start-gae</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>devserver_start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-gae</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>devserver_stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
                <version>${datanucleus.version}</version>
                <configuration>
                    <api>JPA</api>
                    <verbose>true</verbose>             
                    <mappingIncludes>**/entity/*.class</mappingIncludes>
                    <fork>false</fork>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

As the other three related questions already said, there seem to be some issues with conflicting depdencies of JUnit and Hamcrest and/or Mockito, so I tried various exlusions and other inclusions of said artifacts which resulted in this refactored pom.xml, unfortunately to no avail.

        ... shortened due to char limit ...

    <dependencies>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>

        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.3</version>
        </dependency>
        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- Jersey WS-RS dependencies -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <!-- if your container implements Servlet API older than 3.0, use "jersey-container-servlet-core" -->
            <artifactId>jersey-container-servlet-core</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-grizzly2-http</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.test-framework.providers</groupId>
            <artifactId>jersey-test-framework-provider-external</artifactId>
            <version>${jersey.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>junit</artifactId>
                    <groupId>junit</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- JPA dependencies -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.1</version>
            <scope>provided</scope>
        </dependency>

        <!-- JPA Data Nucleus dependencies -->
        <dependency>
            <groupId>com.google.appengine.orm</groupId>
            <artifactId>datanucleus-appengine</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>${datanucleus.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- needed to solve JPA Data Nucleus validation error -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.2</version>
        </dependency>

        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jpa</artifactId>
            <version>${datanucleus.version}</version>
        </dependency>

        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>${datanucleus.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-jpa_2.0_spec</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-jsr107cache</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>net.sf.jsr107cache</groupId>
            <artifactId>jsr107cache</artifactId>
            <version>1.1</version>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>2.3.0</version>
            <exclusions>
                <!-- Exclude Groovy because of classpath issue -->
                <exclusion>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>hamcrest-library</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
            </exclusions>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <!-- Needs to be the same version that REST Assured depends on -->
            <version>2.2.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.1</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.9.0</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>hamcrest-library</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-labs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
                 ... shortened due to char limit of post ...
        </plugin>
    </build>
</project>

And last but not least, here is the output of mvn dependency:tree

--- maven-dependency-plugin:2.8:tree (default-cli) @ CollaboraTex ---
de.uniluebeck.collaboratex:CollaboraTex:war:1.0-SNAPSHOT
+- com.google.appengine:appengine-api-1.0-sdk:jar:1.9.2:compile
+- javax.servlet:servlet-api:jar:2.5:provided
+- jstl:jstl:jar:1.2:compile
+- org.apache.commons:commons-lang3:jar:3.3:compile
+- javax.transaction:jta:jar:1.1:compile
+- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
+- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.6:compile
|  +- org.glassfish.hk2.external:javax.inject:jar:2.2.0:compile
|  +- org.glassfish.jersey.core:jersey-server:jar:2.6:compile
|  |  +- javax.annotation:javax.annotation-api:jar:1.2:compile
|  |  +- org.glassfish.hk2:hk2-api:jar:2.2.0:compile
|  |  |  +- org.glassfish.hk2:hk2-utils:jar:2.2.0:compile
|  |  |  \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.2.0:compile
|  |  \- org.glassfish.hk2:hk2-locator:jar:2.2.0:compile
|  |     \- org.javassist:javassist:jar:3.18.1-GA:compile
|  \- org.glassfish.jersey.core:jersey-common:jar:2.6:compile
|     +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.6:compile
|     \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
+- org.glassfish.jersey.media:jersey-media-multipart:jar:2.6:compile
|  \- org.jvnet.mimepull:mimepull:jar:1.9.3:compile
+- org.glassfish.jersey.containers:jersey-container-grizzly2-http:jar:2.6:compile
|  \- org.glassfish.grizzly:grizzly-http-server:jar:2.3.8:compile
|     \- org.glassfish.grizzly:grizzly-http:jar:2.3.8:compile
|        \- org.glassfish.grizzly:grizzly-framework:jar:2.3.8:compile
+- org.glassfish.jersey.media:jersey-media-moxy:jar:2.6:compile
|  +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.6:compile
|  +- org.eclipse.persistence:org.eclipse.persistence.moxy:jar:2.5.0:compile
|  |  \- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.0:compile
|  |     \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.0:compile
|  \- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.0:compile
+- org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-external:jar:2.6:compile
|  +- org.glassfish.jersey.test-framework:jersey-test-framework-core:jar:2.6:compile
|  +- org.glassfish.jersey.core:jersey-client:jar:2.6:compile
|  +- junit:junit:jar:4.11:compile
|  \- org.glassfish.hk2.external:asm-all-repackaged:jar:2.2.0:compile
+- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
+- org.eclipse.persistence:eclipselink:jar:2.5.1:provided
|  \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:provided
+- com.google.appengine.orm:datanucleus-appengine:jar:2.1.2:compile
|  \- org.datanucleus:datanucleus-enhancer:jar:3.1.1:compile
|     \- org.ow2.asm:asm:jar:4.0:compile
+- org.datanucleus:datanucleus-core:jar:3.1.3:runtime
+- org.hibernate:hibernate-validator:jar:4.1.0.Final:compile
|  +- javax.validation:validation-api:jar:1.0.0.GA:compile
|  \- org.slf4j:slf4j-api:jar:1.5.6:compile
+- org.slf4j:slf4j-log4j12:jar:1.5.2:compile
|  \- log4j:log4j:jar:1.2.14:compile
+- org.datanucleus:datanucleus-api-jpa:jar:3.1.3:compile
+- org.datanucleus:datanucleus-api-jdo:jar:3.1.3:compile
+- javax.jdo:jdo-api:jar:3.0.1:compile
+- org.apache.geronimo.specs:geronimo-jpa_2.0_spec:jar:1.1:compile
+- com.google.appengine:appengine-jsr107cache:jar:1.9.2:compile
+- com.google.appengine:appengine-endpoints:jar:1.9.2:compile
+- net.sf.jsr107cache:jsr107cache:jar:1.1:compile
+- com.jayway.restassured:rest-assured:jar:2.3.0:test
|  +- org.codehaus.groovy:groovy-xml:jar:2.2.1:test
|  +- org.apache.httpcomponents:httpclient:jar:4.2.6:test
|  |  +- org.apache.httpcomponents:httpcore:jar:4.2.5:test
|  |  +- commons-logging:commons-logging:jar:1.1.1:test
|  |  \- commons-codec:commons-codec:jar:1.6:test
|  +- org.apache.httpcomponents:httpmime:jar:4.2.6:test
|  +- org.hamcrest:hamcrest-core:jar:1.3:compile
|  +- org.hamcrest:hamcrest-library:jar:1.3:test
|  +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:test
|  +- com.jayway.restassured:json-path:jar:2.3.0:test
|  |  +- org.codehaus.groovy:groovy-json:jar:2.2.1:test
|  |  \- com.jayway.restassured:rest-assured-common:jar:2.3.0:test
|  \- com.jayway.restassured:xml-path:jar:2.3.0:test
+- org.codehaus.groovy:groovy-all:jar:2.2.1:test
+- org.testng:testng:jar:6.8.1:test
|  +- org.beanshell:bsh:jar:2.0b4:test
|  +- com.beust:jcommander:jar:1.27:test
|  \- org.yaml:snakeyaml:jar:1.6:test
+- org.mockito:mockito-all:jar:1.9.0:test
+- com.google.appengine:appengine-testing:jar:1.9.2:test
+- com.google.appengine:appengine-api-stubs:jar:1.9.2:test
\- com.google.appengine:appengine-api-labs:jar:1.9.2:test
-----------------------------------------------------------

I'm glad for any thoughts on this as after fiddling around quite a bit I'm out of clues. Thanks you!



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/23162642/nosuchmethoderror-with-hamcrest-1-3-and-maven-on-gae

Daniel via StackOverflow

unread,
Apr 19, 2014, 4:57:04 AM4/19/14
to google-appengin...@googlegroups.com

The Unit tests work out fine but it is during the Integration Tests when the RestAssured Tests fail:

expect().
    statusCode(Status.CREATED.getStatusCode()).log().all().
when().
    post("/projects").
then().
    body("directory", Matchers.anything()).body("files", Matchers.empty()); 

aljipa via StackOverflow

unread,
Apr 19, 2014, 6:27:15 AM4/19/14
to google-appengin...@googlegroups.com

As far as I can tell there's still a jar on a classpath that exposes pre hamcrest 1.3 classes, as the mentioned method was only added in 1.3RC4: https://github.com/hamcrest/JavaHamcrest/commit/a6b00c4aadae733236e481fa747d5223cc7b7a9a

I suggest debugging this in your favorite IDE in order to make sure it's so. After that I suggest checking dependency hierarchy for this maven project and figure out the villain.

If that fails it could be the case the jar/class is there by mistake and only checking this in file system might help I guess.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/23162642/nosuchmethoderror-with-hamcrest-1-3-and-maven-on-gae/23168840#23168840

Daniel via StackOverflow

unread,
Apr 21, 2014, 3:51:39 PM4/21/14
to google-appengin...@googlegroups.com
</url>
        </pluginRepository>
    </pluginRepositories>

    <properties>
        <appengine.target.version>1.9.2</appengine.target.version>
        <datanucleus.version>3.1.3</datanucleus.version>
        <jersey.version>2.6</jersey.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.1</version>
        </dependency>

        <!-- Jersey WS-RS dependencies -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>${jersey.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
            <version>${jersey.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>${jersey.version}</version>
            <scope>compile</scope>
        </dependency>

        <!-- JPA dependencies -->
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>javax.persistence</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.core</artifactId>
            <version>2.5.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>org.eclipse.persistence.moxy</artifactId>
            <version>2.5.0</version>
            <scope>compile</scope>
            <type>jar</type>
        </dependency>

        <!-- JPA Data Nucleus dependencies -->
        <dependency>
            <groupId>com.google.appengine.orm</groupId>
            <artifactId>datanucleus-appengine</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>${datanucleus.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jpa</artifactId>
            <version>${datanucleus.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>3.0.1</version>
            <scope>compile</scope>
        </dependency>

        <!-- needed to solve JPA Data Nucleus validation error -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.6</version>
        </dependency>

        <!-- test dependencies -->
        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>2.3.1</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>asm</artifactId>
                    <groupId>org.ow2.asm</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.jayway.restassured</groupId>
            <artifactId>json-path</artifactId>
            <version>2.3.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>1.3</version>
            <scope>test</scope>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-labs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <!-- in order to interpolate version from pom into appengine-web.xml -->
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>  
                <version>2.6</version>  
                <configuration>  
                    <includes>  
                        <include>**/*ServiceTests.java</include>  
                    </includes>  
                </configuration>  
                <executions>
                    <execution>  
                        <id>it</id>
                        <phase>integration-test</phase>
                        <goals>  
                            <goal>integration-test</goal>  
                        </goals>  
                    </execution>  
                </executions>  
            </plugin>

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <!-- 
                <configuration>
                    <port>7378</port>
                    <offline>true</offline>
                </configuration>
                -->
                <executions>
                    <execution>
                        <id>start-gae</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>devserver_start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-gae</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>devserver_stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>maven-datanucleus-plugin</artifactId>
                <version>${datanucleus.version}</version>
                <configuration>
                    <api>JPA</api>
                    <verbose>true</verbose>             
                    <mappingIncludes>**/entity/*.class</mappingIncludes>
                    <fork>false</fork>
                </configuration>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

And last but not least, here is the output of mvn dependency:tree

de.uniluebeck.collaboratex:CollaboraTex:war:1.0-SNAPSHOT
+- com.google.appengine:appengine-api-1.0-sdk:jar:1.9.2:compile
+- javax.servlet:servlet-api:jar:2.5:provided
+- org.apache.commons:commons-lang3:jar:3.1:compile
+- javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
+- org.glassfish.jersey.core:jersey-server:jar:2.6:compile
|  +- org.glassfish.jersey.core:jersey-common:jar:2.6:compile
|  |  +- org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.6:compile
|  |  \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
|  +- org.glassfish.jersey.core:jersey-client:jar:2.6:compile
|  +- javax.annotation:javax.annotation-api:jar:1.2:compile
|  +- org.glassfish.hk2:hk2-api:jar:2.2.0:compile
|  |  +- org.glassfish.hk2:hk2-utils:jar:2.2.0:compile
|  |  \- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.2.0:compile
|  +- org.glassfish.hk2.external:javax.inject:jar:2.2.0:compile
|  +- org.glassfish.hk2:hk2-locator:jar:2.2.0:compile
|  |  \- org.javassist:javassist:jar:3.18.1-GA:compile
|  \- javax.validation:validation-api:jar:1.1.0.Final:compile
+- org.glassfish.jersey.media:jersey-media-multipart:jar:2.6:compile
|  \- org.jvnet.mimepull:mimepull:jar:1.9.3:compile
+- org.glassfish.jersey.media:jersey-media-moxy:jar:2.6:compile
|  +- org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.6:compile
|  \- org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.5.0:compile
+- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
+- org.eclipse.persistence:org.eclipse.persistence.core:jar:2.5.0:compile
|  \- org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.5.0:compile
+- org.eclipse.persistence:org.eclipse.persistence.moxy:jar:2.5.0:compile
+- com.google.appengine.orm:datanucleus-appengine:jar:2.1.2:compile
|  \- org.datanucleus:datanucleus-enhancer:jar:3.1.1:compile
|     \- org.ow2.asm:asm:jar:4.0:compile
+- org.datanucleus:datanucleus-core:jar:3.1.3:runtime
+- org.datanucleus:datanucleus-api-jpa:jar:3.1.3:compile
+- javax.jdo:jdo-api:jar:3.0.1:compile
|  \- javax.transaction:jta:jar:1.1:compile
+- org.hibernate:hibernate-validator:jar:5.1.0.Final:compile
|  +- org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile
|  \- com.fasterxml:classmate:jar:1.0.0:compile
+- org.slf4j:slf4j-log4j12:jar:1.5.6:compile
|  +- org.slf4j:slf4j-api:jar:1.5.6:compile
|  \- log4j:log4j:jar:1.2.14:compile
+- com.jayway.restassured:rest-assured:jar:2.3.1:test
|  +- org.codehaus.groovy:groovy:jar:2.2.1:test
|  |  +- org.ow2.asm:asm-tree:jar:4.1:test
|  |  +- antlr:antlr:jar:2.7.7:test
|  |  +- org.ow2.asm:asm-util:jar:4.1:test
|  |  +- org.ow2.asm:asm-commons:jar:4.1:test
|  |  \- org.ow2.asm:asm-analysis:jar:4.1:test
|  +- org.codehaus.groovy:groovy-xml:jar:2.2.1:test
|  +- org.apache.httpcomponents:httpclient:jar:4.2.6:test
|  |  +- org.apache.httpcomponents:httpcore:jar:4.2.5:test
|  |  +- commons-logging:commons-logging:jar:1.1.1:test
|  |  \- commons-codec:commons-codec:jar:1.6:test
|  +- org.apache.httpcomponents:httpmime:jar:4.2.6:test
|  +- org.hamcrest:hamcrest-core:jar:1.3:test
|  +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:test
|  \- com.jayway.restassured:xml-path:jar:2.3.1:test
+- com.jayway.restassured:json-path:jar:2.3.1:test
|  +- org.codehaus.groovy:groovy-json:jar:2.2.1:test
|  \- com.jayway.restassured:rest-assured-common:jar:2.3.1:test
+- org.hamcrest:hamcrest-library:jar:1.3:test
+- org.testng:testng:jar:6.8.7:test
|  +- junit:junit:jar:4.10:test
|  +- org.beanshell:bsh:jar:2.0b4:test
|  +- com.beust:jcommander:jar:1.27:test
|  \- org.yaml:snakeyaml:jar:1.12:test
+- org.mockito:mockito-all:jar:1.9.0:test
+- com.google.appengine:appengine-testing:jar:1.9.2:test
+- com.google.appengine:appengine-api-stubs:jar:1.9.2:test
\- com.google.appengine:appengine-api-labs:jar:1.9.2:test

As the other three related questions already said, there seem to be some issues with conflicting dependencies of TestNG/JUnit and Hamcrest and/or Mockito, so I tried various exlusions and other inclusions of said artifacts, unfortunately to no avail. What worked though was to not use the log().all() in RestAssured, which must be the origin of the problem. Therefore this would work:

expect().
    statusCode(Status.CREATED.getStatusCode()).
when().
    post("/projects").
then().
    body("directory", Matchers.anything()).body("files", Matchers.empty()); 

I'd like to be able to see the actual output of the REST calls while esting though, so I'm glad for any thoughts on this. Thanks!

Daniel via StackOverflow

unread,
Apr 21, 2014, 4:06:47 PM4/21/14
to google-appengin...@googlegroups.com

I've already found three questions which should relate to the same problem, but somehow they didn't quite solve my problem.

NoSuchMethodError with Hamcrest 1.3 & JUnit 4.11

NoSuchMethodError: org.hamcrest.Matchers.hasXPath when I run tests in eclipse

Getting "NoSuchMethodError: org.hamcrest.Matcher.describeMismatch" when running test in IntelliJ 10.5

The Unit tests work out fine but it is during the Integration Tests when the RestAssured Tests fail:

expect().
    statusCode(Status.CREATED.getStatusCode()).log().all().
when().
    post("/projects").
then().
    body("directory", Matchers.anything()).body("files", Matchers.empty()); 
Reply all
Reply to author
Forward
0 new messages