2017-03-01 141 views
0

当我运行grpc客户端时我收到下面的错误。我的grpc服务器运行良好................... .................................................. .................................................. .............................GRPC客户端不能正常工作

mvn exec:java -Dexec.mainClass="com.example.grpc.client.MyGrpcClient.java" -e 
[INFO] Error stacktraces are turned on. 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Detecting the operating system and CPU architecture 
[INFO] ------------------------------------------------------------------------ 
[INFO] os.detected.name: linux 
[INFO] os.detected.arch: x86_64 
[INFO] os.detected.release: ubuntu 
[INFO] os.detected.release.version: 14.04 
[INFO] os.detected.release.like.ubuntu: true 
[INFO] os.detected.release.like.debian: true 
[INFO] os.detected.classifier: linux-x86_64 
[WARNING] Failed to inject repository session properties. 
java.lang.NoSuchMethodError: org.apache.maven.execution.MavenSession.getRepositorySession()Lorg/eclipse/aether/RepositorySystemSession; 
     at kr.motd.maven.os.RepositorySessionInjector.injectRepositorySession(RepositorySessionInjector.java:22) 
     at kr.motd.maven.os.DetectExtension.injectSession(DetectExtension.java:148) 
     at kr.motd.maven.os.DetectExtension.afterProjectsRead(DetectExtension.java:107) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:274) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:497) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building simple-grpc-client 1.0-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- exec-maven-plugin:1.5.0:java (default-cli) @ simple-grpc-client --- 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.591s 
[INFO] Finished at: Wed Mar 01 14:50:54 IST 2017 
[INFO] Final Memory: 10M/212M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli) on project simple-grpc-client: Execution default-cli of goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java failed: Invalid classpath scope: tuomas -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli) on project simple-grpc-client: Execution default-cli of goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java failed: Invalid classpath scope: tuomas 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:497) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java failed: Invalid classpath scope: tuomas 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
     ... 19 more 
Caused by: java.lang.IllegalStateException: Invalid classpath scope: tuomas 
     at org.codehaus.mojo.exec.AbstractExecMojo.collectProjectArtifactsAndClasspath(AbstractExecMojo.java:118) 
     at org.codehaus.mojo.exec.ExecJavaMojo.addRelevantProjectDependenciesToClasspath(ExecJavaMojo.java:607) 
     at org.codehaus.mojo.exec.ExecJavaMojo.getClassLoader(ExecJavaMojo.java:528) 
     at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:308) 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
     ... 20 more 
[ERROR] 
[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/PluginExecution 

我在这里使用maven,我会非常感谢,如果你可以帮我............

here is my pom.xml 
<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
    ~ Copyright 2016 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"> 
    <parent> 
     <artifactId>grpc-demos</artifactId> 
     <groupId>com.example</groupId> 
     <version>1.0-SNAPSHOT</version> 
     <relativePath>..</relativePath> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 

    <artifactId>simple-grpc-client</artifactId> 

    <dependencies> 
     <dependency> 
      <groupId>${project.groupId}</groupId> 
      <artifactId>simple-grpc-server</artifactId> 
      <version>${project.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>io.reactivex</groupId> 
      <artifactId>rxjava</artifactId> 
      <version>1.1.5</version> 
     </dependency> 
    </dependencies> 

</project> 

它正在服务器的依赖关系。我改变它如下,以获得自己的依赖。

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
    ~ Copyright 2016 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"> 
    <parent> 
     <artifactId>grpc-demos</artifactId> 
     <groupId>com.example</groupId> 
     <version>1.0-SNAPSHOT</version> 
     <relativePath>..</relativePath> 
    </parent> 
    <modelVersion>4.0.0</modelVersion> 

    <artifactId>simple-grpc-client</artifactId> 

    <dependencies> 

     <dependency> 
      <groupId>io.reactivex</groupId> 
      <artifactId>rxjava</artifactId> 
      <version>1.1.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.tomcat.maven</groupId> 
      <artifactId>tomcat7-maven-plugin</artifactId> 
      <version>2.2</version> 
      <type>maven-plugin</type> 
     </dependency> 
     <dependency> 
      <groupId>io.grpc</groupId> 
      <artifactId>grpc-netty</artifactId> 
      <version>1.0.0</version> 
     </dependency> 
     <dependency> 
      <groupId>io.grpc</groupId> 
      <artifactId>grpc-protobuf</artifactId> 
      <version>1.0.0</version> 
     </dependency> 
     <dependency> 
      <groupId>io.grpc</groupId> 
      <artifactId>grpc-stub</artifactId> 
      <version>1.0.0</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <extensions> 
      <extension> 
       <groupId>kr.motd.maven</groupId> 
       <artifactId>os-maven-plugin</artifactId> 
       <version>1.4.1.Final</version> 
      </extension> 
     </extensions> 
     <plugins> 
      <plugin> 
       <groupId>org.xolstice.maven.plugins</groupId> 
       <artifactId>protobuf-maven-plugin</artifactId> 
       <version>0.5.0</version> 
       <configuration> 
        <!-- 
         The version of protoc must match protobuf-java. If you don't depend on 
         protobuf-java directly, you will be transitively depending on the 
         protobuf-java version that grpc depends on. 
        --> 
        <protocArtifact>com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier}</protocArtifact> 
        <pluginId>grpc-java</pluginId> 
        <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.0:exe:${os.detected.classifier}</pluginArtifact> 
       </configuration> 
       <executions> 
        <execution> 
         <goals> 
          <goal>compile</goal> 
          <goal>compile-custom</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

     </plugins> 
    </build> 
</project> 
+0

请添加您的pom.xml,以便人们可以在特定情况下为您提供帮助! – Huds0nHawk

+0

谢谢@ V.Momjyan。我已经发布了我的pom.xml – pubu992

+0

不过,你有一个父pom.xml,这也很好。 – Huds0nHawk

回答

0

好吧,我刚刚发现了你的问题。 我选择从嵌套的3.05到3.39的我的Maven版本,它正常工作。 注意,即使您在写入mvn --version时在终端中得到了3.39,这并不意味着您使用的是mvn 3.39,您应该将其设置为您的设置,然后才真正使用3.39版本的maven。