Missing Paho dependency in IBM iot-java github Maven project - maven

I've been using release version of this github IoT java client: https://github.com/ibm-messaging/iot-java
I'd like to build the source but when I import it into my Eclipse I get a missing dependency error for:
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.0.3-SNAPSHOT</version>
</dependency>
I have tried the snapshot modification in settings.xml:
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
But that won't solve the problem. Also, using this settings using Eclipse Maven settings.xml editor as linked from the dependency error message won't make the dependency be found. (BTW, I can't use Paho 1.0.2)
Also, I have seen that in bottom of pom.xml of the project it references RELEASE, not SNAPSHOT, and tried also changing it.

May this is because you are using
https://repo.eclipse.org/content/repositories/paho-releases/
not
https://repo.eclipse.org/content/repositories/paho-snapshots
so Please use this repository instead of yours
<repositories>
<!-- Dependency of the Paho mqqt snapshot is here -->
<repository>
<id>Eclipse Paho Snapshots Repo</id>
<url>https://repo.eclipse.org/content/repositories/paho-snapshots/</url>
</repository>
</repositories>

Related

Mule XML SDK and its Error in Maven Settings.xml

I'm doing the XML SDK in Mule 4.2.2 with Maven 3.6.3 [though Mule inbuild using (3.6.9)] and AnypointStudio 7.4.2 . Please clarify my doubts
1) Is that XML SDK connectorPlugin creation is supported only in Mule-EE version or public?
2) I'm using the below Maven command and settings.xml , which is throwing 401 Unauthorized (Warning) and error as 'Archetype' issue.
mvn archetype:generate -DarchetypeGroupId=org.mule.extensions -DarchetypeArtifactId=xml-mule-extensions-archetype -DarchetypeVersion=1.0.1 -DgroupId=org.mule.extension -DartifactId=error-handler-framework -DmuleConnectorName=ErrorHandler
Error I'm getting as below. But i can able to assess this URL https://repository.mulesoft.org/releases/ without Login. Not sure why its throwing 401
[WARNING] Failure to transfer org.mule.tools/maven-metadata.xml from
https://repository.mulesoft.org/releases/ was cached in the local repository, resolution will not be reattempted until the update interval of mulesoft-releases has elapsed or updates are forced. Original error: Could not transfer metadata org.mule.tools/maven-metadata.xml from/to mulesoft-releases (https://repository.mulesoft.org/releases/): authenticationrequired (401)
[ERROR] No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.mule.tools, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\jxsubr\.m2\repository), mulesoft-releases (https://repository.mulesoft.org/releases/), central (https://repo.maven.apache.org/maven2)]
Below is the settings.xml
<?xml version="1.0"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:\Users\star\.m2\repository</localRepository>
<profiles>
<profile>
<id>Mule</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
<profile>
<id>standard-repositories</id>
<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-ee-release</id>
<url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
..............
</profile>
I also tried giving Public Repo, instead Mule-ee in the above settings. Still the same error. Please direct me a standard settings.xml for Mule if any.
3) Though Mule inbuild for this runtime 4.2.2 using Maven 3.6.9. Can we use lower version 3.6.3 (I believe this is the stable version now)?
Reference: https://docs.mulesoft.com/mule-sdk/1.1/xml-sdk
Thanks in advance for your help. Please let me know if needed more information.
I think you need to declare the repos as pluginRepositories too for the archetype to work. HTH
This dependency is available only for MuleSoft Enterprise Maven customer repository only.
IN XML SDK other than transform message this ee xsd may not require., I have created a log forwarder without using this dependency.
Log Forwarding Connector Mule XML-SDK - DZone
https://dzone.com/articles/mule-log-forwarder-connector-xml-sdk
https://docs.mulesoft.com/mule-runtime/3.6/configuring-maven-to-work-with-mule-esb#%C2%A0referencing-mulesoft-s-enterprise-repositories.

Does the repos in maven not have jar files?

I have tried looking through various repos around, however i could not find one that contains the jar file for this dependency:
<dependency>
<groupId>com.oracle.java</groupId>
<artifactId>jre</artifactId>
<version>1.8.0_131</version>
</dependency>
Error i got: Could not resolve dependencies for project com.blackducksoftware.test:example-maven-travis:jar:0.1.0-SNAPSHOT: Could not find artifact com.oracle.java:jre:jar:1.8.0_131 in jboss (http://repository.jboss.org/nexus/content/groups/public-jboss)
Is there a reason why only pom files are in the repo and not the jar file?
How do I get the jar file?
From mvnrepository.com:
Note: this artifact it located at Alfresco repository (https://artifacts.alfresco.com/nexus/content/repositories/public/)
So you need to add a profile entry to your settings.xml file.
Example:
<profile>
<id>alfresco-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>alfresco-repo</id>
<name>Alfresco Repository</name>
<url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>

Maven uses wrong repository to lookup dependencies

In my settings.xml I declared a custom repository in a profile like this:
<servers>
<server>
<id>server.id</id>
<username><uname></username>
<password><pw></password>
</server>
</servers>
<profiles>
<profile>
<id>dev.id</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>repo.id</id>
<url>valid working url</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
what works great for all dependencies located there, but build fails whenever I declare dependencies which are located in the central repository. For instance:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
results in:
[ERROR] Failed to execute goal on project <name>: Could not resolve dependencies for project…
…Failed to read artifact descriptor for junit:junit-dep:jar:4.9.1-SNAPSHOT: Could not transfer artifact junit:junit-dep:pom:4.9.1-SNAPSHOT from/to <server.id>…
How can I make maven load dependencies correctly?
You are trying to use a -SNAPSHOT dependency which is not available in Maven Central.
junit:junit-dep:jar:4.9.1-SNAPSHOT: Could not transfer artifact junit:junit-dep:pom:4.9.1-SNAPSHOT fr
In Maven central there are only releases available.
Furthermore the above dependency is not coming into your build by the junit:junit:4.11:jar dependency it must be comming from other sources.

Maven: Why is the -SNAPSHOT suffix missing from artifact file name?

My maven artifact is deployed to a Nexus snapshot repository. There, it is stored in the correct directory, but its filenames have the following pattern:
mylibrary-1.0-20130213.125827-2.jar
However, Maven fails to download that snapshot. According to the error log, Maven seems to expect the following file name:
mylibrary-1.0-SNAPSHOT.jar
These are the repository settings in my pom:
<repositories>
<repository>
<id>mycompany-all</id>
<url>https://servername/nexus/content/groups/mycompany/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>mycompany-releases</id>
<url>https://servername/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>mycompany-snapshots</id>
<url>https://servername/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Note: the nexus group includes both the releases and snapshots repo.
I did not configure these repos in settings.xml - is that the problem? Or what else am I doing wrong?
The pattern you posted (mylibrary-1.0-20130213.125827-2.jar) is a unique snapshot version. Maven 3 forces you to use this type of artifact naming, but in Maven 2 it can be prevented with a statement such as:
<distributionManagement>
...
<snapshotRepository>
...
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
...
</distributionManagement>
To use a specific snapshot in your project, declare it as:
<dependency>
<groupId>com.foo</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0-20130213.125827-2</version>
</dependency>
To use the latest known snapshot, declare it "old-style":
<dependency>
<groupId>com.foo</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
You may find the answer to this similar question helpful as well.
I made it work by adding the repositories to the settings.xml like this:
<repositories>
<repository>
<id>mycompany-releases</id>
<url>https://servername/nexus/content/repositories/releases/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>mycompany-snapshots</id>
<url>https://servername/nexus/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
Then, the SNAPSHOT jar files were downloaded just fine. I suspect that when Maven knows it deals with a snapshot repo, it tries both with and without uniqueVersion (see Duncan Jones' answer).
Note that in our case these blocks had to be duplicated as pluginRepositories because we have custom Maven plugins.

Restlet Maven Dependencies

Does anyone know what the RESTLET maven dependencies are?
None of the entries on the site work. I had to end up installing jars to make it work.
add this repo:
<repositories>
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>https://maven.restlet.talend.com/</url>
</repository>
</repositories>
Then include dependencies with your version:
<dependency>
<groupId>org.restlet.jee</groupId>
<artifactId>org.restlet</artifactId>
<version>${restlet.version}</version>
</dependency>
Use:
<properties>
<restlet.version>2.0.14</restlet.version>
</properties>
to define restlet version or just put whichever version you like. Hope it helps!
Sometimes, the maven dependencies are not downloaded automatically. You have to force it using mvn compile.
Here is a reference to sample restful service that uses following dependencies :
http://topjavatutorial.com/frameworks/spring/spring-rest/standalone-restful-service-using-restlet-framework/
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet</artifactId>
<version>2.1-RC2</version>
</dependency>
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet.ext.simple</artifactId>
<version>2.1-RC2</version>
</dependency>
Use the given mirrors in this
These mirrors are up to date so no need to worry about the versions and so on..
Edit settings.xml in maven installation location to add mirrors.
<settings>
<mirrors>
<mirror>
<id>mygrid-restlet</id>
<url>http://www.mygrid.org.uk/maven/restlet/maven.restlet.org</url>
<mirrorOf>maven-restlet</mirrorOf>
</mirror>
</mirrors>
</settings>
assuming that the POMs using the original repository uses:
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
<url>http://maven.restlet.org</url>
</repository>
<!-- https://mvnrepository.com/artifact/com.softlayer.api/softlayer-api-client -->
<dependency>
<groupId>com.softlayer.api</groupId>
<artifactId>softlayer-api-client</artifactId>
<version>0.1.0</version>
</dependency>

Resources