We have recently migrated our ivy to maven repositories but I am running into an issue with a few artifacts that contain multiple jars per artifact. For instance the artifact located at org.apache.xml:xalan-j:2.7.1 and with in that location there are the following jars that I need to access
serializer.jar
xalan.jar
xsltc.jar
Can maven handle this situation and if so some guidance would be greatly appreciated.
---Code---
<?xml version="1.0" encoding="UTF-8"?>
<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>org.apache.xml</groupId>
<artifactId>xalan-j</artifactId>
<packaging>pom</packaging>
<version>2.7.1</version>
<url>http://xml.apache.org/xalan-j/</url>
<dependencies>
<dependency>
<groupId>org.apache.xerces</groupId>
<artifactId>xerces</artifactId>
<version>[2.7,)</version>
</dependency>
<dependency>
<groupId>org.apache.xml</groupId>
<artifactId>xml-commons-external</artifactId>
<version>[1.3,)</version>
</dependency>
<dependency>
<groupId>org.apache.xml</groupId>
<artifactId>xalan-j</artifactId>
<version>2.7.1</version>
<classifier>xalan</classifier>
</dependency>
<dependency>
<groupId>org.apache.xml</groupId>
<artifactId>xalan-j</artifactId>
<version>2.7.1</version>
<classifier>xsltc</classifier>
</dependency>
<dependency>
<groupId>org.apache.xml</groupId>
<artifactId>xalan-j</artifactId>
<version>2.7.1</version>
<classifier>serializer</classifier>
</dependency>
</dependencies>
Related
I want to add Jackson-databind dependency but I still have no jackson classes in my project. I changed my project from gradle to maven and my pom.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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>pl.TODOList</groupId>
<artifactId>TODO_List</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-xml-databind</artifactId>
<version>0.6.2</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<jackson.version>2.12.4</jackson.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
I don't know if my pom.xml is something wrong or something different. I have feeling that is very simple error that I can't see
At first this project using two different artifacts for databinding.
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-xml-databind</artifactId>
<version>0.6.2</version>
</dependency>
This artifact is an antient one. It released in 2011.
Second, the managed dependencies are not "real" dependencies. In this case you can imagine managed dependencies as a dependency templates. So, if you want to use a managed dependency as a "real" dependency, then you have to describe those artifacts in <dependencies></dependencies> section.
Try something like this
<?xml version="1.0" encoding="UTF-8"?>
<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>pl.TODOList</groupId>
<artifactId>TODO_List</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<jackson.version>2.12.4</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope> <!-- Because this used for testing purposes only -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson.version}</version>
</dependency>
</dependencies>
</project>
UPDATE Based on comment I added the xml databind extension.
I have added slf4j dependency from mvn repository.
My pom.xml is given below after adding that dependency :
<?xml version="1.0" encoding="UTF-8"?>
<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">
<groupId>org.example</groupId>
<artifactId>KafkaProject</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
After adding this dependency in my project, it is giving an error saying that:
Dependency 'org.slf4j:slf4j-simple:1.7.25' not found
By the way, I am using IntelliJ IDEA. So, how to resolve this issue ?
It's not giving me the error.
I think the dependencies are not downloaded due to slow network.
Try to update the project by doing Maven Update/Install to download the dependencies again.
Try this pom.xml :
<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>org.example</groupId>
<artifactId>KafkaProject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>simple Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>KafkaProject</finalName>
</build>
</project>
my maven project has multiple maven modules. Two of those modules (product and feature) are dependent on each other. When I include the modules as dependencies in the pom files, an ! mark appears on the modules. On running maven install I get this error.
The projects in the reactor contain a cyclic reference: Edge between
'Vertex{label='com.catalog:feature:0.0.1-SNAPSHOT'}' and
'Vertex{label='com.catalog:product:0.0.1-SNAPSHOT'}' introduces to
cycle in the graph com.catalog:product:0.0.1-SNAPSHOT -->
com.catalog:feature:0.0.1-SNAPSHOT --> com.catalog:product:0.0.1-
SNAPSHOT #
Without adding the dependencies Product can't access functions defined in Feature module and vice versa.
The parent pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.catalog</groupId>
<artifactId>catalog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.enterprise</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
</dependencies>
<modules>
<module>category</module>
<module>resource</module>
<module>hibernate</module>
<module>product</module>
<module>helper</module>
<module>feature</module>
</modules>
Product module pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.catalog</groupId>
<artifactId>catalog</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>product</artifactId>
<name>product</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>hibernate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>category</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>helper</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Feature module pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.catalog</groupId>
<artifactId>catalog</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.catalog</groupId>
<artifactId>feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>feature</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>hibernate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>product</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Design smell.
Refactor your modules. Basically everything which is needed in both modules should go into a common dependency. You cannot have cycles in your dependency tree, it just won't work.
Update: As this answer is occasionally getting a new upvote, I wanted to mention: the "tree" in "dependency tree" refers to a tree from graph theory, which means that by definition you cannot have cycles :)
It may not work for your particular situation but another option to rectify cyclical dependencies is to use events.
First, set your modules up in a tree with no cyclical dependencies. Put your Event classes at the top of the tree. Then publish and listen for events in any of the modules. This allows you to have modules that communicate with each other without depending on each other.
For how to publish and listen for events in Spring see:
https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2
I am currently trying to introduce a BOM (bill of materials) file to my Maven project, but it does not seem to work and I have no clue, why.
This is my bom:
<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>com.private</groupId>
<artifactId>test.bom</artifactId>
<version>5.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<version.CoreAnnotation>5.0.0-SNAPSHOT</version.CoreAnnotation>
<version.CoreWeb>5.0.0-SNAPSHOT</version.CoreWeb>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreAnnotation</artifactId>
<version> ${version.CoreAnnotation}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreWeb</artifactId>
<version>${version.CoreWeb}</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>
There are many more, but I excluded them because I think this should be enough as an example.
This is my pom (where I try to include the bom):
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>Core</artifactId>
<groupId>com.private</groupId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>Core-ear</artifactId>
<packaging>ear</packaging>
<name>Core-ear: EAR Module for private</name>
<properties>
<version.test.bom>5.0.0-SNAPSHOT</version.test.bom>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>test.bom</artifactId>
<version>${version.test.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Whenever I use maven install there should be a collection of all packages defined in the dependencies section appear in the folder \target\Core-ear\
Now the problem: The dependencies defined in the bom don't appear there. What could be the problem?
ps: running mvn install -X for debugging does not seem to help.
This happens because you did not declare the dependencies in your POM. You only declared the <dependencyManagement> section.
In your POM, you need to add the following dependencies, without the version:
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreAnnotation</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreWeb</artifactId>
<type>war</type>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>test.bom</artifactId>
<version>${version.test.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Refer to Introduction to the Dependency Mechanism: BOM are used to factor version of all the artifacts, so you don't need to add it in your <dependency> section.
I'm trying to add jinput to my project. I'm using Netbeans as an IDE. I'm really unable to find any resources on jinput that aren't broken or ancient. I was really hoping the Maven approach would work but it seems it can't find the appropriate drivers which are stored as Runtime Dependencies.
Here is my POM file:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.mycompany</groupId>
<artifactId>controller</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-platform</artifactId>
<version>2.0.6</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>net.java.jutils</groupId>
<artifactId>jutils</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-platform</artifactId>
<version>2.0.6</version>
<classifier>natives-windows</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-platform</artifactId>
<version>2.0.6</version>
<classifier>natives-linux</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-platform</artifactId>
<version>2.0.6</version>
<classifier>natives-osx</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>2.0.6</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
Here's the error I'm getting when I try to run one of the jinput test classes from their GIT repo:
java.lang.UnsatisfiedLinkError: no jinput-raw_64 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
All the drivers are part of the jinput-platform dependency. Note that the code itself has no compiler issues. I'm fairly certain the issue is with finding the appropriate library during runtime. Any recommendations?