Wednesday, February 12, 2020

http://repo1.maven.org/maven2/ return a 501 HTTPS Required

Requests to http://repo1.maven.org/maven2/ return a 501 HTTPS Required status and a body:


501 HTTPS Required. 
Use https://repo1.maven.org/maven2/
More information at https://links.sonatype.com/central/501-https-required
Requests to http://repo.maven.apache.org/maven2/ return a 501 HTTPS Required status and a body:
501 HTTPS Required. 
Use https://repo.maven.apache.org/maven2/
More information at https://links.sonatype.com/central/501-https-required
How do I satisfy this requirement so that I can regain access to Central?
E.g:
org.ostermiller:utils:jar:1.07.00 (compile)]: Failed to read artifact descriptor for com.fasterxml.jackson.core:jackson-databind:jar:2.2.3: Could not transfer artifact com.fasterxml.jackson.core:jackson-databind:pom:2.2.3 from/to central (http://repo.maven.apache.org/maven2): Failed to transfer http://repo.maven.apache.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.2.3/jackson-databind-2.2.3.pom. Error code 501, HTTPS Required

Solutions:
1. open your maven repository ${user.home}/.m2 folder and open the setting.xml if exist or else create a new one.
C:\Users\<user name\.m2
2. add the below entries in the setting.xml
<settings>
    <mirrors>
        <mirror>
          <id>centralhttps</id>
          <mirrorOf>central</mirrorOf>
          <name>Maven central https</name>
          <url>http://insecure.repo1.maven.org/maven2/</url>
        </mirror>
      </mirrors>
 </settings>

Tuesday, September 10, 2019

Fat Jar assembly using maven

  1. pom.xml  add the below lines 
 <?xml version="1.0" encoding="UTF-8"?> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>make-bundles</id> <goals> <goal>single</goal> </goals> <phase>package</phase> <configuration> <descriptors> <descriptor>all-jar.xml</descriptor> </descriptors> <finalName>ct-mobile-service</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> </execution> </executions> </plugin>
  1. <?xml version="1.0" encoding="UTF-8"?>
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.blujaysolutions.ct</groupId>
            <artifactId>soa-ct-main</artifactId>
            <version>1.0.0</version>
            <relativePath>../soa-ct-main/pom.xml</relativePath>
        </parent>
        <artifactId>dist</artifactId>
        <packaging>pom</packaging>
        <name>Packaging Test : Distribution</name>
        <properties>
            <wildfly-home>D:\KCT\server\wildfly-17.0.0.Final</wildfly-home>
            <wildfly-hostname>127.0.0.1</wildfly-hostname>
            <wildfly-port>9990</wildfly-port>
            <wildfly-username>Blujay</wildfly-username>
            <wildfly-password>Bluj@y@123</wildfly-password>
        </properties>
        <dependencies>
            <dependency>
                <groupId>com.blujaysolutions.ct</groupId>
                <artifactId>soa-ct-common</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.blujaysolutions.ct</groupId>
                <artifactId>soa-ct-dynamic-screen</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.blujaysolutions.ct</groupId>
                <artifactId>soa-ct-master-services</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.blujaysolutions.ct</groupId>
                <artifactId>soa-ct-mobile-service</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.blujaysolutions.ct</groupId>
                <artifactId>soa-ct-workflow-services</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.blujaysolutions.ct</groupId>
                <artifactId>soa-ct-swagger</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>make-bundles</id>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <phase>package</phase>
                            <configuration>
                                <descriptors>
                                    <descriptor>all-jar.xml</descriptor>
                                </descriptors>
                                <finalName>ct-mobile-service</finalName>
                                <appendAssemblyId>false</appendAssemblyId>
                            </configuration>
                        </execution>
                        <execution>
                            <id>make-bundles2</id>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <phase>package</phase>
                            <configuration>
                                <descriptors>
                                    <descriptor>all-war.xml</descriptor>
                                </descriptors>
                                <finalName>ct-mobile-service</finalName>
                                <appendAssemblyId>false</appendAssemblyId>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
  2. create the all-jar.xml to describe how to assemble the artifacts
    <id>bin</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <includes>
                <include>${project.groupId}:*</include>
            </includes>
            <excludes>
                <exclude>io.springfox:*</exclude>
                <exclude>${project.groupId}:soa-ct-swagger:*</exclude>
            </excludes>
            <unpack>true</unpack>
            <outputDirectory>.</outputDirectory>
            <!-- <outputFileNameMapping>jolokia.war</outputFileNameMapping> -->
        </dependencySet>
        <!-- <dependencySet>
            <outputDirectory>./dependencies</outputDirectory>
            <excludes>
                <exclude>${project.groupId}:*:jar:*</exclude>
                <exclude>io.springfox:*:jar:*</exclude>
            </excludes>
        </dependencySet> -->
    </dependencySets>
</assembly>
3. now run the mvn clean package.