cancel
Showing results for 
Search instead for 
Did you mean: 

wrong artifacts from alfresco maven repository

marco_altieri
Star Contributor
Star Contributor
Hi,

as described here https://forums.alfresco.com/en/viewtopic.php?f=10&t=46135&p=136357&hilit=maven#p136357, sometimes the alfresco maven repository returns wrong artifacts that are html error pages.

I have the same problem with the following pom file:


<?xml version="1.0" encoding="UTF-8"?>
   <!–
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements. See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version
      2.0 (the "License"); you may not use this file except in compliance
      with the License. You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0 Unless required by
      applicable law or agreed to in writing, software distributed under the
      License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
      CONDITIONS OF ANY KIND, either express or implied. See the License for
      the specific language governing permissions and limitations under the
      License.
   –>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.someco</groupId>
   <artifactId>alfresco-subscriptions</artifactId>
   <packaging>amp</packaging>
   <name>Alfresco Subscription</name>
   <!–
      An Alfresco version number must be of the form 1.2.3.4. Using
      1.0-SNAPSHOT as the AMP version will create an exception. See
      http://wiki.alfresco.com/wiki/Developing_an_Alfresco_Module: "The
      version number must be made up of numeric values separated by dots.
      For example '2.1.56' is a valid version number, '2.3.4a' is not. " In
      order to be able to use Maven snapshots we cannot use the <version/>
      below as the AMP module version. Instead we use the
      buildnumber-maven-plugin. This requires a scm connection.
   –>
   <version>1.0.0-SNAPSHOT</version>
   <description>Alfresco Subscription</description>
   <repositories>
                <!– ********************************************************************************* –>
                <!– ***************************** WORKAROUND ********************************** –>
                <!– ********************************************************************************* –>
      <repository>
         <id>central</id>
         <url>http://uk.maven.org/maven2</url>
      </repository>
      <repository>
         <id>alfresco-private-repository</id>
         <url>https://artifacts.alfresco.com/nexus/content/groups/private</url>      
      </repository>
      <repository>
         <id>alfresco-public-snapshots</id>
      <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
      </repository>
      <repository>
         <id>alfresco-public</id>
      <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
      </repository>
   </repositories>
   <pluginRepositories>
      <pluginRepository>
         <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
      </pluginRepository>
      <pluginRepository>
         <id>alfresco-public-snapshots</id>
         <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
         <snapshots>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
      </pluginRepository>
   </pluginRepositories>
   <properties>
      <!–
         Default for which src/main/properties/<env>/alfresco-global.properties is
         loaded. NB: used only for the 'test' profile (e.g. '-P test' on the
         mvn commandline) jetty run deployment, does not impact AMP behavior
         which is typically environment independent
      –>
      <env>local</env>
      <!– Webapp used to test/develop locally the AMP –>
      <webapp.name>${project.artifactId}-webapp</webapp.name>
      <!–
         | | By default the src/test/properties/local/alfresco-global.properties
         uses the property "alfresco.data.location" to specify where |
         alf_data gets created. | For local jetty:run deployment default
         creation dir is under project root folder (as location is specified
         relatively to run | dir). Please add alf_data_jetty in svn/cvs
         ignores in order not to commit that. You can also specified a
         different (out of the | sproject) folder | by editing the following
         properties. | DB is also configurable here. Of course keep in sync
         these two values otherwise you'll get integrity errors. | | Empty log
         dir creates file alfresco.log in appserver default dir. You can also
         specify a meaningful log directory for the server | (add a trailing
         slash, e.g. '/var/log/alfresco/' ) | | Jetty embedded run logs by
         default in target/alfresco.log
      –>
        <alfresco.version>4.0.0</alfresco.version>
        <alfresco.edition></alfresco.edition>
      <alfresco.data.location>./alf_data_jetty</alfresco.data.location>
      <alfresco.db.name>alf_jetty</alfresco.db.name>
      <alfresco.db.username>alfresco</alfresco.db.username>
      <alfresco.db.password>alfresco</alfresco.db.password>
        <alfresco.db.params>MODE=PostgreSQL;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;MVCC=TRUE</alfresco.db.params>
        <alfresco.db.url>jdbc:h2:${alfresco.data.location}/h2_data/${alfresco.db.name};${alfresco.db.params}</alfresco.db.url>
        <alfresco.db.datasource.class>org.h2.jdbcx.JdbcDataSource</alfresco.db.datasource.class>
        <webapp.log.level>error</webapp.log.level>
      <webapp.log.dir></webapp.log.dir>
      <!–  End of testing webapp specific properties –>
      <!–  Module specific build time properties –>
      <module.log.level>debug</module.log.level>
        <spring.version>3.0.5.RELEASE</spring.version>
   </properties>
   <!–
      need to list these as a provided so that Maven doesn't download them
      and include them in the AMP, they are provided by Alfresco
   –>
   <dependencies>
        <dependency>
         <groupId>org.alfresco.enterprise</groupId>
         <artifactId>alfresco-data-model</artifactId>
         <version>${alfresco.version}</version>
         <scope>provided</scope>
         <classifier>${alfresco.edition}</classifier>
      </dependency>
      <dependency>
        <groupId>org.springframework.extensions.surf</groupId>
        <artifactId>spring-webscripts</artifactId>
        <version>1.0.0</version>
          <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>org.json</groupId>
        <artifactId>com.springsource.org.json</artifactId>
        <version>1.0.0</version>
          <scope>provided</scope>
      </dependency>
        <dependency>
            <groupId>org.alfresco.enterprise</groupId>
            <artifactId>alfresco-core</artifactId>
            <version>${alfresco.version}</version>
            <scope>provided</scope>
            <classifier>${alfresco.edition}</classifier>
        </dependency>
        <dependency>
         <groupId>org.alfresco.enterprise</groupId>
         <artifactId>alfresco-repository</artifactId>
         <version>${alfresco.version}</version>
         <scope>provided</scope>
         <classifier>${alfresco.edition}</classifier>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
         <version>${spring.version}</version>
         <scope>provided</scope>
      </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
            <scope>provided</scope>
        </dependency>
      <!–
         Example Jar dependency: will be properly packed into the AMP /lib
         directory <dependency> <groupId>rome</groupId>
         <artifactId>opensearch</artifactId> <version>0.1</version>
         </dependency>
      –>
      <!–
         Example AMP dependency: will be properly overlayed in the WAR
         produced by the integration-test phase in profile 'webapp'
         <dependency> <groupId>org.alfresco.enterprise</groupId>
         <artifactId>recordsmanagement</artifactId> <version>2.1.0</version>
         <type>amp</type> </dependency>
      –>
      <!– Don't add here amp dependencies as it will break amp packaging –>
   </dependencies>
   <!–
      The scm is required for the buildnumber-maven-plugin which is required
      for AMP version numbering
   –>
   <scm>
      <connection>scm:svn:http://domain.com/svn/trunk/</connection>
      <developerConnection>scm:svn:https://${user.name}@domain.com/svn/trunk/</developerConnection>
      <url>http://domain.com/svn/trunk/</url>
   </scm>
   <build>
        <plugins>
            <!– Needed for cross OS compatibility in acp/zip encoding –>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <!– By default as per http://code.google.com/p/maven-alfresco-archetypes/issues/detail?id=7 FTL are not filtered to avoid corruption.
                        | This behavior can be relaxed (in case filtering is needed in the FTLs) by selecting which files are filtered and which not as described
                        | here http://code.google.com/p/maven-alfresco-archetypes/issues/detail?id=7#c3
                        –>
                    <nonFilteredFileExtensions>
                        <nonFilteredFileExtension>ftl</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                </configuration>
            </plugin>
            <plugin>
            <artifactId>maven-nosnapshot-plugin</artifactId>
            <groupId>org.alfresco.maven</groupId>
             <version>0.0.8</version>
            <executions>
               <execution>
                  <id>default</id>
                  <phase>initialize</phase>
                  <goals>
                     <goal>strip</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
               <execution>
                  <phase>validate</phase>
                  <goals>
                     <goal>create</goal>
                  </goals>
               </execution>
            </executions>
            <configuration>
               <revisionOnScmFailure>1</revisionOnScmFailure>
               <doCheck>false</doCheck>
               <doUpdate>false</doUpdate>
            </configuration>
         </plugin>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
               <source>1.6</source>
               <target>1.6</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.alfresco.maven.plugin</groupId>
            <artifactId>maven-amp-plugin</artifactId>
            <version>3.0.4</version>
            <extensions>true</extensions>
            <configuration>
               <archive>
                  <addMavenDescriptor>false</addMavenDescriptor>
               </archive>
               <overlays>
                  <!–
                     This sample adds records management module in the finally built
                     AMP <overlay> <groupId>org.org.alfresco</groupId>
                     <artifactId>recordsmanagement</artifactId>
                     <version>2.1.0</version> <type>amp</type> </overlay>
                  –>
                  <!–
                     The current AMP is always last in order to overwrite other
                     modules' modules.properties <overlay></overlay>
                  –>
               </overlays>
            </configuration>
         </plugin>
      </plugins>
      <!–
         Copies and filters resources in build folder so maven-amp-plugin can
         pick them up
      –>
      <resources>
         <resource>
            <filtering>true</filtering>
            <directory>src/main/resources</directory>
            <excludes>
               <exclude>**README-*</exclude>
            </excludes>
         </resource>
         <!–
            Copies and filters AMP config in the proper package
            'alfresco/module/${project.artifactId}' so to enforce full module
            naming single sourcing from POM properties
         –>
         <resource>
            <filtering>true</filtering>
            <directory>src/main/config</directory>
            <targetPath>alfresco/module/${project.artifactId}</targetPath>
            <excludes>
               <exclude>**README-*</exclude>
            </excludes>
         </resource>
      </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-dependency-plugin</artifactId>
                                        <versionRange>[2.0,)</versionRange>
                                        <goals>
                                            <goal>copy-dependencies</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.alfresco.maven</groupId>
                                        <artifactId>maven-nosnapshot-plugin</artifactId>
                                        <versionRange>[0.0,)</versionRange>
                                        <goals>
                                            <goal>strip</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
   <profiles>
      <!–
         Profile used to trigger war creation and integration within Jetty
         embedded
      –>
      <profile>
         <id>webapp</id>
         <build>
            <filters>
               <filter>${project.basedir}/src/test/properties/${env}/alfresco-global.properties</filter>
            </filters>
            <defaultGoal>jetty:run-exploded</defaultGoal>
            <plugins>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-dependency-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>unpack-amps</id>
                        <phase>process-resources</phase>
                        <goals>
                           <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                           <includeTypes>amp</includeTypes>
                           <outputDirectory>${project.build.directory}/${webapp.name}</outputDirectory>
                           <excludes>META*</excludes>
                        </configuration>
                     </execution>
                  </executions>
                  <dependencies>
                     <!–
                        This is required to be re-defined explicitly at plugin level as
                        otherwise the 'amp' extension unArchiver won't be available to
                        the maven-dependency-plugin
                     –>
                     <dependency>
                        <groupId>org.alfresco.maven.plugin</groupId>
                        <artifactId>maven-amp-plugin</artifactId>
                        <version>3.0.4</version>
                     </dependency>
                  </dependencies>
               </plugin>
               <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-war-plugin</artifactId>
                  <executions>
                     <!– Runs war packaging when 'integration-test' phase is called –>
                     <execution>
                        <id>it</id>
                        <phase>package</phase>
                        <goals>
                           <goal>exploded</goal>
                        </goals>
                        <configuration>
                           <archiveClasses>true</archiveClasses>
                        </configuration>
                     </execution>
                  </executions>
                  <configuration>
                     <primaryArtifact>false</primaryArtifact>
                     <!–
                        Don't remove the following line otherwise WAR and AMP builds
                        will be done in the same folder, with unexpected results
                     –>
                     <webappDirectory>${project.build.directory}/${webapp.name}</webappDirectory>
                     <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                     </archive>
                     <warSourceExcludes>licenses/**</warSourceExcludes>
                     <webResources>
                        <resource>
                           <directory>${project.build.testOutputDirectory}</directory>
                           <targetPath>WEB-INF/classes</targetPath>
                           <filtering>true</filtering>
                           <includes>
                              <include>**</include>
                           </includes>
                        </resource>
                        <!– Here we add default this AMP web/ resources–>
                        <resource>
                           <directory>src/main/webapp</directory>
                           <targetPath>WEB-INF/licenses</targetPath>
                           <includes>
                              <include>licenses/*.*</include>
                           </includes>
                           <filtering>false</filtering>
                        </resource>
                                <resource>
                                    <directory>jetty</directory>
                                    <targetPath>WEB-INF</targetPath>
                                    <filtering>true</filtering>
                                </resource>
                     </webResources>
                  </configuration>
                  <dependencies>
                     <!–
                        This is required to be re-defined explicitly at plugin level as
                        otherwise the 'amp' extension unArchiver won't be available to
                        the maven-war-plugin
                     –>
                     <dependency>
                        <groupId>org.alfresco.maven.plugin</groupId>
                        <artifactId>maven-amp-plugin</artifactId>
                        <version>3.0.4</version>
                     </dependency>
                  </dependencies>
               </plugin>
               <plugin>
                  <groupId>org.mortbay.jetty</groupId>
                  <artifactId>maven-jetty-plugin</artifactId>
                        <version>6.1.26</version>
                  <executions>
                     <!– Runs jetty when 'integration-test' phase is called –>
                     <execution>
                        <id>it</id>
                        <phase>integration-test</phase>
                        <goals>
                           <goal>run-exploded</goal>
                        </goals>
                        <configuration>
                           <contextPath>/${webapp.name}</contextPath>
                           <webApp>${project.build.directory}/${webapp.name}</webApp>
                           <scanIntervalSeconds>10</scanIntervalSeconds>
                           <connectors>
                              <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                                 <port>8080</port>
                                 <maxIdleTime>60000</maxIdleTime>
                              </connector>
                           </connectors>
                        </configuration>
                     </execution>
                  </executions>
                        <dependencies>
                            <dependency>
                                <groupId>commons-dbcp</groupId>
                                <artifactId>commons-dbcp</artifactId>
                                <version>1.4</version>
                            </dependency>
                        </dependencies>
               </plugin>
            </plugins>
            <!–
               When invoking 'mvn integration-test', the following alf configs are
               added to the test war in order to be able to run it seamlessly. NB:
               the alfresco-global.properties file is filtered with alfresco.db.name
               and alf.data.location POM properties as default configuration
            –>
            <testResources>
               <testResource>
                  <filtering>true</filtering>
                  <directory>src/test/resources</directory>
               </testResource>
               <!– Includes default properties  for alfresco test war –>
               <testResource>
                  <filtering>true</filtering>
                  <directory>src/test/properties/${env}</directory>
               </testResource>
               <!–
                  src/main/config/ is copied into ==>
                  target/test-classes/alfresco/module/${project.artifactId} to be
                  picked up by the maven-war plugin Best practice tacken from
                  recordsmanagement.amp, is enforced troughout the whole archetype.
                  This convention is also used for module.properties filtering.
               –>
               <testResource>
                  <filtering>true</filtering>
                  <directory>.</directory>
                  <includes>
                     <include>module.properties</include>
                  </includes>
                  <targetPath>alfresco/module/${project.artifactId}</targetPath>
               </testResource>
            </testResources>
         </build>
         <dependencies>
            <dependency>
               <groupId>org.alfresco.enterprise</groupId>
               <artifactId>alfresco</artifactId>
               <version>${alfresco.version}</version>
               <type>war</type>
               <classifier>${alfresco.edition}</classifier>
            </dependency>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <version>1.3.158</version>
                </dependency>
                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate</artifactId>
                    <version>3.2.7.ga</version>
                    <scope>provided</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>net.sf.ehcache</groupId>
                            <artifactId>ehcache</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>tk.skuro.alfresco</groupId>
                    <artifactId>h2-support</artifactId>
                    <version>1.2</version>
                </dependency>
         </dependencies>
      </profile>

   </profiles>
</project>

In the pom file, I had to specify a mirror of the central repository as the first repository in the repository list otherwise wrong artifacts are download from the alfresco maven.
For example the content of the org/springframework/spring-context/spring-context-3.0.0.RELEASE.jar artifact is:


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://maven.alfresco.com/nexus/content/groups/public/org/springframework/spring-context/3.0.0.RELE...">here</a>.</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at maven.alfresco.com Port 80</address>
</body></html>

As far as I can see, the maven client receives a wrong status code by the Apache server and accepts the response as a valid artifacts (of course it is considered valid until it tries to open it).

Regards,
Marco
6 REPLIES 6

billerby
Champ on-the-rise
Champ on-the-rise
Marco,

For your issue to be addressed properly I suggest posting in the google group https://groups.google.com/forum/#!forum/maven-alfresco

If you are building the enterprise edition, you should (I guess since this should now be supported by Alfresco) report it in the support portal?

/Erik

marco_altieri
Star Contributor
Star Contributor
Hi Erik,

I have posted a new topic in the google group.
I prefer to wait before rising a ticket. I'm already waiting for the resolution of other issues that are more important. I don't want to add noise…

Regards,
Marco

Marco,

For your issue to be addressed properly I suggest posting in the google group https://groups.google.com/forum/#!forum/maven-alfresco

If you are building the enterprise edition, you should (I guess since this should now be supported by Alfresco) report it in the support portal?

/Erik

mindthegab
Champ in-the-making
Champ in-the-making
Yes, it´s a known issue Smiley Sad

You want to change any reference to http://maven.alfresco.com to https://artifacts.alfresco.com (notice the HTTPS).

I will soon release new archetypes with this fixed…sorry for the issue!

marco_altieri
Star Contributor
Star Contributor
Hi Gabriele,

thank you for your reply.
I have already modified the pom file. There aren't references to http://maven.alfresco.com anymore.
I have written the whole pom file in the first post.

I don't know why it tries to access the old url…

Regards,
Marco

billerby
Champ on-the-rise
Champ on-the-rise
I found out the reason is in transitive dependencies. The parent pom of the referenced library spring-surf also contains faulty URL:s Smiley Sad

I have filed an issue in the jira of that project.

/Erik

billerby
Champ on-the-rise
Champ on-the-rise
Marco,

First delete the org.springframework artifacts from your local repository, then supply another wagon provider when running mvn:

mvn -Dmaven.wagon.provider.http=httpclient clean install

The error you are receiving is because in because the default wagon provider (lightweight http) can't handle http protocol redirects (in this case from http to https) resulting in the errous pomfiles.

Hope this helps.

/Erik

BTW. This is corrected in wagon 2.1 but since I'm still on maven 2.2.1 it does'nt seem possible to specify this version in my execution directive of my pom.xml without running into other problems.