How to access Maven Central via HTTPS through a Proxy

How to access Maven Central via HTTPS through a Proxy

book

Article ID: KB0073628

calendar_today

Updated On:

Products Versions
TIBCO Streaming 10.x

Description

Attempting to typecheck or build a TIBCO Streaming EventFlow project on a system behind an internet proxy using the default configuration we get this error:
[ERROR] No plugin found for prefix 'wagon' in the current project and in the plugin groups
 [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local
 (C:\Users\USER\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
Maven exited with status code 1

What additional settings are required to use Maven Central through the proxy server?

Issue/Introduction

Supply proxy settings using settings.xml and install Maven Central certificate in the Java cacerts truststore.

Resolution

TIBCO® Streaming relies on Apache Maven for all Java build operations. Using Maven requires access to Maven Central on the internet to set up the build environment. After the build environment is fully set up, then internet access may be limited or removed.

One indication your system is accessing the internet through a proxy server is if you browse to Maven Central (https://repo.maven.apache.org/) and your browser prompts for your username and password before allowing access.

The same credentials that allow your browser to access Maven Central are the credentials which need to be placed into your local Maven Repository "settings.xml" file. This is an optional file used to customize the repositories available to Maven.

Configure Maven for Internet Access Through A Proxy Server

Copy "settings.xml" from:
* Windows: C:\tibco\sb-cep\10.6\sdk\mvn\conf\settings.xml 
* Linux: /opt/tibco/sb-cep/10.6/sdk/mvn/conf/settings.xml
to:
* Windows: C:\Users\{user}\.m2\settings.xml 
* Linux: /home/{user}/.m2/settings.xml 

This default settings.xml file has no enabled configuration, but includes examples of all potential settings with a description of each setting's use.

Edit the <proxy> section to enable an "https" setting for your proxy server credentials:
<settings>
  ...
  <proxies>
   <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>https</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>
  ...
</settings>
To enable a section, remove the XML comment flags <!-- --> from around the section. Every configuration section between these flags is ignored. Comments cannot be nested.

The <host> and <port> values are those reported by your browser when it asks for your credentials. If your browser does not tell you the host and port values, get these from your local IT department.

The <username> and <password> values are the same credential values you use to satisfy the browser prompt. If you are in a managed domain, use for the username: domain\username. If the password has special characters, these may be escaped by proceeding with a back-slash (\). For example, if the password is "Pass\w0rd" you may use "Pass\\w0rd" to preserve a single back-slash.

Include the <nonProxyHosts> setting for those sites you access directly without using the proxy server. Usually you need proxy access for all sites, so this line may be removed.

Verify that Maven can contact Maven Central on your system using command:
  epdev install maven 
which uses the Streaming 'epdev' command to install the TIBCO Streaming libraries into your user account's local repository. The 'epdev' command executes a number of maven commands and clear access to Maven Central is required for any of these to work. 

Trust the Maven Central Certificate 

When a system is behind a proxy server, SSL access to internet services like Maven Central may be blocked. The solution is to add explicit trust of specific site certificates you need into the Java 'cacers' truststore for the Java installation being used by TIBCO Streaming and Maven. This is usually the JDK installed at:
Windows: C:\tibco\sb-cep\10.6\jdk 
Linux/opt/tibco/sb-cep/10.6/jdk 

The following commands assume you are using the default Oracle Java that is installed with TIBCO Streaming. If you are using a different Java install, as indicated on your system PATH and by the value of the JAVA_HOME environment variable, then you will need to find the alternative 'cacerts' truststore file in that Java installation.

1. Download the Maven Central certificate

Most modern web browsers indicate whether a site has a trusted certificate using a "lock" icon next to the URL. A menu available from clicking on the lock icon will give you access to download the site's public certificate. Download the .cer or .crt file to your system. Please find the instructions for your browser in the browser help.

2. Install the certificate into the Java truststore

In a StreamBase Command Prompt or terminal window which is configured correctly for TIBCO Streaming, run the Java 'keytool' command as so:

Windows:
keytool -import -file repo.maven.apache.org.crt -keystore C:\tibco\sb-cep\10.6\jdk\lib\security\cacerts
Enter keystore password: 
Owner: CN=repo.maven.apache.org, O="Sonatype, Inc", L=Fulton, ST=Maryland, C=US
Issuer: CN=DigiCert SHA2 Secure Server CA, O=DigiCert Inc, C=US
...
Trust this certificate? [no]:  yes
Certificate was added to keystore
("changeit" is the default password.)

Linux:
keytool -import -file ./repo.maven.apache.org.crt -keystore /opt/tibco/sb-cep/10.6/jdk/lib/security/cacerts
Enter keystore password: 
Owner: CN=repo.maven.apache.org, O="Sonatype, Inc", L=Fulton, ST=Maryland, C=US
Issuer: CN=DigiCert SHA2 Secure Server CA, O=DigiCert Inc, C=US
...
Trust this certificate? [no]:  yes
Certificate was added to keystore
("changeit" is the default password.)

At this point, Maven commands and TIBCO Streaming commands and SB Studio which use the Java install with this modification will trust Maven Central for SSL access.

Verify TIBCO Streaming Maven Commands

To verify that TIBCO Streaming can now access Maven Central, run from a correctly configured terminal or the StreamBase Command Prompt:
  epdev install maven 
This copies the TIBCO Streaming libraries needed for typechecking and building into the user's local Maven repository. 

If this fails, run the command again using the '-X' option to turn on DEBUG logging for Maven, as so:
  epdev -X install maven 

See the "Caused by" lines to identify the root cause of the problem. If the cause is a permissions problem related to SSL, double-check the steps used for installing the Maven Central certificate. For other errors double-check the settings.xml proxy configuration.