Dependency javax.mail:mail:1.4 not found - maven

After I imported a maven project in IntelliJ IDEA, there are two errors in the pom.xml file:
"Failed to read artifact descriptor for javax.mail:mail:jar:1.4"
"Dependency javax.mail:mail:1.4 not found"
Does anyone know the reason behind these errors and how can I fix them?
Thank you and have a great day!

Due to license restrictions the older java mail classes are not in maven central or the java.net repository. usually companies host their own maven proxy and add these classes there.
Since around version 1.4.5 the dependencies are available in the java.net repository. Some later versions are also in maven central.
All other versions need to be downloaded from the oracle website and either added to a maven proxy or to your local maven repository - for example using the dependency plugin.

Change the pom.xml to include:
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies>
Or if you have a build.gradle file in the dependencies section add:
compile "com.sun.mail:jakarta.mail:1.6.3"

Related

How to add aem Uber jar dependency in maven build

I have used the maven archetype10 as shown below and created the project structure and everything was fine.
mvn archetype:generate -DarchetypeGroupId=com.adobe.granite.archetypes -DarchetypeArtifactId=aem-project-archetype -DarchetypeVersion=10 -DarchetypeRepository=https://repo.adobe.com/nexus/content/groups/public/
Now i wanted to add the aem uber-jar dependency and added the below dependency tags in the project pom.xml and in core module pom.xml respectively and also my repository tags are same as https://repo.adobe.com/
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.2.0</version>
<scope>provided</scope>
</dependency>
after adding the above dependency tag when i compile it is giving me the below error.
[ERROR] Failed to execute goal on project aemexample.core: Could not
resolve dependencies for project
com.krishh.example:aemexample.core:bundle:0.1: Could not transfer
artifact com.adobe.aem:uber-jar:jar:6.2.0 from/to
adobe-public-releases
(http://repo.adobe.com/nexus/content/groups/public): hostname in
certificate didn't match: <repo.adobe.com> != <devedge.day.com> OR
<devedge.day.com> -> [Help 1]
Is there anything am missing to add extra dependencies to compile and run this successfully.
You seem to be missing a classifier in your dependency. Try adding the one for AEM APIs, as suggested in the documentation. This should help Maven locate the necessary JAR in the repository:
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.2.0</version>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>
If that doesn't help, you should also look at the certificate warning. Check out the answers to this question for more information on the subject.
TL;DR - possible causes could be:
an old Maven version using an HTTP library that is not compliant with the certificate being used by the repository - try upgrading Maven
erroneous certificate used by the server
potential network configuration issues between you and the repository
an actual attempt at getting you to download a malicious file by a party pretending to be the Nexus

Nexus sonatype does not get zip dependency

I have setup Sonatype Nexus with Maven and seems to be working. However, my project depends (transitively) on docbook-xsl-1.75.2 but instead of a jar there you find a zip file. Is this the reason why Nexus is not getting it, that it is a zip file? I haven't found any Nexus configuration page in the web console offering a possible filter.
I browse my Nexus repository and see it gets the pom file but nothing else.
That module has no main artifact, it's packaging type is set to "pom".
What it does have is two additional artifacts which can be retrieved using Maven module classifiers as follows:
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl</artifactId>
<version>1.75.2</version>
<classifier>resources</classifier>
<type>zip</type>
</dependency>
And
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl</artifactId>
<version>1.75.2</version>
<classifier>ns-resources</classifier>
<type>zip</type>
</dependency>
Sorry, I have no idea how you'd retrieve these as transitive dependencies.
The next day, and after restarting Nexus it pulled the dependency. I don't still understand the magic behind Nexus not seeing the dependencies while they are clearly available but at least this question is resolved.

can't find valid maven repository for hibernate-search-4.2.0.Final.jar

I use maven.
I want to use the last version of hibernate-search : 4.2.0.Final
I was under 3.3.0.Final
I can't a valid maven repository for this version.
Which maven repository I have to use to get this version of hibernate search ?
Because if you go there :
https://repository.jboss.org/nexus/index.html#nexus-search;gav~org.hibernate~hibernate-search~~~~kw,versionexpand
You'll find the version I need, but when I download hibernate-search-4.2.0.Final.jar and I unarchive it, I see there is only META-INF folder but no class in the jar : the jar is invalid !
Thanks for your help !
The hibernate-search project changed their artifact structure to use hibernate-search-orm instead of hibernate-search. Hibernate-search is now just a jar that declares a dependency on hibernate-search-orm which maven will resolve transitively and include in your project.
See the upgrade notes here - https://community.jboss.org/wiki/HibernateSearchMigrationGuide
More specifically this note - https://community.jboss.org/wiki/HibernateSearchMigrationGuide#New_jars_Maven_modules_reorganization
If you look in the pom for hibernate search you will see the dependency - this should all be resolved from central without any additional repository.
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>${project.version}</version>
</dependency>
The best repository for JBoss artifacts is: https://repository.jboss.org/nexus/content/groups/public-jboss/
The available repositories are explained in their wiki: https://community.jboss.org/wiki/MavenRepository
The group public-jboss contains all releases and third-party artifacts required to by JBoss artifacts.
Isn't maven central good enough ?
http://search.maven.org/#search|ga|1|hibernate-search
Since this is a JBoss project, you can get newest builds from our Nexus repository. Here is how to configure it in your ~/.m2/settings.xml. Your pom.xml then should contain this dependecy.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>4.2.0.Final</version>
</dependency>

Can I download a jar file from maven central using maven?

I have a dependency problem with maven. I used to have saxon 8.7 that is located on maven central. Then, I had to upgrade to the latests saxon-b 9.1.0.0 which is only partially on maven central.
This is a snippet of my dependencies:
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon-dom</artifactId>
<version>9.1.0.8</version>
<scope>runtime</scope>
</dependency>
The first artifact 'saxon' is available on maven central, but the secon 'saxon-dom'. Here is the artifact I want.
Can I tell maven to download the "jar" file or am I obliged to download the jar and publish it locally on my maven repo to use it as a dependency?
Did not expect to resolve this so easily :
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
<classifier>dom</classifier>
</dependency>
Basically, I can get the dependencies that are "attached" to the 'saxon' artifact using the classifier tag. Did not know about this and I found out that the tag existed when I searched for 'saxon' on Sonatype repository (which is quite good). It gave me the dependency snippet above.
Reference : http://maven.apache.org/pom.html
If the required version is not in the repo, then yes you need to do one of the following alternatives
Search for a public repo containing the required version of jar. And add the repo to your pom.xml file. OR
Download it manually, and install it locally on your machine, to help the project build completely.

Where to find Maven CXF 2.2.6 jar?

I'm converting an ANT project that uses CXF into a Maven one. The problem is that this projects depends on CXF v2.2.6 and when I go to here or even here, there is no jar to download. I don't know what to do. I have the JAR but I want to use the Maven features like dependency management.
Thanks for your help
If using Ant, it likely used the cxf-bundle jar that pretty much contains all of CXF. You can just add:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.2.6</version>
</dependency>
to your new pom and it would get that jar along with all the dependencies that it would require.
It is available at Maven central. Use repo1.maven.org as your repository.
Either install it manually to your local repository or use a repository manager like Nexus.

Resources