Maven project with PI4J library - error in opening zip file - java

I've got quite strange problem with pi4j library to Raspberry Pi. I have Maven project in Eclipse and just added repository and dependency for pi4j like this:
<repository>
<id>oss-snapshots-repo</id>
<name>Sonatype OSS Maven Repository</name>
<url>https://oss.sonatype.org/content/groups/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
I don't have any pi4j code in my project and I get this error while doing mvn install:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on
project kosciol-main: Error creating shaded jar: error in opening zip
file
d:\Programy\apache-maven-3.1.1\m2\repositories\com\pi4j\pi4j-native\1.0-SNAPSHOT\pi4j-native-1.0-SNAPSHOT-hard-float.so
-> [Help 1]
If I delete dependency, project compiles without errors...
I tried to delete this pi4j repository from m2 folder but this didn't help.
How can I solve it?

Try to specify the scope of the dependency as "provided", like this:
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Related

Cannot resolve dropwizard version 2.1.3-SNAPSHOT in maven project pom in Intellij

Using the following dependency entry in my pom:
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
</dependency>
</dependencies>
Using an older dropwizard version works fine:
<properties>
<dropwizard.version>2.0.9</dropwizard.version>
</properties>
But using the most up to date version as listed on mvnrepository:
<dropwizard.version>2.1.2</dropwizard.version>
gives the following error:
Dependency 'io.dropwizard:dropwizard-core:2.1.2' not found
Additionally, using the recommended version in dropwizard's tutorial page does not work either:
<dropwizard.version>2.1.3-SNAPSHOT</dropwizard.version>
I have the following to pull snapshots in my pom:
<repositories>
<repository>
<id>nexus</id>
<name>nexus-snapshot</name>
<url>http://localhost:8081/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
Update:
By deleting io/dropwizard from my ~/.m2/repository directory and invalidating caches & restarting, I was able to load dropwizard version 2.1.2. I am still unable to determine how to properly load the SNAPSHOT version. I don't know what repository settings to add to my pom file in order to correctly link to that dependency.

Could not find an artifact in central when using maven build a project

I'm totally new to Maven. I am building an Apache projects using Maven command: mvn clean package.
It showed build failure and give the following error message:
[ERROR] Failed to execute goal on project taverna-perspective-myexperiment: Could not
resolve dependencies for project org.apache.taverna.workbench:taverna-perspective-
myexperiment:bundle:3.1.0-incubating-SNAPSHOT: Could not find artifact
org.jdom:com.springsource.org.jdom:jar:1.1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
It seems it needs a dependency org.jdom:com.springsource.org.jdom:jar:1.1.0 but it cannot find it. I searched this artifact in the internet and found a page giving the following maven configurations:
<dependency>
<groupId>org.jdom</groupId>
<artifactId>com.springsource.org.jdom</artifactId>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
I checked the pom.xml and found the dependency for org.jdom is identical with the above. What should I do to fix it? Does it mean this artifact has been removed from the central? Is there any other sources we can set for it?
in page write note:
Note: this artifact is located at Spring Plugins repository (https://repo.spring.io/plugins-release/)
then you must add https://repo.spring.io/plugins-release/ to repositories in pom.xml file:
<repositories>
<repository>
<id>spring</id>
<name>Spring Repository</name>
<url>https://repo.spring.io/plugins-release/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>com.springsource.org.jdom</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>

Install maven dependency from location other than Maven Central

I have this pom.xml file:
<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>interos</groupId>
<artifactId>jenkins</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>cli</artifactId>
<version>2.49</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jenkins-ci.main/cli -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I run
mvn install
and I get:
[ERROR] Failed to execute goal on project jenkins: Could not resolve
dependencies for project interos:jenkins:jar:1.0: Failure to find
org.jenkins-ci.main:cli:jar:2.49 in
https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced -> [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I tried doing this:
<repositories>
<repository>
<id>repository.maven</id>
<name>Spring Framework Maven Release Repository</name>
<url>https://mvnrepository.com</url>
</repository>
</repositories>
But then I got:
[ERROR] Failed to execute goal on project jenkins: Could not resolve
dependencies for project interos:jenkins:jar:1.0: Could not find
artifact org.jenkins-ci.main:cli:jar:2.49 in repository.maven
(https://mvnrepository.com) -> [Help 1]
You need to add jenkins repository
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
There are 2 possible solutions (perhaps more):
Add also Maven central to the repositories section of your pom file.
Add repositories and mirrors to the Maven settings.xml file.
Option 1 and 2 can also be combined.
Another but maybe the best solution is to use your own instance of a Nexus repository manager and load all the dependencies from that Nexus instance (that Nexus should be defined as repository). That Nexus instance should synchronize with/proxy to external repositories like Maven central, Spring, ... and so on.

Maven dependency for pd4ml

HI I searched on google and did not find the dependency for PD4ML.I have added the jar manually but everytime i do mvn clean install it is giving me compile time error
error: package org.zefer.pd4ml does not exist
org.zefer.pd4ml does not exist
I got the answer after hours spending on it
step one :download the pd4ml.jar
step two :Run the below command on command prompt
mvn install:install-file -Dfile=D:\<path to your downloaded jar>\pd4ml.jar -DgroupId=com.pd4ml.utilities -DartifactId=pd4ml -Dversion=1.0 -Dpackaging=jar
step 3 : add the dependency on pom.xml based on the groupId and artifactsId you have provided
<dependency>
<groupId>com.pd4ml.utilities</groupId>
<artifactId>pd4ml</artifactId>
<version>1.0</version>
</dependency>
Remember ss_css2 jar is also require to run the pd4ml follow the above steps to create a mvn depedency for this jar
Did you add a dependency to the pom.xml file?
Something like:
<dependency>
<groupId>org.zefer.pd4ml</groupId>
<artifactId>pd4ml</artifactId>
<version>3.2.3fx5</version>
</dependency>
In your pom.xml add the repository first to resolve the pd4ml as below:
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>http://maven.scandilabs.com/repository</url>
</repository>
</repositories>
and then in the dependencies add dependency as below:
<dependency>
groupId>org.zefer.pd4ml</groupId>
<artifactId>pd4ml</artifactId>
<version>370fx2</version>
</dependency>
Add the repository https://pd4ml.tech/maven2/ and the dependency com.pd4ml to your pom.xml:
<project ...>
<groupId>de.luckydonald.stackoverflow</groupId>
<artifactId>42805145</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>pd4ml</id>
<url>https://pd4ml.tech/maven2/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<!-- html to rtf -->
<dependency>
<groupId>com.pd4ml</groupId>
<artifactId>pd4ml</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>
</project>

can't add maven dependency - apache poi

I created this maven project in Eclipse on my mac. The following two artifacts are in my pom. No problem on MAC.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.14</version>
</dependency>
However when I recently moved the code to Eclipse on my PC I got this weird error "Missing artifact org.apache.poi:poi:jar:3.14". And it points to both the dependency block and the first line of pom (see screenshot) . Updated project many times and it did not help.
I have set up two repositories, one public and one institutional.
<repositories>
<repository>
<id>JBoss repository</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>repo</name>
<url>http://risdevtool01p.mdanderson.edu:8081/artifactory/repo</url>
</repository>
</repositories>
When I do "mvn clean install -U", it looks like it is trying to download poi and poi-ooxml from two different repositories.
Downloading:http://repository.jboss.org/nexus/content/groups/public/org/apache/poi/poi-ooxml-schemas/3.14/poi-ooxml-schemas-3.14.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/poi/poi/3.14/poi-3.14.jar
Downloading: http://risdevtool01p.mdanderson.edu:8081/artifactory/repo/org/apache/poi/poi/3.14/poi-3.14.jar
Downloading: http://risdevtool01p.mdanderson.edu:8081/artifactory/repo/org/apache/poi/poi-ooxml-schemas/3.14/poi-ooxml-schemas-3.14.jar
The problem is in the nexus of JBoss, the artifact is not properly deleted indeed we had the version in the list of available versions but the version is not available at the expected location which is http://repository.jboss.org/nexus/content/groups/public/org/apache/poi/poi/3.14/
404 - Path /org/apache/poi/poi/3.14/ not found in group repository "Public Repository Group" [id=public].
Path /org/apache/poi/poi/3.14/ not found in group repository "Public Repository Group" [id=public].
But, obviously they've just removed this version properly indeed now this version is no more part of the available versions as you can see here http://repository.jboss.org/nexus/content/groups/public/org/apache/poi/poi/ such that if you remove it from your local repository and try again with a command of type mvn clean install, it will work

Categories