AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modules

cancel
Showing results for 
Search instead for 
Did you mean: 
plarochette
Customer

AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modules

Jump to solution

Hi,

All the modules that i have created with SDK 4.1 are reported twice at ACS startup and in share admin modules with ACS 6.2.2.

The others modules not. 

share modules reported twice.png

And in share admin module navigator :

share modules reported twice_2.png

I have not modified the default structure of the AMP. The modules in twice work normally but i dont understand why they are listed twice.

An old post talk about a same problem in sdk 3 but it has been fixed since (mix of test-classes and classes).

Does someone have an idea where i can search ? I think the problem is linked with the fact that the module.properties file of the module is also in the jar file of the module in the war file...

Thanks for your help.

1 Solution

Accepted Solutions
abhinavmishra14
Advanced

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

I see the problem, it is not just with share modules but its the same case with platform modules as well. 

By default SDK4.x meant to build jar based artifact and hence the module.properties file is located under "src\main\resources\alfresco\module\<yourShareModule>" path. and when you also enable the sdk to generate amps along with jars, it end up putting the jar inside the amp/lib having one more module.properties file. 

If you enabled this plug-in, you get the amp along with jars:

some details can be found here: https://github.com/Alfresco/alfresco-sdk/blob/master/docs/advanced-topics/amps.md

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-assembly-plugin</artifactId>
	<version>2.6</version>
	<executions>
		<execution>
			<id>build-amp-file</id>
			<phase>package</phase>
			<goals>
				<goal>single</goal>
			</goals>
			<configuration>
				<appendAssemblyId>false</appendAssemblyId>
				<descriptor>src/main/assembly/amp.xml</descriptor>
			</configuration>
		</execution>
	</executions>
	<dependencies>
		<dependency>
			<groupId>org.alfresco.maven.plugin</groupId>
			<artifactId>alfresco-maven-plugin</artifactId>
			<version>${alfresco.sdk.version}</version>
		</dependency>
	</dependencies>
</plugin>

The catch is that, amps can't be installed unless there is module.properties file at the top level of the amp. 

There are two options to fix this:

1- Exclude the module.properties from jar via maven-jar-plugin exclude config. Pros: Issue will be fixed, Cons: Only amp artifact can be deployed. If for any reason if you would have to go back to jar artifact only, then you have to include the module.properties back and remove the exclude config. OOTB local docker deployment may also fail as it will by default copy the jar in extensions directory and if jar doesn't have module.properties, it will not work. so you must also add <includeTypes>amp</includeTypes> to the docker projects where it copies the extensions and <type>amp</type> to the dependencies section.

2- Create a custom copy jar (name it well so you can identify the purpose) and exclude the original jar + include the custom jar with no module.properties in the amp. Pros: Issue will be fixed. Both amp and jar based artifacts can be used. Cons: An additonal jar will be created

Here is one of the examples:

- Add following plugin before maven-assembly-plugin in <YourShareModule>\pom.xml. Note that order of plugins matter, so must be added before maven-assembly-plugin

- Add following plugin before maven-assembly-plugin in <YourPlatformModule>\pom.xml. Note that order of plugins matter, so must be added before maven-assembly-plugin

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-shade-plugin</artifactId>
	<version>3.2.0</version>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>shade</goal>
			</goals>
			<configuration>
				<filters>
					<filter>
						<artifact>*:*</artifact>
						<excludes>
<!-- Exclude module.properties --> <exclude>**/alfresco/module/${project.artifactId}/module.properties</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin>

- Update platform dependency type for your platform module and includeTypes under maven-dependency-plugin's copy-dependencies goal in <YourPlatformModule>-docker\pom.xml, example (see in bold):

<dependency>
       <groupId>com.demo</groupId>
       <artifactId>acs71-demo-platform</artifactId>
       <version>1.0-SNAPSHOT</version>
        <type>amp</type>
 </dependency>

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<!-- Copy the repository extension and the dependencies required for execute integration tests -->
		<execution>
			<id>collect-test-artifacts</id>
			<phase>pre-integration-test</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>${project.build.directory}/extensions</outputDirectory>
				<excludeScope>compile</excludeScope>
			</configuration>
		</execution>
		<!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
		<execution>
			<id>collect-extensions</id>
			<phase>package</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>${project.build.directory}/extensions</outputDirectory>
				<includeScope>runtime</includeScope>
				<includeTypes>amp,jar</includeTypes>
				<!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> -->
			</configuration>
		</execution>
	</executions>
</plugin>

- Update platform dependency type for your platform module and includeTypes under maven-dependency-plugin's copy-dependencies goal in <YourShareModule>-docker\pom.xml, example (see in bold):

<dependency>
       <groupId>com.demo</groupId>
       <artifactId>acs71-demo-share</artifactId>
       <version>1.0-SNAPSHOT</version>
       <type>amp</type>
 </dependency>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker --> <execution> <id>collect-extensions</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/extensions</outputDirectory> <includeScope>runtime</includeScope> <includeTypes>amp</includeTypes> <!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> --> </configuration> </execution> </executions> </plugin>

You can find examples here: https://github.com/abhinavmishra14/acs7-sdk43-demo

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View solution in original post

10 Replies
abhinavmishra14
Advanced

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

Can you share the result of following command:

java -jar alfresco-mmt.jar list <ShareWARFileLocation>
or
 java -jar bin/alfresco-mmt.jar list tomcat/webapps/share.war

Usually following properties are used from module.properties

module.id=${project.artifactId}
module.title=${project.name}
module.description=${project.description}
module.version=${project.version}

As you can see, it refers to maven properties, its likely that you may have two different modules having different ids but using same title/description. But first check the result of the above command and you may have to verify all amp modules to check the values for the above properties/pom files

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
plarochette
Customer

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

Thank you abhinavmishra14 for your help.

The alfesco-mmt list command list only one amp module with this id >
share modules reported twice_5.png
It seems that there is no artifactId problem... The 2 module.properties files (in the jar include in the AMP and in the AMP module) are also similar.

I have created a new alfresco database and start with a public sdk 4.x AMP module from Jeff POTTS tutorial (actions-tutorial-share for example) and i have the same result...
share modules reported twice_4.png

 


share modules reported twice_3.png


Is there something else that i can check ?

Thank you.

abhinavmishra14
Advanced

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

This could be an issue/bug with share modules view and may be showing duplicates. Which specific version of acs6 you are using, so i can also try to replicate?

 

 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
plarochette
Customer

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

Thank you,

Yesterday i have downloaded the last alfresco.war, share.war and alfresco-share-services.amp of the distribution package 6.2.2.19 (
Enterprise - 6.2.2 (19 r8452332f-b3758)) and i have the same issue.

I have noticed that the infos that are displayed twice come from this 2 module.properties files :

First info line in share module browser comes from module.properties file in C:\alfresco-content-services\tomcat\webapps\share\WEB-INF\lib\actions-tutorial-share-1.0-SNAPSHOT.jar\alfresco\module\actions-tutorial-share\module.properties

Second info line in share module browser comes from module.properties file in
C:\alfresco-content-services\tomcat\webapps\share\WEB-INF\classes\alfresco\module\actions-tutorial-share\module.properties

Thank you for your help.

Best regards.

abhinavmishra14
Advanced

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

Glad you could figure out. 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
plarochette
Customer

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

Thank you, 

I have identified the source of the informations that are reported twice but it it doesn't solve the problem Smiley Sad

By default, the share AMP module seems to include 2 module.properties files for each AMP module created with the SDK 4.1.

One in the AMP file and one in the JAR file that is included in the AMP file. So the Share module browser lists twice the module.

How to avoid this, is it a good method to remove one of this 2 files ? Does the solution is to modify the amp.xml file for example in  :

SDK 4.1 amp.xml >

Not include module.properties at amp root ?
share modules reported twice6.png


Or not include the jar file in the module ?

share modules reported twice7.png

 

 

Thanks a lot.

abhinavmishra14
Advanced

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

I see the problem, it is not just with share modules but its the same case with platform modules as well. 

By default SDK4.x meant to build jar based artifact and hence the module.properties file is located under "src\main\resources\alfresco\module\<yourShareModule>" path. and when you also enable the sdk to generate amps along with jars, it end up putting the jar inside the amp/lib having one more module.properties file. 

If you enabled this plug-in, you get the amp along with jars:

some details can be found here: https://github.com/Alfresco/alfresco-sdk/blob/master/docs/advanced-topics/amps.md

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-assembly-plugin</artifactId>
	<version>2.6</version>
	<executions>
		<execution>
			<id>build-amp-file</id>
			<phase>package</phase>
			<goals>
				<goal>single</goal>
			</goals>
			<configuration>
				<appendAssemblyId>false</appendAssemblyId>
				<descriptor>src/main/assembly/amp.xml</descriptor>
			</configuration>
		</execution>
	</executions>
	<dependencies>
		<dependency>
			<groupId>org.alfresco.maven.plugin</groupId>
			<artifactId>alfresco-maven-plugin</artifactId>
			<version>${alfresco.sdk.version}</version>
		</dependency>
	</dependencies>
</plugin>

The catch is that, amps can't be installed unless there is module.properties file at the top level of the amp. 

There are two options to fix this:

1- Exclude the module.properties from jar via maven-jar-plugin exclude config. Pros: Issue will be fixed, Cons: Only amp artifact can be deployed. If for any reason if you would have to go back to jar artifact only, then you have to include the module.properties back and remove the exclude config. OOTB local docker deployment may also fail as it will by default copy the jar in extensions directory and if jar doesn't have module.properties, it will not work. so you must also add <includeTypes>amp</includeTypes> to the docker projects where it copies the extensions and <type>amp</type> to the dependencies section.

2- Create a custom copy jar (name it well so you can identify the purpose) and exclude the original jar + include the custom jar with no module.properties in the amp. Pros: Issue will be fixed. Both amp and jar based artifacts can be used. Cons: An additonal jar will be created

Here is one of the examples:

- Add following plugin before maven-assembly-plugin in <YourShareModule>\pom.xml. Note that order of plugins matter, so must be added before maven-assembly-plugin

- Add following plugin before maven-assembly-plugin in <YourPlatformModule>\pom.xml. Note that order of plugins matter, so must be added before maven-assembly-plugin

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-shade-plugin</artifactId>
	<version>3.2.0</version>
	<executions>
		<execution>
			<phase>package</phase>
			<goals>
				<goal>shade</goal>
			</goals>
			<configuration>
				<filters>
					<filter>
						<artifact>*:*</artifact>
						<excludes>
<!-- Exclude module.properties --> <exclude>**/alfresco/module/${project.artifactId}/module.properties</exclude> </excludes> </filter> </filters> </configuration> </execution> </executions> </plugin>

- Update platform dependency type for your platform module and includeTypes under maven-dependency-plugin's copy-dependencies goal in <YourPlatformModule>-docker\pom.xml, example (see in bold):

<dependency>
       <groupId>com.demo</groupId>
       <artifactId>acs71-demo-platform</artifactId>
       <version>1.0-SNAPSHOT</version>
        <type>amp</type>
 </dependency>

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<!-- Copy the repository extension and the dependencies required for execute integration tests -->
		<execution>
			<id>collect-test-artifacts</id>
			<phase>pre-integration-test</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>${project.build.directory}/extensions</outputDirectory>
				<excludeScope>compile</excludeScope>
			</configuration>
		</execution>
		<!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker -->
		<execution>
			<id>collect-extensions</id>
			<phase>package</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>${project.build.directory}/extensions</outputDirectory>
				<includeScope>runtime</includeScope>
				<includeTypes>amp,jar</includeTypes>
				<!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> -->
			</configuration>
		</execution>
	</executions>
</plugin>

- Update platform dependency type for your platform module and includeTypes under maven-dependency-plugin's copy-dependencies goal in <YourShareModule>-docker\pom.xml, example (see in bold):

<dependency>
       <groupId>com.demo</groupId>
       <artifactId>acs71-demo-share</artifactId>
       <version>1.0-SNAPSHOT</version>
       <type>amp</type>
 </dependency>
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <!-- Collect extensions (JARs or AMPs) declared in this module do be deployed to docker --> <execution> <id>collect-extensions</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/extensions</outputDirectory> <includeScope>runtime</includeScope> <includeTypes>amp</includeTypes> <!-- IMPORTANT: if using amp dependencies only, add <includeTypes>amp</includeTypes> --> </configuration> </execution> </executions> </plugin>

You can find examples here: https://github.com/abhinavmishra14/acs7-sdk43-demo

~Abhinav
(ACSCE, AWS SAA, Azure Admin)
plarochette
Customer

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

Thanks very much for the workaround and for the informations about the use of the maven-shade-plugin. It works.

For the plateform modules, in my case, the fact of having 2 module.properties files has no impact on the list of modules at alfresco startup logs and in the alfresco admin page summary.

http://127.0.0.1:8080/alfresco/s/enterprise/admin/admin-systemsummary

Best regards.

abhinavmishra14
Advanced

Re: AMP Share modules created with SDK 4.1 are reported twice at ACS startup and in share admin modu

Jump to solution

I was seeing that for platform, but at least you are unblocked. 

I have created profile based options here: https://github.com/abhinavmishra14/acs7-sdk43-demo

So if you would have to stick to out of the box build, you can do so. 

To get the amp you need just run: mvn clean package -Pamp-build

~Abhinav
(ACSCE, AWS SAA, Azure Admin)