How to import Wildfly dependencies in Maven - java

I'm trying to compile a project (webapp) with Maven and that project "uses" .jar's that are in the Wildfly installation directory (.../Wildfly.../modules/...).
Is there an easy way to import all of these modules through the POM?
I've tried using:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-client-all</artifactId>
<version>10.1.0.Final</version>
</dependency>
And it didn't work.
After that I tried using:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
</dependency>
To no effect either, giving me the following error:
Could not resolve dependencies for project
someproject:someproject:war:0.0.1-SNAPSHOT: The following artifacts
could not be resolved: org.apache.activemq:artemis-
commons:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-core-
client:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-hqclient-
protocol:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-jms-
client:jar:1.1.0.wildfly-017, org.slf4j:jcl-over-slf4j:jar:1.7.7.jbossorg-1:
Could not find artifact org.apache.activemq:artemis-
commons:jar:1.1.0.wildfly-017 in central
(https://repo.maven.apache.org/maven2)
Any tips would be appreciated.

The wildlfy feature pack [1][2], contains pretty much everything that Wildlfy uses for distribution. However, this has way much more dependencies that you actually need, in most cases. So, just be aware of it.
You can also check out Wildlfy BOMs [3][4], which might be useful for you, as well.
Happy Coding!
[1] https://mvnrepository.com/artifact/org.wildfly/wildfly-feature-pack/11.0.0.Final
[2] https://github.com/wildfly/wildfly/tree/master/feature-pack/src/main/resources/modules/system/layers/base
[3] https://mvnrepository.com/artifact/org.wildfly.bom/wildfly-javaee7
[4] https://github.com/wildfly/boms

Related

what is causing my Wildfly BOM compile error

I am upgrading to wildfly 21.0.2.Final for an application and wanted to pull the BOM for it rather than linking the dependencies that I needed 1 at a time.
mvnrepository says it should look like this:
<!-- https://mvnrepository.com/artifact/org.wildfly/wildfly-feature-pack -->
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-feature-pack</artifactId>
<version>21.0.2.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
However, when I attempt to package that using mvn clean package i get these errors:
Could not resolve dependencies for project org.example:test:war:1.0-SNAPSHOT: The following artifacts could not be resolved: org.apache.taglibs:taglibs-standard-spec:jar:1.2.6-RC1, org.apache.taglibs:taglibs-standard-impl:jar:1.2.6-RC1, org.apache.taglibs:taglibs-standard-compat:jar:1.2.6-RC1: Could not find artifact org.apache.taglibs:taglibs-standard-spec:jar:1.2.6-RC1 in central (https://companyNameglobal.jfrog.io/companyNameglobal/maven-all)
It appears as if the artifacts don't exist, but then why would they be required in the wildfly BOM?
Any help would be great.

Maven Site Plugin with Java9

I have a problem running my CI builds on Travis with Java9 (Oracle JDK 9).
I fails on maven-site-plugin - after removing it everything works smothly.
I tried removing everything else to check for possible dependencies collisions, left out with just this one plugin build still fails. It is just a pom container, still failing with just a simple site plugin (updated to latest version that claimed to be java9 ready).
Here are all of the resources:
failing Travis build
Travis configuration
project POM file
Looking for similar problems on the web I found that usually it's plugin compatibility (all of the plugins ware updated) or different dependencies versions, but I removed all of them and it still fails.
The builds run locally on OpenJDK 9 perfectly fine.
-edit-
After applying hint from #nullpointer :
updated POM
CI error
You should probably wait and update to using version 3.7 of site plugin as mentioned here.
Seems like you are encountering something similar to #MSITE-796
Quoting further from the same link:-
The release will need a little bit more time due to pending
SNAPSHOT-dependencies which need to be released first. So either have
a little bit more patience or add doxia-sitetools 1.7.5 as a dependency
to the maven-site-plugin in your own project.
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sitetools</artifactId>
<version>1.7.5</version>
</dependency>
-edit-
As doxia-sitetools is just a pom container project one needs to update all of it's modules directly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-decoration-model</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-skin-model</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-integration-tools</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-renderer</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-doc-renderer</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
</plugin>

How to import Apache Commons Net using Maven

When I run import org.apache.commons.net.ftp.{FTP, FTPClient} I receive the error: object apache is not a member of package org. I am using Maven, and I tried adding
<dependency>
<groupId>org.apache.commons.net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
and/or
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
as well as various other similar packages to my pom.xml file, but nothing is working. This seems to be a very simple error yet I cannot figure out what I'm missing. This is my first time using Maven, am I misunderstanding how dependencies work? I am using Scala 2.11.6 if that matters.
Update: I was finally able to run the file I wanted through this command:
mvn exec:java -Dexec.mainClass="com.havas.plugins.test"

What is the difference between the GeoIP2 MaxMind pom and my local one?

I'm following this guide:
https://github.com/maxmind/GeoIP2-java
It says:
We recommend installing this package with Maven. To do this, add the dependency to your pom.xml:
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.2.0</version>
</dependency>
There is also pom.xml file in the Git repository of GeoIP2 which is much longer - what is the difference between them?
Cited from the official homepage:
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
Think of the pom.xml as the heart of Maven. In the file you can specify dependencies (most typically jar files), and other information, such as how the project should be built. Without digging to deep into this, one of Maven's strengths is that it manages the dependencies of projects.
To answer your concrete question, GeoIP2 manages its dependencies using Maven. This section of its pom.xml defines them:
<dependencies>
<dependency>
<groupId>com.maxmind.db</groupId>
<artifactId>maxmind-db</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.20.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency>
</dependencies>
By using Maven in your own project, you will only need to add the one dependency to GeoIP2. Maven will then search for the dependency in a repository, typically the Maven Central Repository if Maven isn't configured to use another. It will also automatically download all other needed dependencies (transitive dependencies), in this case it would be the dependencies listed above, plus any other dependencies those in turn depend on, and so on.
So, a short recap: Without a dependency management tool like Maven, you would need to manually make sure you have all the correct dependencies on the classpath. Maven fixes this for you.

Retrieve Jetty from Maven Central Repository as project dependency in IntelliJ IDEA Project

I want to use Jetty as an embedded library in a Java project I'm working on in IntelliJ IDEA. However, there are many different packages for Jetty available from the Maven Central Repository. The JAR available for direct download from here is named as jetty-distribution-9.0.3.v20130506.tar.gz, so I assumed the best complete package available from the Maven Central Repo was org.eclipse.jetty:jetty-distribution:9.0.3.v20130506. But IntelliJ returns this error when attempting to use that coordinate to retrieve the library:
No files were downloaded for org.eclipse.jetty:jetty-distribution:9.0.3.v20130506
Why can't that package be found? And if it's not usable, which packages should I download?
Edit: I now realise that the coordinate I should have been using is org.eclipse.jetty.aggregate:jetty-all:9.0.3.v20130506. I can locate this at search.maven.org, but IntelliJ cannot find anything newer than version 7. Can anyone reproduce or explain this issue? Moved to new question.
Check the dependency type.
There are so called pom type of dependencies, which act as a list of other dependencies. To be able to fetch them, you have to mark them as pom dependencies in your pom.xml
If you only need the server component, try searching for this string
'org.eclipse.jetty:jetty-server:9.0.3.v20130506'
Maven dependencies have a type, which by default is jar. The jetty distribution package is not a jar, and as you can see in the central repository, you can download either a .zip or a .tar.gz, so you'll have to declare the dependency as:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-distribution</artifactId>
<version>${jetty.version}</version>
<type>zip</type>
</dependency>
If you build now, it will download the zip and the build will probably succeed. But, a zip is different from a jar, so depending on what you're actually doing in that build, you will have to do more things to actually make use of that zip.
You probably don't want to use the distribution package unless you're also building a standalone distribution (.zip) for your project as well, in which case you should probably use the maven-assembly-plugin which can unzip the jetty distribution and rezip your whole project.
What you should do is decide what exactly you're going to need and build a custom jetty. Here's the starting point, enough to be able to deploy a simple servlet-based application:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-xml</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<version>${jetty.version}</version>
</dependency>
You're probably going to need this one as well, since this is how you can start Jetty:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-start</artifactId>
<version>${jetty.version}</version>
</dependency>
Look at the list of modules to see what else you might need, for example jetty-ajp, jetty-websocket, or jetty-jsp.

Categories