Maven can not calculate build path in Eclipse - java

I am very new to using Maven, and I'm trying to follow along with an online tutorial using Eclipse, however when I'm writing the Maven file, I get the following Error:
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.8.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.8.1: ArtifactResolutionException: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:3.8.1 from http://repo1.maven.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. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.8.1 from/to central (http://repo1.maven.org/maven2): Failed to transfer http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.8.1/maven-compiler-plugin-3.8.1.pom. Error code 501, HTTPS Required
My pom.xml looks like this, and the plugin tag is underlined with a red error
<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.pluralsight</groupId>
<artifactId>conference</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
I've tried deleting the repository folder in my .m2 folder, and updating my project, but I haven't found any fix yet. Can someone help me out?

Your Maven versions is probably out of date.
Newer versions should automatically go to the central maven repo using HTTPS.
Your error is saying: Error code 501, HTTPS Required
When trying to go to the central repo.
Update maven to the latest version or atleast to 3.2.3.
Download the latest Maven version from: https://maven.apache.org/download.cgi
In Eclipse you can change the maven version like this:
Preferences -> Maven -> Installations -> Add...
Now select the Maven you just installated

Related

How to build nifi processor nar file and dependencies from maven central

I am trying to build a nar file from maven repo central. I am not very used to maven, so I will explain the steps I followed until the blocking point where I am stuck now.
I want to generate the nar files for this artifact:
https://mvnrepository.com/artifact/org.apache.nifi/nifi-hwx-schema-registry-nar/1.10.0
So I created 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>TestMaven</groupId>
<artifactId>TestMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-hwx-schema-registry-nar</artifactId>
<version>1.10.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifactItems>
<artifactItem>
<!-- hardcode values, or use properties, depending on what you want
to do -->
<groupId>TestMaven</groupId>
<artifactId>TestMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>[ packaging ]</type>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And then I try to compile whit this commands (first commands are to include maven dependencies on the PATH):
export JAVA_HOME=/usr/jdk64/jdk1.8.0_112
export M2_HOME=/usr/local/apache-maven
export M2=$M2_HOME/bin export PATH=$M2:$PATH
mvn -U -X dependency:copy-dependencies -DskipTests
-Dclassifier=sources -DoutputDirectory=target -Dhttp.proxyHost=X.X.X.X -Dhttp.proxyPort=80 -Dhttps.proxyHost=X.X.X.X -Dhttps.proxyPort=80
And I am getting this error, which says that the maven dependency couldn't be found:
[ERROR] Failed to execute goal on project TestMaven: Could not resolve
dependencies for project TestMaven:TestMaven:jar:0.0.1-SNAPSHOT: Could
not find artifact
org.apache.nifi:nifi-hwx-schema-registry-nar:jar:1.10.0 in central
(https://repo.maven.apache.org/maven2) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal on project TestMaven: Could not resolve dependencies for
project TestMaven:TestMaven:jar:0.0.1-SNAPSHOT: Could not find
artifact org.apache.nifi:nifi-hwx-schema-registry-nar:jar:1.10.0 in
central (https://repo.maven.apache.org/maven2)
Thank you
You would need to get the source code for Apache NiFi version 1.10.0 and then build that module.
You could get the code by cloning the git repo and checking out the tag rel/1.10.0.
https://github.com/apache/nifi/tree/rel/nifi-1.10.0/nifi-nar-bundles/nifi-standard-services/nifi-hwx-schema-registry-bundle
Then run mvn clean package from the location above.

Maven: `Unknown packaging: bundle` error from a dependency packaging as bundle

I am running mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies in my project, and I'm seeing the following errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies (default-cli) on project beam-sdks-java-core: Some problems were encountered while processing the POMs:
[ERROR] [ERROR] Unknown packaging: bundle # line 6, column 16: 1 problem was encountered while building the effective model for org.xerial.snappy:snappy-java:1.1.4
[ERROR] [ERROR] Unknown packaging: bundle # line 6, column 16
Looking at Snappy's pom file, it looks like so:
<?xml version='1.0' encoding='UTF-8'?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<packaging>bundle</packaging>
<description>snappy-java: A fast compression/decompression library</description>
<version>1.1.4</version>
<name>snappy-java</name>
....
Specifically, the <packaging>bundle</packaging> line seems to be the problem.
I tried adding the maven-bundle-plugin to my own POM file's <build> tag, but that won't fix it (and why should it? I'd think that a dependency's config shouldn't affect my pom?)
How do I enable the maven-bundle-plugin for my dependencies? Do I need to add it to a specific subsection of my pom that refers to apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies?
Also, for extra info, my Maven version is 3.5.0
I tried adding the maven-bundle-plugin to my own POM file's
tag, but that won't fix it (and why should it? I'd think that a
dependency's config shouldn't affect my pom?
And you are right : it is not the maven-bundle-plugin as a dependency that you need to
add to make the bundle package usable in your build.
What you need is adding the maven-bundle-plugin as a plugin to
enhance the default Maven lifecycle such as :
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>
....
</Include-Resource>
</instructions>
</configuration>
</plugin>
</plugins>
<build>
You can find the information in the apache-felix-maven-bundle-plugin.
This is actually an issue with snappy-java 1.1.4. Their pom does not include the bundle plugin. However, version 1.1.7 switches to jar packaging.
You can work around this by using maven-dependency-plugin 2.10.

installing a jar with maven-install-plugin to local repo creates pom without dependencies [duplicate]

I have a maven plugin, which I have not uploaded to the central repository, but which I want to use in my projects.
What works
I can install the maven plugin like this:
git clone https://github.com/RudolfVonKrugstein/jinja-maven-plugin.git
cd jinja-maven-plugin
mvn install
Then I can use the plugin like this pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>de.wintercloud</groupId>
<artifactId>sample</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>de.wintercloud</groupId>
<artifactId>jinja-maven-plugin</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>de.wintercloud</groupId>
<artifactId>jinja-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>renderjinja</goal>
</goals>
</execution>
</executions>
<configuration>
<outputFile>out.txt</outputFile>
<templateFile>templ.jinja</templateFile>
<varFile>vars.yaml</varFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here are the other files relevant to the compile:
templ.jinja:
{{ Name }}
vars.yaml:
Name: MyWonderfullName
This works:
> mvn compile
> cat out.txt
MyName
Nice!
What does not work
Now I am trying to give the plugin as a jar to my colleagues so that they can simple install the jar. The Idea is to do it like this:
git clone https://github.com/RudolfVonKrugstein/jinja-maven-plugin.git
cd jinja-maven-plugin
mvn package
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=target/jinja-maven-plugin-1.0.jar
When I now do (in the sample project dir)
mvn compile
I get this error:
[ERROR] Failed to execute goal de.wintercloud:jinja-maven-plugin:1.0:renderjinja (default) on project sample: Execution default of goal de.wintercloud:jinja-maven-plugin:1.0:renderjinja failed: A required class was missing while executing de.wintercloud:jinja-maven-plugin:1.0:renderjinja: org/yaml/snakeyaml/Yaml
How can I install the jar so that I can use it as a plugin?
It looks to me as if dependencies are missing. Why?
You just hit MINSTALL-110, which is going to be fixed in the next 3.0.0 release of the Maven Install Plugin. The core issue here is that you're installing manually a JAR file with the file parameter, the plugin detects that there is a POM inside, but only keeps the coordinate information (group id, artifact id, packaging and version), not the whole POM. As such, when the POM is installed, the dependencies aren't kept.
Indeed, if you take a look at the installed POM, you will see
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>de.wintercloud</groupId>
<artifactId>jinja-maven-plugin</artifactId>
<version>1.0</version>
<packaging>maven-plugin</packaging>
<description>POM was created from install:install-file</description>
</project>
which shows that the dependencies weren't retained. And if you take a look at the Maven logs in debug mode when running the install-file command, it will show
[DEBUG] Using META-INF/maven/de.wintercloud/jinja-maven-plugin/pom.xml for groupId, artifactId, packaging and version
A work-around waiting for version 3.0.0 is to specify the path to the POM file to install, along with the main artifact, by specifying the pomFile parameter. Run the following instead:
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=target/jinja-maven-plugin-1.0.jar -DpomFile=pom.xml
Then the full POM will be installed, not a generic stub.
With this change, the error
[ERROR] Failed to execute goal de.wintercloud:jinja-maven-plugin:1.0:renderjinja (default) on project sample: Execution default of goal de.wintercloud:jinja-maven-plugin:1.0:renderjinja failed: A required class was missing while executing de.wintercloud:jinja-maven-plugin:1.0:renderjinja: org/yaml/snakeyaml/Yaml
will not happen anymore. Maven will correctly download the dependencies and use them for the plugin.

Error building java desktop application from eclipse

I am trying to build a github project pdfSAM on eclipse. The dependencies are JAVA 8, getText and Maven. I installed all the plugins on eclipse but when I build the project using pom.xml I am getting an error for pdfsam-core project-
"Failed to execute goal on project pdfsam-core: Could not resolve dependencies for project org.pdfsam:pdfsam-core:jar:3.0.0.RELEASE-SNAPSHOT: The following artifacts could not be resolved: org.sejda:sejda-model:jar:2.0.0-alpha13, org.sejda:sejda-conversion:jar:2.0.0-alpha13: Failure to find org.sejda:sejda-model:jar:2.0.0-alpha13 in https://repository.jboss.org/nexus/content/repositories/public/ was cached in the local repository, resolution will not be reattempted until the update interval of jboss has elapsed or updates are forced -> [Help 1] "
Build error on eclipse
I also tried building the project from command line using commands
1.mvn clean install
2.mvn clean install -PfastTests
3.mvn clean install -Dmaven.test.skip=true
All the commands give me me same error and a Build failure occurs.
I am also inserting the pom.xml file of pdfsam-core-
<?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>
<description>Core pdfsam library</description>
<parent>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-parent</artifactId>
<version>3.0.0.RELEASE-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.pdfsam</groupId>
<artifactId>pdfsam-i18n</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
</dependency>
<dependency>
<groupId>org.sejda</groupId>
<artifactId>sejda-model</artifactId>
</dependency>
<dependency>
<groupId>org.sejda</groupId>
<artifactId>sejda-conversion</artifactId>
</dependency>
<dependency>
<groupId>org.sejda</groupId>
<artifactId>eventstudio</artifactId>
</dependency>
<dependency>
<groupId>jdepend</groupId>
<artifactId>jdepend</artifactId>
</dependency>
</dependencies>
</project>
Kindly give me a solution to this.
Two easy (possible) fixes:
Try to delete the artifact in your local repo and rebuild to trigger a download.
Use the -U maven goal to update the snapshot.
Top answer from experience, 2nd answer from:
When maven says "resolution will not be reattempted until the update interval of MyRepo has elapsed", where is that interval specified?

The following artifacts could not be resolved: org.apache.hbase:hbase:jar:0.96.1.1-hadoop2

I try to take the following steps:
right click on pom.xml and run as maven install in eclipse but I got this error:
[ERROR] Failed to execute goal on project tt: Could not resolve dependencies for project com.sunshineatnoon:tt:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.apache.hbase:hbase:jar:0.96.1.1-hadoop2, com.yahoo.ycsb:core:jar:0.1.4: Failure to find org.apache.hbase:hbase:jar:0.96.1.1-hadoop2 in http://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]
however, when I looked into http://repo.maven.apache.org/maven2, there indeed exists this org.apache.hbase:hbase:jar:0.96.1.1-hadoop2.
My pom.xml is as follows:
<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.sunshineatnoon</groupId>
<artifactId>tt</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.96.1.1-hadoop2</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.yahoo.ycsb</groupId>
<artifactId>core</artifactId>
<version>0.1.4</version>
</dependency>
</dependencies>
</project>
How can I solve this problem?Any help will be appreciated, thanks in advance!
Maven pulls all the dependencies to your local machine. The default path would be ${USER_HOME}/.m2/repository. Here you should see whether the following dependencies really exist. Also are you using multiple repositories? Maven will place files under folders where it thinks there's a conflict "_maven.repositories" I normally delete these as it creates the above error as well.
org.apache.hbase:hbase:jar:0.96.1.1-hadoop2
${USER_HOME}/.m2/repository/org/apache/hbase/hbase/0.96.1.1-hadoop2
com.yahoo.ycsb:core:jar:0.1.4
${USER_HOME}/.m2/repository/com/yahoo/ycsb/core/0.1.4
The artifact hbase-0.96.1.1-hadoop2 does not exist. The hbase module was divided into multiple children as of version 0.96.
hbase => hbase-client, hbase-protocol, hbase-server, hbase-examples ..
You will need to reference hbase-(client|protocol|server|examples|etc)-0.96.1.1-hadoop2

Categories

Resources