what is causing my Wildfly BOM compile error - java

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.

Related

Maven compiling with dependencies not in POM

I'm trying to build a Maven project from work, which has servlet-api 3.1.0 as a provided dependency:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
But then fails to compile because it cannot find getRequestURL() from javax.servlet.http.HttpServletRequest.
Later, I found out it's using an older version of servlet-api which I never included in my POM:
Downloading from central: https://repo.maven.apache.org/maven2/javax/servlet/servlet-api/2.2/servlet-api-2.2.jar
Downloaded from central: https://repo.maven.apache.org/maven2/javax/servlet/servlet-api/2.2/servlet-api-2.2.jar (41 kB at 63 kB/s)
Maybe that version of servlet-api is comming from a dependency, but I don't know from which one, they are a lot.
How can I override that version with the one I added in the project's POM?
You can try couple of things.
Try mvn dependency:tree to see if it is getting downloaded as part of another dependency.
If you don’t see the dependency getting downloaded as part of another dependency, clean you local repository( it might be inside .m2 directory) and do a clean install of your application.
you can also share your pom.xml so that others can take a look and help.

Dependency of Type "POM"

I am trying to get an ESB system running using ServiceMix and ActiveMQ. But even before I get that far, I had a question about dependency types of POM. I got the maven dependency as:
<!-- https://mvnrepository.com/artifact/org.apache.servicemix/servicemix -->
<dependency>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix</artifactId>
<version>7.0.1</version>
<type>pom</type>
</dependency>
Now when I run "clean install" on the the project in which I included this dependency, I don't see any of the activeMQ jars being copied in the classpath or available for compilation (I have copy-dependency written, so I can see what jar files are included). In this case, do I still have to explicitly mention the activeMQ dependency in my pom file? Like:
<!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-core -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
</dependency>
Any guidance would be appreciated. This ServiceMix is frustrating with the lack of documentation.
If you put a dependency of type pom into your <dependencies>, Maven will use the content of the POM as transitive dependencies. So everything in that POM will become a part of the classpath unless it has something like test scope or its version is overridden by some other part of the POM.
Putting a POM into the <dependencyManagement> is a different thing. Note that scope import is only for <dependencyManagement>.

How to import Wildfly dependencies in Maven

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

maven dependecies can't be imported

I have set-up a mave project in Eclipse, I added the project dependencies to the pom.xml which was created by eclipse automatically.
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId> org.springframework.core </artifactId>
<version>3.0.6.RELEASE </version>
</dependency>
</dependencies>
Now when I import the Jdbc template in one of the classes, I get the import can't be resolved error
import org.springframework.jdbc.core.JdbcTemplate;
Are dependencies added during compilation time, or execution time only? if they are only available at execution time, then how can I compile the code?
One way to verify if maven dependencies are added to your project or not in eclipse is under the project ->libraries->Maven Dependencies, all the dependency you have added in your pom.xml should be present
In your case spring-jdbc{version}.jar should there else try to update the project, while updating the project by default all the dependencies would be downloaded to your home directory/.m2/repository. If you find your dependencies are not present check your proxy settings. http://maven.apache.org/guides/mini/guide-proxies.html
The simple problem you have is that the class org.springframework.jdbc.core.JdbcTemplate is contained in the following artifact:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
but not in the spring-core nor as transitive dep. Apart from that you should first check to build the project on command line with Maven and afterward import it into Eclipse.

How to add maven dependencies for mahout and hadoop?

I am doing a project that has dependencies on some classes from the mahout and hadoop core jars. I was using javac with the classpath option to include them before, but someone suggested to me that I should use maven to build my project instead. However, I am not sure how to add the dependencies to these jar files which are located in my /usr/local directory.
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.205.0</version> <!-- or whatever version -->
</dependency>
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.5</version>
</dependency>
Add this to your pom:
<dependencies>
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>hadoop</artifactId>
<version>some.version</version>
</dependency>
</dependencies>
If you have a copy of the jar to be used for say the hadoop example above, execute this command:
mvn install:install-file -Dfile=/some/path/my-hadoop.jar -DgroupId=some.group -DartifactId=hadoop -Dversion=some.version -Dpackaging=jar
Have a look at the maven documentation, especially the part on dependency management. If you want to use Maven you should get to know the basics (one of which is dependency management).
Basially you define your project's dependencies in the <dependencies> section of your pom. Look up maven central (the most common online repository) for the dependencies you want or search for other online repositories that might contain them.
If you can't find them, add the dependencies you want anyways (think of a sensible group id, artifact id and version) and try to compile. Maven will complain about the dependencies missing and provide a basic command to put those dependencies into the local repository. Copy those commands and fill in the appropriate path to the jar file and maven will deploy that dependency in your local repository.
Note that you should first look for the dependencies in an online repository since otherwise you'd have to manually deploy each new version in your local repo.

Categories