Stackdriver monitoring nosuchmethoderror when having a 'google-api-services-compute' - google-app-engine

There is an error from a java application using the Stackdriver Monitoring client when I have a dependency to the google-api-services-compute.
exception:
java.lang.NoSuchMethodError:
com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
at io.grpc.Metadata$Key.validateName(Metadata.java:629)
at io.grpc.Metadata$Key.<init>(Metadata.java:637)
at io.grpc.Metadata$Key.<init>(Metadata.java:567)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:742)
at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:737)
at io.grpc.Metadata$Key.of(Metadata.java:593)
at io.grpc.Metadata$Key.of(Metadata.java:589)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.<init>(GrpcHeaderInterceptor.java:60)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:220)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:193)
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:185)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:155)
at com.google.cloud.monitoring.v3.stub.GrpcMetricServiceStub.create(GrpcMetricServiceStub.java:176)
at com.google.cloud.monitoring.v3.stub.MetricServiceStubSettings.createStub(MetricServiceStubSettings.java:188)
at com.google.cloud.monitoring.v3.MetricServiceClient.<init>(MetricServiceClient.java:157)
at com.google.cloud.monitoring.v3.MetricServiceClient.create(MetricServiceClient.java:138)
at com.google.cloud.monitoring.v3.MetricServiceClient.create(MetricServiceClient.java:129)
at com.vmware.adapter3.gcp.builder.GoogleCloudMonitoringManager.testGoogleCloudMonitoringConnection(GoogleCloudMonitoringManager.java:356)
on the create method:
MetricServiceClient metricServiceClient = MetricServiceClient.create();
only when Maven Dependencies :
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${project.gson.version}</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>${project.http.version}</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>${project.oauth.version}</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-compute</artifactId>
<version>v1-rev158-1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev158-1.25.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-monitoring</artifactId>
<version>1.98.0</version>
Please help me to come out of this problem.

It seems the issue is the lower case function name "create": It has to start with a higher case "C", being "Create", as in "MetricServiceClient.Create()".

Related

Payara 5 issue with deployment due to io.lettuce.core.support.LettuceCdiExtension

I tried looking for solutions to my problem but I haven't found any help.
Our application is using Redis Lettuce but during deployment using Payara 5.2022.3, I can't proceed and it's because of the LettuceCdiExtension error. Can anyone help me? I'm also using jdk11 if it helps
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:Error instantiating :io.lettuce.core.support.LettuceCdiExtension -- Error instantiating :io.lettuce.core.support.LettuceCdiExtension
at org.jboss.weld.util.ServiceLoader.createInstance(ServiceLoader.java:315)
at org.jboss.weld.util.ServiceLoader.prepareInstance(ServiceLoader.java:247)
at org.jboss.weld.util.ServiceLoader.loadService(ServiceLoader.java:215)
at org.jboss.weld.util.ServiceLoader.loadServiceFile(ServiceLoader.java:185)
at org.jboss.weld.util.ServiceLoader.reload(ServiceLoader.java:165)
at org.jboss.weld.util.ServiceLoader.iterator(ServiceLoader.java:289)
at org.glassfish.weld.DeploymentImpl.getExtensions(DeploymentImpl.java:495)
at org.glassfish.weld.WeldDeployer.processApplicationLoaded(WeldDeployer.java:518)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:434)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
Exception while loading the app : CDI deployment failure:Error instantiating :io.lettuce.core.support.LettuceCdiExtension -- Error instantiating :io.lettuce.core.support.LettuceCdiExtension]]
This is part of the pom.xml
<!-- JPA -->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-envers</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<!-- JPA End -->

Apache Flink: JMXReporterFactory could not be found

I try to check out Apache Flink's function to report metrics to external systems. I started with the JMX reporter because it doesn't need an additional dependency since it's included in Flink via "org.apache.flink.metrics.jmx.JMXReporter". I'm running everything from IntelliJ, so that I had to add the setup to my configuration like this:
Properties props = new Properties();
props.put("metrics.reporter.jmx.factory.class", "org.apache.flink.metrics.jmx.JMXReporterFactory");
Configuration conf = ConfigurationUtils.createConfiguration(props);
env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);
So far so good. I got this warning from my console:
14:06:58,715 WARN org.apache.flink.runtime.metrics.ReporterSetup [] - The reporter factory (org.apache.flink.metrics.jmx.JMXReporterFactory) could not be found for reporter jmx. Available factories: [].
So it tells me there's no available reporter factory, right? But why? In addition I get following error message, if I try to add the reporter setup with
conf.setClass("metrics.reporter.jmx.factory.class", org.apache.flink.metrics.jmx.JMXReporterFactory);
Cannot resolve symbol 'jmx'
So it can't find jmx what is strange cause the documentary told me it's included.
This is my pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-walkthrough-common_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-runtime-web_2.12</artifactId>
<version>${flink.version}</version>
</dependency>
<!-- This dependency is provided, because it should not be packaged into the JAR file. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add connector dependencies here. They must be in the default scope (compile). -->
<!-- Example:
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
-->
<!-- Add logging framework, to produce console output when running in the IDE. -->
<!-- These dependencies are excluded from the application JAR by default. -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>

Apache Shiro: Permission filter is validating last matched path

I am using Apache Shiro with Guice on Google App Engine.
Following filter chain is present in configureShiroWeb() function
addFilterChain("/**/first/second/third/**", AUTHC_BASIC, config(REST, "X"));
addFilterChain("/**/first/**", AUTHC_BASIC, config(REST, "Y"));
When a request is made for an API- example.appspot.com/v1/first/second/third, the first filter is bypassed and the access is granted for a user with permission Y and not with X.
I am using the following shiro and guice related dependencies:
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-web</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-guice</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-guice</artifactId>
<version>1.8</version>
</dependency>
Upgrade Shiro, If you are still running into this issue let us know.

Working Maven3 configuration for AppEngine + DataNucleus + JPA 2

I'm trying to create GAE project via Maven and I'm facing problem with persistence libraries configuration. I try including different dependencies and specifying different scopes, but I always get some errors like:
java.lang.NoClassDefFoundError: org/datanucleus/ObjectManagerFactoryImpl
.
java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil
.
java.lang.NoClassDefFoundError: org/datanucleus/ClassLoaderResolver
.
Invocation of init method failed; nested exception is javax.persistence.PersistenceException: No persistence providers available for "transactions-optional" after trying the following discovered implementations: org.datanucleus.api.jpa.PersistenceProviderImpl
Well, eventually I've found the solution for my case:
<!-- Persistence Dependencies -->
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.1.2</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>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>[3.1.1, 3.1.99]</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>[3.1.1, 3.1.99]</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-jpa-query</artifactId>
<version>3.0.2</version>
</dependency>
I hope it will help somebody with same issues.
check the GAE dependencies here
https://code.google.com/p/datanucleus-appengine/wiki/Compatibility
Its possible you may be using some incompatible versions.

NoClassDefFoundError: com/google/api/client/util/Lists when setting up oauth2 on app engine

We're using the following libraries:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<version>v2-rev114-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev98-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev50-1.17.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.13.1-beta</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client-appengine</artifactId>
<version>1.17.0-rc</version>
</dependency>
However, we're getting the following errors:
java.lang.NoClassDefFoundError: com/google/api/client/util/Lists
at com.google.api.client.auth.oauth2.Credential$Builder.<init>(Credential.java:625)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential$Builder.<init>(GoogleCredential.java:356)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.<init>(GoogleCredential.java:193)
at com.xyz.getStoredCredentials(GoogleUserCredentialManager.java:155)
java.lang.NoClassDefFoundError: com/google/api/client/json/JsonObjectParser$Builder
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient$Builder.<init>(AbstractGoogleJsonClient.java:74)
at com.google.api.services.bigquery.Bigquery$Builder.<init>(Bigquery.java:2913)
at com.abc.doPost(BigQuery.java:138)
So which libraries are we missing here?
this change fixed it:
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.17.0-rc</version>
</dependency>

Resources