How to fix 'Missing requirement' error in Maven on Windows - maven

I'm trying to build dbeaver and get the following error when running mvn package:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: org.jkiss.dbeaver.slf4j 1.0.0.qualifier
[ERROR] Missing requirement: org.jkiss.dbeaver.slf4j 1.0.0.qualifier requires 'bundle org.slf4j.api 0.0.0' but it could not be found
I'm running on Windows 10 and using apache-maven-3.6.1. The strange thing is that when I try the same steps on Linux it builds without problem.

Update
Possible cause is maven 3.6.1 https://www.eclipse.org/lists/tycho-user/msg08177.html
Original post
The problem here, I presume, is that https://dbeaver.io/eclipse-repo/ p2 site is missing slf4j bundle and Tycho (?) cannot resolve the requirement. I still do not know how to make standalone maven build work, but here is an ugly workaround on how to build Windows binary with Eclipse (and embedded maven).
You can use p2-maven-plugin to build that missing bundle yourself. Instead of setting up a brand new project, you can temporarily modify product\localRepository\pom.xml to have a single artifact like
...
<artifacts>
<artifact><id>org.slf4j:slf4j-api:1.7.26</id></artifact>
</artifacts>
...
Now build that (product\localRepository\) project and start jetty
mvn p2:site
start mvn jetty:start
Now you can add this interim update site (http://localhost:8080/site/) to your Eclipse installation (Help -> Install New Software) and install slf4j. You should already be able to run DBeaver from within Eclipse.
To build a binary, add this interim repo into main pom.xml file, e.g. right after local-contrib one.
<repository>
<id>more</id>
<url>http://localhost:8080/site/</url>
<layout>p2</layout>
</repository>
Then go to Run Configurations -> Maven Build -> dbeaver, enter package goal and tick Skip Tests, click Run and go have some coffee.
As you can see Eclipse uses some sort of embedded maven runtime, so I guess it resolves things differently.
Note that if you are updating your local git repo, you might need to update your Eclipse project big time. I was unable to do it with right clicking on the project -> Configure -> Configure and Detect Nested Projects :( But deleting Eclipse project and nested projects (without deleting underlying files) and re-importing Maven project did the trick for me.
There is also an open issue for this https://github.com/dbeaver/dbeaver/issues/6115 .

Related

Having Maven Plugins in IntelliJ IDEA without Maven Installation in Computer

I just started to use Maven and IntelliJ IDEA.
I imported a project into IntelliJ IDEA which requires Maven. I didn't install Maven to my computer but I have 2 plugins in IntelliJ IDEA named as "Maven" and "Maven Extension". And the code I have is running without any dependency problem.
In that case, do I still need to install Maven from the web or just the plugins in the IntellJ are enough for projects with Maven?
Can we say that for every project? If someone can explain the logic behind I would be very happy.
Thanks a lot!
Intellij comes with a bundled version of Maven (see File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven; the property 'Maven home directory' on that screen by defaults points to 'Bundled (Maven 3)').
You don't have to, but you can still install your own version of Maven, and point that property to it. It has the advantage of being able to run maven from the command-line, which is a better guarantee of build-stability (i.e. building the same project in different environments with the same result) than building directly inside of your IDE. And often is way more helpful in investigating build problems.

missing artifact org.elasticsearch:elasticsearch:jar:5.0.0-alpha1

Even though I can see the JAR file in Maven Dependencies and in .m2/repository directory, I still get this error.
missing artifact org.elasticsearch.elasticsearch
Do you have any idea where I am doing wrong?
I have met the same question.You can try the flowing steps:
1.make sure your network is well connected.
2.go to .m2/repository,delete all the files
3.restart your project and run maven install and maven update.
After running a build from the shell (mvn clean install, etc.) and making sure the problem is caused by Eclipse - there are a few options:
First, try Project --> Clean...
Right click on the project in the Project Explorer pane and then choose Maven --> Update Project...
Disable and then re-enable Dependency Management - right click Maven --> Disable Dependency Management and then Maven->Enable Dependency Management
Close the project and then reopen it.

Building an Eclipse plugin using Maven

I am trying to configure Maven to build an Eclipse application (Eclipse plugin packaged with all of the Eclipse EXEs etc).
I have already Mavenised dozens of dependencies of the project and deployed them to our internal Nexus (OSS) server. I have also installed the Nexus P2 Repository Plugin and the P2 Bridge Plugin (2.6.3-01) and the Nexus Unzip Plugin (0.12.0). I can browse to the .meta/p2 folder of our group repository, but it is currently empty.
This should be a lot simpler than it currently appears to be. I'm targeting Eclipse 3.4.2 (Ganymede) on Windows. If it makes any difference, we actually deploy our application packaged as a stripped-down/customised Eclipse installation.
eclipse-repository
When I run maven against a pom with <packaging>eclipse-repository</packaging> I get the following error:
[ERROR] Missing requirement: MyApp 0.0.0 requires
'org.eclipse.equinox.executable.feature.group 0.0.0'
but it could not be found
...where do I get that from, and how do I add it to Nexus?
When I run maven against a pom with <packaging>eclipse-plugin</packaging> I get the following error:
[ERROR] Missing requirement: MyApp 0.0.0 requires
'bundle org.eclipse.ui 0.0.0'
but it could not be found
...but I found the following directories on my local file system (suspect itp-04-rcp generated the first one):
D:\maven\repository\p2\osgi\bundle\org.eclipse.ui\3.6.2.M20110203-1100
D:\maven\repository\p2\osgi\bundle\org.eclipse.ui\3.7.0.v20110928-1505
Tycho POM-First artifacts
I've also tried the pom-first-dependencies and manifest-first-dependency combo: http://wiki.eclipse.org/Tycho/How_Tos/Dependency_on_pom-first_artifacts
I don't understand how this works - I can build itp02 from Git. I can see that it builds two bundles:
+---------------------+---------------------+--------------------------------------+
| artifactId | Bundle-Name | Bundle-SymbolicName |
+---------------------+---------------------+--------------------------------------+
| pomfirst-bundle | pomfirst-bundle | tycho.demo.itp02.pomfirst-bundle |
| pomfirst-thirdparty | pomfirst-thirdparty | tycho.demo.itp02.pomfirst-thirdparty |
+---------------------+---------------------+--------------------------------------+
...but how does build02 pick these up? The only bit that seems relevant is:
Import-Package: tycho.demo.itp02.pomfirst
...that doesn't have anything to do with either of the Bundle-Names.
Felix Maven Bundle Plugin
I tried the Felix maven-bundle-plugin. I include all of my regular maven dependencies in a pom with <packaging>bundle</packaging>.
mvn deploy creates something at /nexus/content/repositories/snapshots/.meta/p2/plugins. I can download the jar via a browser, but all of the dependency jars are named "artifact-vresion" rather than "artifact_version" - is that right?
mvn bundle:bundleall creates an OSGI bundle for each of the transitive dependencies, but I'm not sure what to do with them from here.
mvn bundle:deploy refuses to do anything unless I specify -DremoteOBR and probably a few other parameters which I don't really understand.
The 'org.eclipse.equinox.executable.feature.groug' seems to be necessary if you build an eclipse product which includes the native launchers ("include laucher" property set to true in product configuration). Try to add the feature to your platform definition (e.g. copy from eclipse p2 repo or your running eclipse IDE).
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=407272
Regards,
Paolo
To solve the Problem concerning the missing dependencies:
[ERROR] Missing requirement: MyApp 0.0.0 requires
'bundle org.eclipse.ui 0.0.0'
but it could not be found
seems that your Feature/Plugin MyApp requires to download the org.eclipse.ui Plug-in before it can be installed.
You should check your settings from your configuration-pom like this:
<properties>
<tycho.version>0.25.0</tycho.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<repository.url>http://download.eclipse.org/releases/neon</repository.url>
</properties>
<repositories>
<repository>
<id>NeonRepository</id>
<url>${repository.url}</url>
<layout>p2</layout>
</repository>
if you have set up your self-hosted p2 repository, make sure that the page is correctly build.
You can check this if you select(in eclipse) Help -> Install New Software.
Eclipse should show the provided parts.
If nothing is shown, even if you have deselected every checkbox, you should check your p2-repository.
It should contain the "features" and "plugins" container as well as the artifacts.jar and content.jar.
If you have only the two folders, you should run
eclipse -application org.eclipse.equinox.p2.publisher.UpdateSitePublisher
-metadataRepository file:/<some location>/repository
-artifactRepository file:/<some location>/repository
-source /<location with a site.xml>
-configs gtk.linux.x86
-compress
-publishArtifacts
in a CLI/Shell.
For more Information check the eclipse documentation.
Can you make maven/tycho instantiate a target platform against which you can build your source plugins? http://www.vogella.com/articles/EclipseTycho/article.html

add external plugin to intellij maven project

I'd like to add a plugin to my maven project in Intellij, but I'm not sure where I should download from and where I should put the jar files. For example, I want to use
<plugin>
<groupId>funambol</groupId>
<artifactId>rhinounit-maven-plugin</artifactId>
...
or
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
...
in my pom.xml, but the text between the tags is red.
The rhineunit-maven-plugin does not seem to be found in any central repository. You will have to download the plugin sources yourself from here and then build them by running mvn install where the pom file is located. This will install the plugin in your local repository and the version will be 1.0.
Regarding the jasmin-maven-plugin it can be found here and as you can see the latest stable version is 1.1.0. That means that you will only have to add the version 1.1.0 to your plugin statement and the plugin will be downloaded when you run mvn install (actually in an earlier maven phase but don't bother about that).
Here seems to be a good article on how to use rhinounit-maven-plugin so you should go ahead and study it.
Regarding the tags being red that is caused by IntelliJ not being able to find the jar files in the local repo, especially if you don't set the version for the plugins. Normally IntelliJ shows a little green growl-like thing in the upper right corner that states "Maven projects need to be imported" when you change your pom files from within IntelliJ. If you select "Import Changes" it will try to download your dependencies. Another way to solve it is to run mvn install on your own project from the command line.

Maven can't discover workspace projects, junit, other libraries

so I have started using maven (with eclipse, and a local implementation of Sonatype) not that long ago, after getting through the initial pain I though everything was working.... apparently not !
I have my main project POM and all my child POM (I am using a 'flat' hierarchy, so all the sub projects are in the same folder as the parent POM). This seems to be working OK.
The sub project where all started and 'released' and tested before I started using Maven. I went to maven to solve my 'dependencies' problems... or rather make them more complicated in this instance.
Most of the 'Maven' stuff seems to work fine, but I can't resolve the dependencies of my 'sub projects' that have been released into my local ms/repository
Each day I start up eclipse and have the same problems, I have 'unable to resolve imports' on all my personal libraries, and all those that I use for them (such as Log4j, DDlUtils etc).
I thought the whole point of maven was that I would be able to put in an import declaration for a library, add the 'groupID' and other stuff to the child POM (or parent POM). And then have all the jars downloaded automagically when I run
mvn install
against the parent.
However each day I find I have to re-insert the build path to the libraries (internal and external) via the eclipse workspace and point them to the location of the libraries that I have downloaded as maven can't seem to find them anywhere.
Specifically with running Junit test, I can run them from the workspace (using run as junit) and they all pass fine. But if I try to run them with
mvn test
I get an message saying
java.lang;NoClassDefFoundError: org/junit/Assert
(and this is the same from within eclipse running the mvn test or from CLI)
with an error message in the output of
failed to execute goal org.apache.maven.plugins:maven.surfire-plugin:2.10:test
the POM and jar are in my M2_REPO, and I can find it when I search in sonatype, why can't maven find something that is part of its own system, exists in its repo.
but this obviously works just fine when I run via eclipse and point it to an independently downloaded junit library.
I don't know what extra info you may require, and I'm obviously missing something in either the m2e plugin, my maven install or in sonatype.
please help I'm begining to loose my hair!
and may soon be forced to return to an ant/ivy solution (but don't want to have to learn 'yet another tool' (in this case ivy).
Thanks in advance
David.
ps. i'm on a windows XP platform
edit...
can I get maven to build and release the jar and pom even though it thinks it is failing the tests (which is itn't as I'm doing them manually, and they pass just fine).
If I look in the 'effective POM' tab of my parent POM, the plugin stated above is not in there. I guess this means it is a maven config setting, but where do I add it, and why isn't it automatic when I run my first set of maven tests?
edit 2....
I just found this on the apache plugin comments page (http://maven.apache.org/plugins/maven-surefire-plugin/plugin-info.html), so I ran the code on the CLI, mvn surefire:help -Ddetail=true -Dgoal=test lots of stuff was downloaded, and now the tests run, but they fail within maven ? (remember they pass when run from eclipse using 'run as junit test)... so this is nearly a solution...
It sounds like you need make eclipse aware that the projects in question are Maven projects. You may have POMs set up for your projects, but for the m2e plugin to work you need to have either created the project as a Maven project ('New' -> 'Project...' -> 'Maven' -> 'Maven Project...'), or converted it into a Maven project by right clicking it then selecting 'Configure' -> 'Convert to Maven Project'. You will know that a project has been recognised as a Maven project because there will be a little blue 'M' in the top left of its icon, as shown in the screenshot below:
The main thing to note in the above picture is the 'Maven Dependencies' library. This is set up automatically by the m2e plugin. Whenever you add a dependency to a POM then the project's build path will be configured automatically, although sometimes you may need to force it to do so by right clicking the project and selecting 'Maven' -> 'Update Maven Configuration'. The important thing is that if everything is working then you should never have to update the build path yourself. Moveover, if you do update it yourself then any changes you make will likely get overwritten the next time you run the 'Update Maven Configuration' command.
Also worth noting from the picture is that the two dependencies 'mavenProjectTest' and 'primes' have folder icons next to them. This means that they have been picked up as workspace projects. For this to work the project must have 'workspace resolution' enabled, and the projects to be picked up need to be configured as m2e Maven projects as well.
You mention downloading external libraries. You shouldn't need to download any libraries yourself - by adding the right dependency declaration for an external library then Maven will download it from your configured remote repository (the first time anyway - afterwards it will then be able to get it from your local repository). By default, this is the Maven Central repository. To add an external library to your project just follow that link, enter the library in the search box, click on the version link for the version you require, then you will be taken to a page where there will be the dependency XML declaration that you can just copy and paste into your POM.
One more thing that may help is that you should make sure that your source folders follow the Maven default directory structure. That is, your test packages should be contained in a source folder called 'src/test/java', and the main project packages should go in 'src/main/java'. Otherwise Maven will not know where to find your source code. It is possible to configure a POM to tell Maven to expect your source code to be in different source folders, but it is highly recommended that you follow the standard Maven directory structure.
Since you have child modules, my suggestion would be to simplify things by creating a new Maven project from scratch that you can have a play around with. Once you are comfortable with that then try getting m2e to work for your multi-module project.
I remember your pain when first getting to grips with Maven, but it's great once you understand what it's doing and everything is working. I highly recommend reading through the free online book Maven: The Complete Reference - it helped me out a lot when I was getting started with Maven.
I have experienced the same messages and have found a working solution, thanks to one of my organization's Maven experts.
Here was my pom.xml that reproduces your error:
<dependencies>
<dependency>
<groupId>org.junit4</groupId>
<artifactId>org.junit4</artifactId>
<version>4.3.1</version>
</dependency>
</dependencies>
With it, I would get package org.junit does not exist messages and NoClassDefFoundError: org/junit/Assert. Similar to your experience, it worked great from Eclipse, green bars and all.
Here is the pom.xml that works:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
I copied this from the example at the top of this Using JUnit page.

Resources