java .lang.NoSuchMethodError: com.google.common.io.ByteStreams.exhaust (Ljava / io / InputStream;) J - PullRequest
0 голосов
/ 04 мая 2020

Я получаю эту ошибку "java .lang.NoSuchMethodError: com.google.common.io.ByteStreams.exhaust (Ljava / io / InputStream;) J" при использовании метода ServiceCredentials.fromStream (). Кто-нибудь здесь сталкивался с этим и знает исправление? TIA

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>[title]</groupId>
<artifactId>calendar-event-consumer</artifactId>
<version>0.1</version>
<name>${project.artifactId}</name>
<description>Service that listens for events in a queue to push them 
to an external API</description>
<inceptionYear>2017</inceptionYear>

<packaging>jar</packaging>

<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.11.5</scala.version>
<scala.compat.version>2.11</scala.compat.version>
</properties>

<dependencies>
<dependency>
  <groupId>org.scala-lang</groupId>
  <artifactId>scala-library</artifactId>
  <version>${scala.version}</version>
</dependency>

<!-- Test -->
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.11</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.specs2</groupId>
  <artifactId>specs2-core_${scala.compat.version}</artifactId>
  <version>2.4.16</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.scalatest</groupId>
  <artifactId>scalatest_${scala.compat.version}</artifactId>
  <version>2.2.4</version>
  <scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.rabbitmq/amqp-client -->
<dependency>
  <groupId>com.rabbitmq</groupId>
  <artifactId>amqp-client</artifactId>
  <version>4.2.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.21</version>
</dependency>

<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback- 
classic -->
<dependency>
  <groupId>ch.qos.logback</groupId>
  <artifactId>logback-classic</artifactId>
  <version>1.2.3</version>
</dependency>

<!--JSON parsing-->
<dependency>
  <groupId>org.json4s</groupId>
  <artifactId>json4s-native_2.11</artifactId>
  <version>3.5.3</version>
</dependency>

<!--Google Calendar API-->
<dependency>
  <groupId>com.google.api-client</groupId>
  <artifactId>google-api-client</artifactId>
  <version>1.22.0</version>
</dependency>
<dependency>
  <groupId>com.google.oauth-client</groupId>
  <artifactId>google-oauth-client-jetty</artifactId>
  <version>1.22.0</version>
</dependency>
<dependency>
  <groupId>com.google.apis</groupId>
  <artifactId>google-api-services-calendar</artifactId>
  <version>v3-rev254-1.22.0</version>
</dependency>
<dependency>
  <groupId>com.google.auth</groupId>
  <artifactId>google-auth-library-oauth2-http</artifactId>
  <version>0.20.0</version>
</dependency>
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>23.0</version>
</dependency>

<!--Slick -->
<dependency>
  <groupId>com.typesafe.slick</groupId>
  <artifactId>slick_2.11</artifactId>
  <version>3.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java - 
->
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>6.0.6</version>
</dependency>
<dependency>
  <groupId>com.typesafe</groupId>
  <artifactId>config</artifactId>
  <version>1.3.1</version>
</dependency>
<dependency>
  <groupId>com.typesafe.slick</groupId>
  <artifactId>slick-hikaricp_2.11</artifactId>
  <version>3.2.1</version>
</dependency>



</dependencies>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
  <plugin>
    <!-- see http://davidb.github.com/scala-maven-plugin -->
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
      <args>
        <arg>-Xmax-classfile-name</arg>
        <arg>128</arg>
      </args>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
          <goal>testCompile</goal>
        </goals>
        <configuration>
          <args>
            <arg>-deprecation</arg>
            <arg>-dependencyfile</arg>

<arg>${project.build.directory}/.scala_dependencies</arg>
          </args>
        </configuration>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <configuration>
      <useFile>false</useFile>
      <disableXmlReport>true</disableXmlReport>
      <!-- If you have classpath issue like NoDefClassError,... -->
      <!-- useManifestOnlyJar>false</useManifestOnlyJar -->
      <includes>
        <include>**/*Test.*</include>
        <include>**/*Suite.*</include>
      </includes>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.6.0</version>
    <executions>
      <execution>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>maven</executable>
      <workingDirectory>/tmp</workingDirectory>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <archive>
        <manifest>
          <mainClass>com.qpercom.App</mainClass>
        </manifest>
      </archive>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>
</build>
</project>

Журнал ошибок:

17: 40: 54.163 [pool-1-thread-3] INFO c .q. c .rabbitmq.RabbitMQEventConsumer - Получено сообщение типа класса com.qpercom.model.CreateOrUpdateEventMessage о событии (185, omis19demo) 17: 40: 54.626 [pool-1-thread-3] INFO com.zaxxer.hikari.HikariDataSource - googleApiDb - Запущено. 17: 40: 55.553 [pool-1-thread-3] INFO c .q. c .google.GoogleCalendarPusher - Создание события в Календаре Google 17: 40: 55.690 [pool-1-thread-3] INFO c .q. c .google.GoogleCalendarPusher - Создание службы календаря Google ... 17: 40: 57.063 [pool-1-thread-3] ОШИБКА c .q. c .rabbitmq.RabbitMQEventConsumer - Ошибка толкающее событие. Сообщение было добавлено в очередь. Трассировка исключения: java .lang.NoSuchMethodError: com.google.common.io.ByteStreams.exhaust (Ljava / io / InputStream;) J 17: 40: 57.065 [pool-1-thread-3] ОШИБКА c .r. c .impl.ForgivingExceptionHandler - потребитель com.qpercom.consumer.rabbitmq. RabbitMQEventConsumer$$anon$1@56acb716 (amq.ctag-CJwhF_0CeOmwK1kBKrQLXw) метод handleDelivery для канала AMQChannel (amqp: // zdMBDgTdd9fMMJft@3.249.159.145 5672): 5672 исключение для канала AMQChannel (amqp: // zdMBDgTdd9fMMJft@3.249.159.145: 5672 /, 1) java .lang.NoSuchMethodError: com.google.common.io.ByteStreams.exhaust (Ljava / io / InputStream;) J на ​​ком. google.api.client.http.ConsumingInputStream.close (ConsumingInputStream. java: 40) на com.faster xml .jackson.core. json .UTF8StreamJsonParser._closeInput (UTF8StreamJsonParser. java 237): 237) .faster xml .jackson.core.base.ParserBase.close (ParserBase. java: 345) на com.faster xml .jackson.core. json .UTF8StreamJsonParser.close (UTF8StreamJsonParser. java: 808) на com.google.api.client. json .jackson2.JacksonParser.close (JacksonParser. java: 50) на com.google.api.client. json .JsonParser.parse (JsonParser. java: 365) на com.google.api.client. json .JsonParser.parse (JsonParser. java: 337) на com.google.api.client. json .JsonObjectParser.parseAndClose (JsonObjectParser. java: 79) на com.google.api.client. json .JsonObjectParser.parseAndClose (JsonObjectParser. java: 73) на com.google.api.client. HttpResponse.parseAs (HttpResponse. java: 444) в com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken (ServiceAccountCredentials. java: 447) в com.google.auth.oauth2.OAuth2rereA . java: 157) по адресу com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata (OAuth2Credentials. java: 145) по адресу com.google.auth.oauth2.ServiceAccountCredentials.getRequestMetadata (ServiceAccountCredentials * 603 * 603): 603 * 603): 60) com.google.auth.http.HttpCredentialsAdapter.initialize (HttpCredentialsAdapter. java: 91) по адресу com.google.api.client.http.HttpRequestFactory.buildRequest (HttpRequestFactory. java: 88.i) в com. client.googleapis.services.Ab stractGoogleClientRequest.buildHttpRequest (AbstractGoogleClientRequest. java: 300) по адресу com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed (AbstractGoogleClientRequest. java: 41.gap.isap. AbstractGoogleClientRequest.executeUnparsed (AbstractGoogleClientRequest. java: 352) по адресу com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute (AbstractGoogleClientRequest. java: 469) в comG.google.com GoogleCalendarPusher. scala: 145) на com.qpercom.calendar.google.GoogleCalendarPusher.doCreate (GoogleCalendarPusher. scala: 54) на com.qpercom.calendar.google.GoogleCalendarPusher.doCreate (GoogleCalendarPusher. scala: 25) на com.qpercom.calendar.AbstractAPICalendarPusher.pushCreateOrUpdate (AbstractAPICalendarPusher. scala: 74) на ком. qpercom.App $$ anonfun $ main $ 1.apply (приложение. scala: 26) на com.qpercom.App $$ anonfun $ main $ 1.apply (приложение. scala: 22) на com.qpercom.consumer. rabbitmq.RabbitMQEventConsumer $$ anon $ 1.handleDelivery (RabbitMQEventConsumer. scala: 49) в com.rabbitmq.client.impl.ConsumerDispatcher $ 5.run (ConsumerDispatcher. java: 149) клиентская аудитория. $ WorkPoolRunnable.run (ConsumerWorkService. java: 100) в java .util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor. java: 1149) в java .util.concurrent.ThreadPoolExecutor . java: 624) в java .lang.Thread.run (Thread. java: 748)

1 Ответ

0 голосов
/ 04 мая 2020

С некоторой IDE есть плагин для отладки такого рода кейсов. enter image description here

В любом случае google-api-client 1.22.0, как вы можете видеть, зависит от guava-jdk5 17. Эта версия находится в конфликте с google-out-library.oath2-http, для которой требуется версия guava> 20

Попробуйте изменить ваш pom. xml вот так

    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.22.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava-jdk5</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Это приведет к:

enter image description here

При этом вы исключаете старую версию и используете версию 23.0 вместо 17.0. Надеюсь, это поможет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...