When attempting to test a neo4j server using neo4j-harness, I get a noclassdeffound exception when building the embedded Neo4j server
private final Neo4j embeddedNeo4jServer = Neo4jBuilders.newInProcessBuilder()
.withDisabledServer()
.withFixture("")
.build(); // exception here
My pom.xml looks like this:
<dependencies>
<!-- Core Dependencies -->
<dependency><groupId>org.neo4j.driver</groupId><artifactId>neo4j-java-driver</artifactId><version>4.4.5</version></dependency>
<dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-streams</artifactId><version>3.0.0</version></dependency>
<dependency><groupId>org.apache.curator</groupId><artifactId>curator-x-discovery</artifactId><version>4.2.0</version></dependency>
<dependency><groupId>org.json</groupId><artifactId>json</artifactId><version>20211205</version></dependency>
<dependency><groupId>org.slf4j</groupId><artifactId>slf4j-simple</artifactId><version>1.7.30</version></dependency>
<!-- Test Dependencies -->
<dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter</artifactId><version>5.8.2</version><scope>test</scope></dependency>
<dependency><groupId>org.skyscreamer</groupId><artifactId>jsonassert</artifactId><version>1.5.0</version><scope>test</scope></dependency>
<dependency><groupId>org.neo4j.test</groupId><artifactId>neo4j-harness</artifactId><version>4.4.5</version><scope>test</scope></dependency>
<!-- Spring dependencies for an embedded Kafka instance -->
<dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka</artifactId><version>2.8.3</version><scope>test</scope></dependency>
<dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka-test</artifactId><scope>test</scope><version>2.8.3</version></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><version>2.6.4</version>
<exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency>
<!-- Mockito dependencies - NOTE: the inline dependency replaces the core one, but might be removed in future versions-->
<!--<dependency><groupId>org.mockito</groupId><artifactId>mockito-core</artifactId><version>4.4.0</version><scope>test</scope></dependency>-->
<dependency><groupId>org.mockito</groupId><artifactId>mockito-junit-jupiter</artifactId><version>4.4.0</version><scope>test</scope></dependency>
<dependency><groupId>org.mockito</groupId><artifactId>mockito-inline</artifactId><version>4.4.0</version><scope>test</scope></dependency>
</dependencies>
There is a clash in the version of scala-library used in spring-kafka-test and neo4j-harness.
To resolve this, you can exclude the scala dependency from spring-kafka-test, meaning the neo4j-harness version will be used for both.
To do this, add an exclusion in the pom.xml:
<dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka-test</artifactId><scope>test</scope><version>2.8.3</version>
<exclusions><exclusion><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId></exclusion></exclusions></dependency>
Related
I want to include XStream in my RCP project and used a Maven Dependency to add it to my target definition.
<location includeDependencyDepth="infinite" includeDependencyScopes="compile,provided,runtime,test,system,import" includeSource="true" missingManifest="generate" type="Maven">
<dependencies>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.20</version>
<type>jar</type>
</dependency>
</dependencies>
</location>
From this diagram, it seems like xmlpull is present but XStream throws ClassNotFoundException in the constructor.
java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException cannot be found by xstream_1.4.20
Looking more closely, I see that there are a number of new plugins named wrapped.bundlename. I then reconfigured the Maven Dependency to produce a feature and added the feature to my core feature.
The run configuration picked up the new feature but xmlpull was still not found at runtime. In desperation, I added all plugins (xmlpull included) to the run configuration but there was no improvement.
Is this the right approach for creating plugins from maven dependencies?
I have 4 modules in my project.
Module1 (i.e. com.assign.print:printlog.value:3.0.0-SNAPSHOT) has one class i.e. Foo.java, inside this class, on more class is there which is using com.print.assess: mns.pro:2.0
Module2 , Module2 and Module4 are using com.print.assess: mns.pro:6.2.
In my project main pom.xml, the dependency is added as :
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>6.2</version>
</dependency>
In Foo.java, I have one class as DataVal.java which is using older version.
If I don't add
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>2.0</version>
</dependency>
to Module1 pom.xml, Redline error is coming for DataVal.java saying "cannot resolve the symbol". So when I added the dependency with version 2.0, the error was resolved but while installing project:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.print.assess:mns.pro:6.2 paths to
dependency are:
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.app.print:print.sal:1.1.3
+-com.print.assess:mns.pro:6.2
and
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.print.assess:mns.pro:2.0
and
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.print.assess.over:multi-task.rev:3.1
+-com.print.assess:mns.pro:6.2
How to resolve this issue?
Thanks in advance
If you have the dependencyConvergence enforcer rule active (which you obviously have), you need to determine your versions in the <dependencyManagement> (which is different from the standard <dependencies>).
Then you can declare the dependencies without version in <dependencies>. dependencyManagement entries can be in the main pom and in modules as well. #Bahmut gave you the link to understand dependencyManagement.
You may want to move your 6.2 dependency in your main pom to <dependencyManagement> so it does not get imported by default. Then you can simply import the 6.2 version in your module poms like this:
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
</dependency>
and in the module where you need version 2, you can import it like this:
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>2.0</version>
</dependency>
More information about dependency management can be found here:
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
My configuration is:
Scala 2.11 (plugin Scala IDE)
Eclipse Neon.3 Release (4.6.3)
Windows 7 64bit
I want run this simple scala code (Esempio.scala):
package it.scala
// importo packages di Spark
import org.apache.spark.SparkContext
import org.apache.spark.SparkConf
object Wordcount {
def main(args: Array[String]) {
val inputs: Array[String] = new Array[String](2)
inputs(0) = "C:\\Users\\FobiDell\\Desktop\\input"
inputs(1) = "C:\\Users\\FobiDell\\Desktop\\output"
// oggetto SparkConf per settare i parametri sulla propria applicazione
// da fornire poi al cluster manager scelto (Yarn, Mesos o Standalone).
val conf = new SparkConf()
conf.setAppName("Smartphone Addiction")
conf.setMaster("local")
// oggetto SparkContext per connessione al cluster manager scelto
val sc = new SparkContext(conf)
//Read file and create RDD
val rawData = sc.textFile(inputs(0))
//convert the lines into words using flatMap operation
val words = rawData.flatMap(line => line.split(" "))
//count the individual words using map and reduceByKey operation
val wordCount = words.map(word => (word, 1)).reduceByKey(_ + _)
//Save the result
wordCount.saveAsTextFile(inputs(1))
//stop the spark context
sc.stop
}
}
So, if I use the Spark-shell everything is ok otherwise, from Eclipse IDE, if I select the file (Esempio.scala) and run it via Run->Run as->Scala application, I obtain this Exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.apache.spark.SparkContext.withScope(SparkContext.scala:701)
at org.apache.spark.SparkContext.textFile(SparkContext.scala:830)
at it.scala.Wordcount$.main(Esempio.scala:47)
at it.scala.Wordcount.main(Esempio.scala)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Incompatible Jackson version: 2.8.8
at com.fasterxml.jackson.module.scala.JacksonModule$class.setupModule(JacksonModule.scala:64)
at com.fasterxml.jackson.module.scala.DefaultScalaModule.setupModule(DefaultScalaModule.scala:19)
at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:745)
at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82)
at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala)
... 4 more
My pom.xml file is:
<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>it.hgfhgf.xhgfghf</groupId>
<artifactId>progetto</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>progetto</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Neo4j JDBC DRIVER -->
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc-driver</artifactId>
<version>3.1.0</version>
</dependency>
<!-- Scala -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.11</version>
</dependency>
<!-- Spark -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
</project>
I noticed that the .jar files that are into spark-2.2.1-bin-hadoop2.7/jars directory are:
jackson-core-2.6.5.jar
jackson-databind-2.6.5.jar
jackson-module-paranamer-2.6.5.jar
jackson-module-scala_2.11-2.6.5.jar
jackson-annotations-2.6.5.jar
Can anyone explain to me in simple terms what this exception is and how can it be resolved?
Spark 2.x contains the jackson 2.6.5 and neo4j-jdbc-driver uses jackson 2.8.8 version, here the dependency conflict between two different version of jackson library.
That's why you are getting this Incompatible Jackson version: 2.8.8 error.
Try to override the dependency version for these[below] modules inside your pom.xml and see if works,
jackson-core
jackson-databind
jackson-module-scala_2.x
or try adding below dependency into your pom.xml
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.11</artifactId>
<version>2.8.8</version>
</dependency>
Not sure if this helps anyone whos had the problem with an sbt project thats using scala 2.12. Putting in jackson-module-scala_2.11 doesn't quite work. There a single version of jackson-module-scala 2.6.7 that has a scala 2.12 build
Following line in build.sbt worked
dependencyOverrides ++= {
Seq(
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.6.7.1",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.6.7",
"com.fasterxml.jackson.core" % "jackson-core" % "2.6.7"
)
}
This fixed the problem for spark 2.4.5
Scala version 2.1.1 works with Jackson 2.6.5. Use the following:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.5</version>
</dependency>
I did run into the same version conflict of Jackson. In addition to override jackson-core, jackson-databind, jackson-module-scala_2.x, I also defined jackson-annotations in my pom.xml, which solved the conflict.
Explanation:
This exception occurs when there is a dependency conflict between two different versions of the Jackson library.
To resolve conflicts maven proceeds as follows:
It uses a a nearest-wins strategy.
If dependencies are on the same level, in that case maven would resolve the conflict by simply using the one, which has a higher position in pom.
This can lead to picking to wrong Jackson version.
Solution:
To detect the conflict, you can use in intelliJ the plugin Maven Helper. It will allow you to exclude conflictuel dependencies using the <exclusions> element in the element by which the problematic jar is included.
Note:
This error can also happen when trying to launch a spark Job on cluster mode. In this case, you have to specify explicitally the jar using the spark.driver.extraClassPath and spark.executor.extraClassPath configurations with the spark-submit command.
--conf spark.driver.extraClassPath
--conf spark.executor.extraClassPath
I was getting error Incompatible Jackson version: 2.9.9-3
I added
libraryDependencies += "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.14.0" in build.sbt
.build project(Build => Rebuild project)
.Invalidate and restart(file=>Invalidate cache)
it's worked for me
Below is the combination that worked for me .
aws-java-sdk-1.7.4.jar
hadoop-aws-2.7.3.jar
joda-time-2.9.6.jar
hadoop-client-2.7.3-sources.jar
hadoop-client-2.7.3.jar
hadoop-client-2.6.0-javadoc.jar
hadoop-client-2.6.0.jar
jets3t-0.9.4.jar
jackson-core-2.10.0.jar
jackson-databind-2.8.6.jar
jackson-module-scala_2.11-2.8.5.jar
jackson-annotations-2.8.7.jar
I have an existing JEE Maven and Eclipse project:
mainProject.ear
+--project1.war
+--project2.war
+--ejb-proj.jar
I would like to have a test profile for unit testing the EJB project, including read/write database with JPA.
I have added a dependency in my pom.xml like this:
<!-- Embedded glassfish -->
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.0-74b</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<port>8080</port>
<autoDelete>true</autoDelete>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
</dependencies>
Then I have created a test class:
#Before
public void setup() {
// instantiate container and context
ejbContainer = EJBContainer.createEJBContainer();
logger.info("Opening the container");
ctx = ejbContainer.getContext();
}
These are the Maven goals, in Eclipse "skip test" is unflagged:
clean compile package
Glassfish is correctly started but I get an error about missing jdbc driver.
Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource
So, these are the questions:
Why is the mysql dependency in embedded glassfish ignored ?
Is it correct to start the embedded container from the test class ? Maybe it would be better to have it started during the test phases.
In the end I want the container to be initialized only for the ejb test, so I suppose I have to deploy the ejb jar only. How can I do that ?
For completeness, the same maven goals with skip test = true just work. And the .ear deployed in a running container works too.
I'm running in to a problem where I cannot start a spring boot server due to the same problem listed in this question:
How to set up Spring Boot and log4j2 properly?
I am encountering this scenario because the spring boot project has a dependency on a jar that includes elasticsearch, which includes a new version of slf4j that isn't compatible with spring boot
I tried the recommended solution by implementing every exclusion in the elasticsearch project dependency definition possible, but for some reason the new version keeps being picked up. I cannot seem to force the spring boot project to ignore the logging packages used by the elasticsearch project.
Here is my pom for the spring-boot project, see the dependency for problematic.project.import : http://pastebin.com/Yeq2qk9Y
Here is the pom for the project that is being imported into the spring boot project: http://pastebin.com/gknmf6Tt
The error I am getting is:
Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(Lorg/apache/logging/log4j/core/config/ConfigurationSource;)Lorg/apache/logging/log4j/core/config/Configuration;
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadConfiguration(Log4J2LoggingSystem.java:165)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadDefaults(Log4J2LoggingSystem.java:148)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:75)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
Any tips on how to get this issue cleared? Is this possible for two versions of this set of libraries to be loaded, each module ignorant to the version they don't need?
You can exclude the cyclic dependencies by using the <exclusions> tag in your pom.xml like this:
<dependency>
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>sample.ProjectE</groupId> <!-- Exclude Project-E from Project-B -->
<artifactId>Project-E</artifactId>
</exclusion>
</exclusions>
</dependency>
You should exclude the cyclic dependency of the newer version from the dependency which is having it and that way only the older version will be loaded and not both.
Here is the link for more information:
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html