Maven项目构建在NoClassDefFoundError和其他人的测试 - 编译阶段失败

时间:2017-06-24 19:47:03

标签: java maven java-8

我完全失去了无益的Maven痕迹。 mvn compile成功就像一个魅力,但mvn packageNoClassDefFoundErrorNoSuchMethodError test-compile阶段的-DskipTests=true测试([INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building first-dataflow 0.1 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ first-dataflow --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/user/projects/personal/first-dataflow/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ first-dataflow --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ first-dataflow --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/user/projects/personal/first-dataflow/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ first-dataflow --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ first-dataflow --- [INFO] [INFO] ------------------------------------------------------- [INFO] T E S T S [INFO] ------------------------------------------------------- [INFO] Running com.example.WordCountTest [ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! - in com.example.WordCountTest [ERROR] testCountWords(com.example.WordCountTest) Time elapsed: 0.002 s <<< ERROR! java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z at com.example.WordCountTest.<init>(WordCountTest.java:72) [ERROR] testExtractWordsFn(com.example.WordCountTest) Time elapsed: 0.002 s <<< ERROR! java.lang.NoClassDefFoundError: Could not initialize class org.apache.beam.sdk.testing.TestPipeline at com.example.WordCountTest.<init>(WordCountTest.java:72) [INFO] Running com.example.DebuggingWordCountTest [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.098 s <<< FAILURE! - in com.example.DebuggingWordCountTest [ERROR] testDebuggingWordCount(com.example.DebuggingWordCountTest) Time elapsed: 0.098 s <<< ERROR! java.lang.NoClassDefFoundError: Could not initialize class org.apache.beam.sdk.testing.TestPipeline at com.example.DebuggingWordCountTest.testDebuggingWordCount(DebuggingWordCountTest.java:47) [INFO] [INFO] Results: [INFO] [ERROR] Errors: [ERROR] DebuggingWordCountTest.testDebuggingWordCount:47 NoClassDefFound Could not ini... [ERROR] WordCountTest.<init>:72 » NoSuchMethod com.fasterxml.jackson.core.JsonFactory.... [ERROR] WordCountTest.<init>:72 NoClassDefFound Could not initialize class org.apache.... [INFO] [ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.948 s [INFO] Finished at: 2017-06-24T22:40:00+03:00 [INFO] Final Memory: 17M/437M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20:test (default-test) on project first-dataflow: There are test failures. [ERROR] [ERROR] Please refer to /Users/user/projects/personal/first-dataflow/target/surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 失败了<?xml version="1.0" encoding="UTF-8"?> <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ Copyright (C) 2017 Google Inc. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); you may not ~ use this file except in compliance with the License. You may obtain a copy of ~ the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the ~ License for the specific language governing permissions and limitations under ~ the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> <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> <groupId>com.example</groupId> <artifactId>first-dataflow</artifactId> <version>0.1</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <surefire-plugin.version>2.20</surefire-plugin.version> </properties> <repositories> <repository> <id>ossrh.snapshots</id> <name>Sonatype OSS Repository Hosting</name> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${surefire-plugin.version}</version> <configuration> <parallel>all</parallel> <threadCount>4</threadCount> <redirectTestOutputToFile>true</redirectTestOutputToFile> </configuration> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> <version>${surefire-plugin.version}</version> </dependency> </dependencies> </plugin> <!-- Ensure that the Maven jar plugin runs before the Maven shade plugin by listing the plugin higher within the file. --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> </plugin> <!-- Configures `mvn package` to produce a bundled jar ("fat jar") for runners that require this for job submission to a cluster. --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <finalName>${project.artifactId}-bundled-${project.version}</finalName> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/LICENSE</exclude> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> </transformers> </configuration> </execution> </executions> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.4.0</version> <configuration> <cleanupDaemonThreads>false</cleanupDaemonThreads> </configuration> </plugin> </plugins> </pluginManagement> </build> <dependencies> <!-- Adds a dependency on a specific version of the Dataflow SDK. --> <dependency> <groupId>com.google.cloud.dataflow</groupId> <artifactId>google-cloud-dataflow-java-sdk-all</artifactId> <version>2.0.0</version> </dependency> <!-- Dependencies below this line are specific dependencies needed by the examples code. --> <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client</artifactId> <version>1.22.0</version> <exclusions> <!-- Exclude an old version of guava that is being pulled in by a transitive dependency of google-api-client --> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava-jdk5</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.apis</groupId> <artifactId>google-api-services-bigquery</artifactId> <version>v2-rev295-1.22.0</version> <exclusions> <!-- Exclude an old version of guava that is being pulled in by a transitive dependency of google-api-client --> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava-jdk5</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client</artifactId> <version>1.22.0</version> <exclusions> <!-- Exclude an old version of guava that is being pulled in by a transitive dependency of google-api-client --> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava-jdk5</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.google.apis</groupId> <artifactId>google-api-services-pubsub</artifactId> <version>v1-rev10-1.22.0</version> <exclusions> <!-- Exclude an old version of guava that is being pulled in by a transitive dependency of google-api-client --> <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava-jdk5</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>20.0</version> </dependency> <!-- Add slf4j API frontend binding with JUL backend --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.14</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> <version>1.7.14</version> <!-- When loaded at runtime this will wire up slf4j to the JUL backend --> <scope>runtime</scope> </dependency> <!-- Hamcrest and JUnit are required dependencies of PAssert, which is used in the main code of DebuggingWordCount example. --> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>1.3</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> </dependencies> </project> Marant构建过程的1}}选项,发出它成功运行的那个阶段。此外,项目在运行时因这些错误而失败。

我在自己的项目中遇到了这个问题,并且从原型开始进行正确的mvn安装和项目初始化,我最后通过一个熊骨教程完成了这个过程。

在远程计算机上编译和打包时(操作系统是Ubuntu 16.04,本地是OS X),它会正常打包和编译。使用本地机器,不是。

迹:

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
$ echo $M2_HOME
/opt/maven

的pom.xml:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:first-dataflow:jar:0.1
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 79, column 15
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building first-dataflow 0.1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ first-dataflow ---
[INFO] com.example:first-dataflow:jar:0.1
[INFO] +- com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:jar:2.0.0:compile
[INFO] |  +- org.apache.beam:beam-sdks-java-core:jar:2.0.0:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-core:jar:2.8.8:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.8:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.8:compile
[INFO] |  |  +- org.apache.avro:avro:jar:1.8.1:compile
[INFO] |  |  |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] |  |  |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |  |  |  +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] |  |  |  +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] |  |  |  \- org.tukaani:xz:jar:1.5:compile
[INFO] |  |  \- org.xerial.snappy:snappy-java:jar:1.1.4-M3:compile
[INFO] |  +- org.apache.beam:beam-sdks-java-io-google-cloud-platform:jar:2.0.0:compile
[INFO] |  |  +- org.apache.beam:beam-sdks-java-extensions-google-cloud-platform-core:jar:2.0.0:compile
[INFO] |  |  |  +- com.google.cloud.bigdataoss:gcsio:jar:1.4.5:compile
[INFO] |  |  |  \- com.google.apis:google-api-services-cloudresourcemanager:jar:v1-rev6-1.22.0:compile
[INFO] |  |  +- org.apache.beam:beam-sdks-java-extensions-protobuf:jar:2.0.0:compile
[INFO] |  |  +- com.google.api.grpc:grpc-google-pubsub-v1:jar:0.1.0:compile
[INFO] |  |  |  \- com.google.api.grpc:grpc-google-iam-v1:jar:0.1.0:compile
[INFO] |  |  +- com.google.cloud.bigdataoss:util:jar:1.4.5:compile
[INFO] |  |  |  +- com.google.api-client:google-api-client-java6:jar:1.20.0:compile
[INFO] |  |  |  +- com.google.api-client:google-api-client-jackson2:jar:1.20.0:compile
[INFO] |  |  |  \- com.google.oauth-client:google-oauth-client-java6:jar:1.20.0:compile
[INFO] |  |  +- com.google.cloud.datastore:datastore-v1-proto-client:jar:1.4.0:compile
[INFO] |  |  |  +- com.google.http-client:google-http-client-protobuf:jar:1.20.0:compile
[INFO] |  |  |  \- com.google.http-client:google-http-client-jackson:jar:1.20.0:compile
[INFO] |  |  +- com.google.cloud.datastore:datastore-v1-protos:jar:1.3.0:compile
[INFO] |  |  +- io.grpc:grpc-auth:jar:1.2.0:compile
[INFO] |  |  +- io.grpc:grpc-core:jar:1.2.0:compile
[INFO] |  |  |  +- com.google.errorprone:error_prone_annotations:jar:2.0.11:compile
[INFO] |  |  |  +- io.grpc:grpc-context:jar:1.2.0:compile
[INFO] |  |  |  \- com.google.instrumentation:instrumentation-api:jar:0.3.0:compile
[INFO] |  |  +- io.grpc:grpc-netty:jar:1.2.0:compile
[INFO] |  |  |  +- io.netty:netty-codec-http2:jar:4.1.8.Final:compile (version selected from constraint [4.1.8.Final,4.1.8.Final])
[INFO] |  |  |  |  \- io.netty:netty-codec-http:jar:4.1.8.Final:compile
[INFO] |  |  |  \- io.netty:netty-handler-proxy:jar:4.1.8.Final:compile
[INFO] |  |  |     \- io.netty:netty-codec-socks:jar:4.1.8.Final:compile
[INFO] |  |  +- io.netty:netty-handler:jar:4.1.8.Final:compile
[INFO] |  |  |  +- io.netty:netty-buffer:jar:4.1.8.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-common:jar:4.1.8.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport:jar:4.1.8.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-resolver:jar:4.1.8.Final:compile
[INFO] |  |  |  \- io.netty:netty-codec:jar:4.1.8.Final:compile
[INFO] |  |  +- io.grpc:grpc-stub:jar:1.2.0:compile
[INFO] |  |  +- io.grpc:grpc-all:jar:1.2.0:compile
[INFO] |  |  |  +- io.grpc:grpc-okhttp:jar:1.2.0:compile
[INFO] |  |  |  |  +- com.squareup.okhttp:okhttp:jar:2.5.0:compile
[INFO] |  |  |  |  \- com.squareup.okio:okio:jar:1.6.0:compile
[INFO] |  |  |  +- io.grpc:grpc-protobuf:jar:1.2.0:compile
[INFO] |  |  |  |  \- com.google.protobuf:protobuf-java-util:jar:3.2.0:compile
[INFO] |  |  |  |     \- com.google.code.gson:gson:jar:2.7:compile
[INFO] |  |  |  +- io.grpc:grpc-protobuf-lite:jar:1.2.0:compile
[INFO] |  |  |  \- io.grpc:grpc-protobuf-nano:jar:1.2.0:compile
[INFO] |  |  |     \- com.google.protobuf.nano:protobuf-javanano:jar:3.0.0-alpha-5:compile
[INFO] |  |  +- com.google.cloud.bigtable:bigtable-protos:jar:0.9.6.2:compile
[INFO] |  |  +- com.google.cloud.bigtable:bigtable-client-core:jar:0.9.6.2:compile
[INFO] |  |  |  +- com.google.auth:google-auth-library-appengine:jar:0.6.0:compile
[INFO] |  |  |  |  \- com.google.appengine:appengine-api-1.0-sdk:jar:1.9.34:compile
[INFO] |  |  |  \- io.dropwizard.metrics:metrics-core:jar:3.1.2:compile
[INFO] |  |  +- com.google.auth:google-auth-library-credentials:jar:0.6.1:compile
[INFO] |  |  +- com.google.auth:google-auth-library-oauth2-http:jar:0.6.1:compile
[INFO] |  |  +- com.google.api.grpc:grpc-google-common-protos:jar:0.1.0:compile
[INFO] |  |  +- com.google.protobuf:protobuf-java:jar:3.2.0:compile
[INFO] |  |  \- io.netty:netty-tcnative-boringssl-static:jar:1.1.33.Fork26:runtime
[INFO] |  +- org.apache.beam:beam-runners-direct-java:jar:2.0.0:compile
[INFO] |  \- org.apache.beam:beam-runners-google-cloud-dataflow-java:jar:2.0.0:compile
[INFO] |     +- org.apache.beam:beam-sdks-common-runner-api:jar:2.0.0:compile
[INFO] |     +- com.google.apis:google-api-services-dataflow:jar:v1b3-rev196-1.22.0:compile
[INFO] |     +- com.google.apis:google-api-services-clouddebugger:jar:v2-rev8-1.22.0:compile
[INFO] |     \- com.google.apis:google-api-services-storage:jar:v1-rev71-1.22.0:compile
[INFO] +- com.google.api-client:google-api-client:jar:1.22.0:compile
[INFO] |  +- com.google.oauth-client:google-oauth-client:jar:1.22.0:compile
[INFO] |  \- com.google.http-client:google-http-client-jackson2:jar:1.22.0:compile
[INFO] +- com.google.apis:google-api-services-bigquery:jar:v2-rev295-1.22.0:compile
[INFO] +- com.google.http-client:google-http-client:jar:1.22.0:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |  \- org.apache.httpcomponents:httpclient:jar:4.0.1:compile
[INFO] |     +- org.apache.httpcomponents:httpcore:jar:4.0.1:compile
[INFO] |     +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |     \- commons-codec:commons-codec:jar:1.3:compile
[INFO] +- com.google.apis:google-api-services-pubsub:jar:v1-rev10-1.22.0:compile
[INFO] +- joda-time:joda-time:jar:2.4:compile
[INFO] +- com.google.guava:guava:jar:20.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.14:compile
[INFO] +- org.slf4j:slf4j-jdk14:jar:1.7.14:runtime
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:compile
[INFO] \- junit:junit:jar:4.12:compile
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.080 s
[INFO] Finished at: 2017-06-24T23:24:24+03:00
[INFO] Final Memory: 18M/437M
[INFO] ------------------
function googleScan(imageData) {
    var deferred = $q.defer();
    var url = "https://vision.googleapis.com/v1/images:annotate?key=<myAPIKey>";
    var payload = {
        requests: {
            image: {
                content: imageData.split(',')[1]
            },
            features: [{
                type: 'TEXT_DETECTION',
                maxResults:50
            }]
        }
    };
    $http.post(url, payload, { headers: { "NoAuthToken": true } }).then(function (response) {
        deferred.resolve(parseAnalyzedResult(response.data.responses[0].textAnnotations));
        console.log(response);
    }, function (error) {
        console.log(error);
    });
    return deferred.promise;

编辑:教程参考: https://cloud.google.com/dataflow/docs/quickstarts/quickstart-java-maven

依赖树:

style: width=40%

0 个答案:

没有答案
相关问题