Conflicting module versions. Module [groovy-xml is loaded in version 4.x.x and you are trying to load version 3.x.x - spring-cloud

I am working to setup wiremock for springboot rest api and using rest assured and spring-cloud-starter-contract-stub-runner from spring cloud. when i run the sample integration test i encounter module conflict error

check your dependency tree of pom file. The reason for the error is there were two groovy libs in your class path with different versions and this is causing the conflict
One from rest-assured dependency and other from spring-cloud-starter-contract-stub-runner dependency
Solution is to remove rest assured and replace it with restdocs-api-spec-restassured dependency. This way you can use rest assured with out additional groovy dependency
. your class path will only have 1 groovy from spring-cloud-starter-contract-stub-runner dependency

Found this workaround on Rest Assured's GitHub page. You replace Rest Assured's dependency with this one
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.1.1</version>
<scope>test</scope>
<exclusions><!-- https://www.baeldung.com/maven-version-collision -->
<exclusion>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>5.1.1</version>
<scope>test</scope>
</dependency>
Rest Assured's Github Page

1 just manually remove rest-assured dependency from POM file.
2 add to the pom file
<dependency>
<groupId>com.epages</groupId>
<artifactId>restdocs-api-spec-restassured</artifactId>
<version>0.10.4</version>
</dependency>
3 Maven clean
4 Maven Compile
5 Maven - Reload(refresh)

Related

Error with a excluded dependency in Spring Boot project: exclusion.artifactId with value '*' does not match a valid id pattern

If I want to build my project with maven package, I get the warning from Maven:
Some problems were encountered while building the effective model for
ch.mobi.ama:logcollector:jar:1.0.0-SNAPSHOT [WARNING]
'dependencyManagement.dependencies.dependency.exclusions.exclusion.artifactId'
for org.quartz-scheduler:quartz:jar with value '*' does not match a
valid id pattern. #
org.springframework.boot:spring-boot-dependencies:2.1.6.RELEASE,
c:\ieu.m2\repository\org\springframework\boot\spring-boot-dependencies\2.1.6.RELEASE\spring-boot-dependencies-2.1.6.RELEASE.pom,
line 2619, column 25
I've tried older Spring Boot versions. Version 2.1.5 had the same problem. With 2.1.4 there is no warning.
In line 2619 of the specified file spring-boot-dependencies-2.1.6.RELEASE.pom there is actually the following code:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
<exclusions>
<exclusion>
<artifactId>c3p0</artifactId>
<groupId>com.mchange</groupId>
</exclusion>
<exclusion>
<artifactId>*</artifactId>
<groupId>com.zaxxer</groupId>
</exclusion>
</exclusions>
</dependency>
Since the given code comes from Spring Boot, I can't influence it and have a bad feeling. Will my project be properly built? Do I have to go back to version 2.1.4? Do I have to report the problem to Spring Boot?
What can I do?
It's a maven new feature. Upgrade your maven to some version > 3.2.1.
https://maven.apache.org/docs/3.2.1/release-notes.html

Is there a reason why the Eclipse build cannot find a Maven lib

Is there a reason why eclipse can't find this lib when it is added in Maven dependency with success.
Is there an error here ?
This is the Maven dependency:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.1.GA</version>
</dependency>
The dependency mentioned is not the correct dependency since it is not the artifact of the RESTEasy JAX RS Implementation. Therefore it neither contains org.jboss.resteasy.ClientRequest nor org.jboss.resteasy.ClientResponse.
In order to have access to the required classes, the dependency ought to be used is the following:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>${resteasy.version}</version>
</dependency>

Creating Akka project in OSGi

I am hoping to run an Akka project within an OSGi container (apache-servicemix-4.4.1-fuse-06-03) but am having a little trouble installing the dependent libraries. I have already installed akka-actor and config as follows:
osgi:install -s mvn:com.typesafe.akka/akka-actor/2.1-SNAPSHOT
osgi:install -s mvn:com.typesafe/config/0.4.1
But am unable to install scala-library (v2.9.2 required). I have tried creating my own bundle using the maven-bundle-plugin but to no avail and have googled round for ages.
Any help would be greatly appreciated.
If you're looking for a quick workaround, use the bundle from your Scala IDE/Eclipse for Scala 2.9.2. I did that for my Akka 2.1/Karaf POC and it worked fine. If you don't have one, download it from my lib folder here.
This was kindly uploaded after posting on the scala-users group:
https://github.com/guofengzh/scala-lang-osgi
The built binaries of scala-lang-osgi referred by #ben1729 is now available on our Bippo/Soluvas Nexus repository public repository: http://nexus.bippo.co.id/nexus/content/groups/public/
Feel free to browse our repository at http://nexus.bippo.co.id/nexus/
Usage:
<repository>
<id>bippo-nexus-public</id>
<url>http://nexus.bippo.co.id/nexus/content/groups/public/</url>
</repository>
then add one or all of them to your Maven POM file:
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-library</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-dbc</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-swing</artifactId>
<version>2.9.2</version>
</dependency>
Please let me know when a new version comes out so I can redeploy the newer artifacts to our repo.
Update: Scala OSGi 2.10-M6 is now available on our repository:
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.0-M6</version>
</dependency>
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.10.0-M6</version>
</dependency>
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-dbc</artifactId>
<version>2.10.0-M2</version>
</dependency>
<dependency>
<groupId>org.scala-lang-osgi</groupId>
<artifactId>scala-swing</artifactId>
<version>2.10.0-M6</version>
</dependency>
It can work with Akka but using a patched Akka 2.1-M1 (see http://www.assembla.com/spaces/akka/tickets/2367-osgi-manifest-references-2-9-2 ).
The patched Akka is available in our repository as: (in Karaf URL)
mvn:com.typesafe.akka/akka-actor/2.1-M1/jar/patch2
Summary on Akka bug: Akka 2.1-M1 requires 2.10-M6, it doesn't work with 2.9.2 :
Error executing command: Error starting bundles:
nable to resolve 160.0: missing requirement [160.0] osgi.wiring.package; (&(osgi.wiring.package=scala.collection.convert)(version>=2.9.2)(!(version>=2.10.0)))
But it currently imports the wrong package versions:
scala.collection.convert;version="[2.9.2,2.10)",
scala.concurrent.util;version="[2.9.2,2.10)",
scala.concurrent.util.duration;version="[2.9.2,2.10)",

Using Guava bundled with GWT

GWT 2.2 and later includes Guava. The package containing Guava is com.google.gwt.thirdparty.guava. However, there doesn't seem to be a module XML file that would allow this package to be used in client (translatable) code. Based on this observation, it would seem that this copy of Guava is intended for GWT-internal use only.
For GWT projects using Guava, is the suggested approach to download Guava separately? If not, what is the process for including com.google.gwt.thirdparty.guava in client code?
Yes, if you want to use Guava yourself, you'll need the guava and guava-gwt jars, and reference the modules you want in your gwt.xml file. In the past, you've also needed jsr305, although my understanding is that this was being fixed, so you may not need that in r09
Your assumption is correct; it's for internal use only; download it separately. If using Maven, include the following in your pom.xml:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r07</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r07</version>
<classifier>gwt</classifier>
<scope>provided</scope>
</dependency>
<!-- for the source/classes for javax.annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>1.3.9</version>
<scope>provided</scope>
</dependency>

Maven missing transitive dependency

I have a maven project with a dependency (datanucleus-db4o). This dependency has itself a dependency on db4o (db4o:db4o:jar:7.12.126.14142-all-java5).
Now maven says:
09.09.10 19:43:09 MESZ: Missing artifact db4o:db4o:jar:7.12.126.14142-all-java5:compile
I am new to maven. Is it right that datanucleus-db4o defines its own dependency with a specific version number? Is this a good way? m2eclipse can't download it. I downloaded a newer Version of db4o and added it to the classpath. Maven keeps writing about the missing artifact.
Also I've got NoClassDefFound errors when I launch my application. This leads me to the other question:
Am I doing something wrong?
Thanks in advance.
Here is the relevant part of the pom.xml...
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>2.2.0-m1</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-db4o</artifactId>
<version>2.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
and here is the relevant part of the pom.xml of
<dependency>
<groupId>db4o</groupId>
<artifactId>db4o</artifactId>
<version>7.12.126.14142-all-java5</version>
</dependency>
Is it right that datanucleus-db4o defines its own dependency with a specific version number? Is this a good way?
I'm not sure I understood the question... Anyway, there is indeed something wrong with the db4o:db4o dependency of the datanucleus-db4o artifact: it is not available in Maven central nor in the DataNucleus repository. I don't understand how users are supposed to use the datanucleus-db4o artifact.
I downloaded a newer Version of db4o and added it to the classpath. Maven keeps writing about the missing artifact.
Not sure what you did exactly but maybe the following will work: exclude the dependency that can't be resolved and replace it with some equivalent from the db4o repository.
<dependencies>
...
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-db4o</artifactId>
<version>2.1.1</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>db4o</groupId>
<artifactId>db4o</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-full-java5</artifactId>
<version>7.12-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
...
<repository>
<id>db4o</id>
<url>https://source.db4o.com/maven</url>
</repository>
</repositories>
I have no idea if this will work of course.
Also I've got NoClassDefFound errors when I launch my application. This leads me to the other question:
Can't say since you didn't post the error. But give the above a try.
The required file is not in the maven repositories, but it is in the datanucleus zip file (that one with all dependencies). Look into the /deps folder.
I unpacked it and installed it into the local maven repository with this command:
./mvn install:install-file -Dfile=/home/myUser/Downloads/db4o-7.12.126.14142-all-java5.jar -DgroupId=db4o -DartifactId=db4o -Dversion=7.12.126.14142-all-java5 -Dpackaging=jar
After that it is found by maven. Now there are other problems going on. I'll try to solve them myself...
Seems like the JDO or Datanucleus stuff is not well organized at the moment. I think they refactored some classes and now they can't be found at some versions and implementations are incompatible with the api and such stuff.