Kafka POM Dependency Issue - ClassNotFoundException: org.apache.kafka.test.TestCondition - java

I'm seeing - java.lang.NoClassDefFoundError: org/apache/kafka/test/TestCondition in my integration tests. I think this is something related to way the repository import the kafka related packages. I'm adding pom dependencies with scope and classifiers used.
Could you please help fixing this?
<kafka-clients.version>0.10.2.1</kafka-clients.version>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>${kafka-clients.version}</version>
<classifier>test</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<version>${kafka-clients.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka-clients.version}</version>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${kafka-clients.version}</version>
<classifier>test</classifier>
</dependency>
TestCondition is in kafka-clients-version-test.jar
So add classifer test to 'kafka-clients' artifactId

Related

Correct the classpath of your application so that it contains a single, compatible version of org.apache.camel.impl.converter.DefaultTypeContent

I encountered this error on the console on my eclipse-workspace while setting up my pom.xml on my spring boot app. I'm currently using spring-boot version 2.5.6
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.camel.impl.converter.DefaultTypeConverter
And the code below are the dependencies that i have added.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>org-apache.camel</groupId>
<artifactId>camel-jackson-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-servlet</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>java.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>
<dependencies>
I just don't know if some of my dependencies if there are incompatibilities.
Thank you for your help in advance.
Edit:
Additional Logs
Description
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.apache.camel.impl.engine.SimpleCamelContext.createTypeConverter(SimpleCamelContext.java:138)
referring to this code
135: protected TypeConverter createTypeConverter(){
136: return new DefaultTypeConverter(
137: getCamelContextReference(), getPackageScanClassResolver(), getInjector(),
138: isLoadTypeConverter());
The following method did not exist:
org.apache.camel.impl.converter.DefaultTypeConverter. <init>(Lorg/apache/camel/CamelContext;Lorg/apache/camel/spi/PackageScanClassResolver;Lorg/apache/camel/spi/Injector:V
The method’s class, org.apache.camel.impl.converter.DefaultTypeConverter, is available from the following locations:
jar:file:/apache/camel/camel-base/3.0.0-M4/camel-base-3.0.0-M4.jar!/org/apache/camel/impl/converter/DefaultTypeConverter.class
The class hierarchy was loaded from the following locations:
org.apache.camel.impl.converter.DefaultTypeConverter: camel/camel-base/3.0.0-M4/camel-base-3.0.0-M4.jar
org.apache.camel.impl.concerter.BaseTypeConverterRegistry file: camel/camel-base/3.0.0-M4/camel-base-3.0.0-M4.jar
org.apache.camel.support.service.ServiceSupport: file:/camel/camel-api/3.13.0/camel-api-3.13.0.jar
org.apache.camel.support.service.BaseService: file:/camel/camel-api/3.13.0/camel-api-3.13.0.jar
You are mixing different version of Camel's jars. You have some at version 3.13.0 and others at 3.0.0-M4 and they are not compatible with each other.
You haven't shared all of your pom.xml so I can't tell for certain, but I would guess that the camel.version property is set to 3.0.0.M4 which is not aligned with your dependency on the Camel starter where the version is 3.13.0:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.13.0</version>
</dependency>
You should update your pom so that a consistent version is used for all of Camel's modules. You can check their versions by running mvn dependency:list on the command line.

Libraries conflict after upgrade of google-cloud library in my java software running on dataproc

I have a problem after upgrade google-cloud library from 0.8.0 to 0.32.0-alpha version on my java software running on google dataproc.
Here my maven dependencies:
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud</artifactId>
<version>0.32.0-alpha</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.19</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.19</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.33</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
This is the error I can see in the dataproc job output
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at com.google.api.gax.retrying.BasicRetryingFuture.<init>(BasicRetryingFuture.java:77)
at com.google.api.gax.retrying.DirectRetryingExecutor.createFuture(DirectRetryingExecutor.java:73)
at com.google.cloud.RetryHelper.run(RetryHelper.java:73)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:51)
at com.google.cloud.bigquery.BigQueryImpl.getTable(BigQueryImpl.java:375)
at com.google.cloud.bigquery.BigQueryImpl.getTable(BigQueryImpl.java:366)
at com.finscience.job.link.LinkAnalyzerProcess.process(LinkAnalyzerProcess.java:210)
at com.finscience.job.link.LinkAnalyzerJob.main(LinkAnalyzerJob.java:140)
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:498)
at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:755)
at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:119)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
It seems that the problem is related to google.api.gax library.
After a search I found people that solved the problem excluding guava from maven dependencies.
So I modified my google cloud dependency in this way:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud</artifactId>
<version>0.32.0-alpha</version>
<exclusions>
<exclusion>
<artifactId>com.google</artifactId>
<groupId>guava</groupId>
</exclusion>
</exclusions>
</dependency>
But unfortunately this do not solve my problem.
The github page of the google cloud library (https://github.com/googlecloudplatform/google-cloud-java) says that:
The easiest way to solve version conflicts is to use google-cloud's
BOM
So I add the following dependency to my pom:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bom</artifactId>
<version>0.41.0-alpha</version>
<type>pom</type>
<scope>import</scope>
</dependency>
but even in this case the problem has not been solved.
Could someone help me?
You are most likely running into conflicts with Spark and Hadoop jars on the Dataproc cluster. This answer goes into how to repackage jars to deal with Hadoop / Spark conflicts.

javax.enterprise.inject.Vetoed Open web beans, which jar?

I'm wanting to try out Open Web Beans 1.6.2, but the jars it lists on it's website for adding CDI support to a Java SE application
openwebbeans-spi.jar
openwebbeans-impl.jar
geronimo-jcdi_1.0_spec.jar
geronimo-atinject_1.0_spec.jar
geronimo-interceptor_1.2_spec.jar
geronimo-annotation_1.2_spec.jar
Don't seem to contain the javax.enterprise.inject.Vetoed annotation, I've had to add cdi-api 1.2 as a dependency to resolve the issue, but I'm not sure if this is correct as all other CDI dependencies were resolved by the above? Here are the dependencies I have in my pom, is this correct?
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-spi</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.2_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.2_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
This link seems to suggest support for #Vetoed was added in Open Web Beans 1.5.0
Please upgrade geronimo-jcdi_1.0_spec to jcdi_1.1 version
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_1.1_spec</artifactId>
<version>1.0</version>
</dependency>
Although your problem is weird, because you have also following entry:
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency
which also contains #Vetoed and thus should be enough. Does maven ignore it somehow?

CXF ClassNotFoundException: javax.ws.rs.MessageProcessingException

I'm trying to start a jax ws & rs server endpoints, I can get them started using rs-api 2.0 (and version 2.0.1) but when I try to make a request it throws
java.lang.NoClassDefFoundError: javax/ws/rs/MessageProcessingException
There are some other threads in SO regarding this matter but the suggestions don't work for me. Using any of the rs-api 2 milestone versions throws issues
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/BadRequestException
I'm running this as a java application, not a webapp. Anyone have any ideas to try? Thanks
EDIT: My dependencies. I added jsr311 but that did not change the MessageProcessingException
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
CXF: version 2.7.0
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
</dependency>
rs-api version: 2.0
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
jsr311 version: 1.1.1
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
Faced the same issue, but later when I used 3.0.0-milestone2 of cxf-bundle with 2.1-m01 of javax.ws.rs-api, it worked like a charm.
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1-m01</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>3.0.0-milestone2</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0-m10</version>
</dependency>
This version has support for javax.ws.rs.MessageProcessingException class.
I took this same error using Jersey client without JSON/JAXB providers to do the calls to server, when I configure Jettison provider the problem was solved. This erros also occour when I use a incompatible POJO to marshaling object to call service. check it. I hope this help.
The problem also occur when you have Classloader problems, check your maven dependecy hierarchy conflicts of jax-rs. In my case I need to use exlcusion filter in my pom.xml like
<exclusions>
<exclusion>
<artifactId>javax.ws.rs-api</artifactId>
<groupId>javax.ws.rs</groupId>
</exclusion>
</exclusions>
I made exclusion in cxf-bundle-jaxrs in another project that uses javax.ws.rs-api dependency. Using dependency of cxf-rt-frontend-jaxrs:2.7.11 was sufficient.
I had the same issue & I had to add this exclusion -
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</exclusion>

elasticsearch ElasticsearchIntegrationTest

I have written an integration test for ElasticSearch by extending ElasticsearchIntegrationTest. Top section of the test below:
import org.junit.*;
import static org.junit.Assert.assertEquals;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
public class ProductSearchTest extends ElasticsearchIntegrationTest
I'm seeing this error from JUnit when trying to run the test via maven
java.lang.NoSuchMethodError: com.carrotsearch.randomizedtesting.RandomizedContext.runWithPrivateRandomness(Lcom/carrotsearch/randomizedtesting/Randomness;Ljava/util/concurrent/Callable;)Ljava/lang/Object;
at __randomizedtesting.SeedInfo.seed([9DE685AB75B54F0A:10B1B129F9E3CB67]:0)
I've included the dependencies in the pom as described on the elasticsearch site
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>4.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.4.0</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.4.0</version>
<scope>test</scope>
</dependency>
Has anyone seen this before? It looks like i'm missing a dependency (i've tried adding a couple of the carrotsearch maven dependencies into the pom without success). Alternatively, does anyone have the integration tests working with the versions I am using, so at least if I expend hours trying to locate the dependency issue I can be confident it will work once identified.
Thank you for your time.
Indeed, it seems there is a mismatch between the randomizedtesting jar Lucene uses and the one ES uses. Try this in your pom.xml:
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>4.10.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>randomizedtesting-runner</artifactId>
<groupId>
com.carrotsearch.randomizedtesting
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.4.0</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.carrotsearch.randomizedtesting</groupId>
<artifactId>randomizedtesting-runner</artifactId>
<version>2.1.10</version>
<scope>test</scope>
</dependency>

Categories

Resources