New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to generate WARs without alfresco:run in SDK 3.0 #420

Open
gravitonian opened this Issue Oct 17, 2016 · 25 comments

Comments

Projects
None yet
@gravitonian
Contributor

gravitonian commented Oct 17, 2016

Some users use the WARs as final artifacts for deployments. Today you cannot create the WARs without running the system with alfresco:run.

Provide something like alfresco:build-war that can be used by for example a CI server to create the WARs before deployment.

@gravitonian gravitonian added this to the 3.0.0 milestone Oct 17, 2016

@gravitonian gravitonian self-assigned this Oct 17, 2016

@sujaypillai

This comment has been minimized.

sujaypillai commented Oct 17, 2016

+1 for that .... I am one of that user :)

@toonconvents

This comment has been minimized.

toonconvents commented Oct 17, 2016

+1 Same here

@jgoldhammer

This comment has been minimized.

Collaborator

jgoldhammer commented Nov 27, 2016

@gravitonian
Have you started on this already?
I would like to discuss how the implementation should look like. Any ideas? I could jump on the train to implement it...

Thanks,
Jens

@gravitonian

This comment has been minimized.

Contributor

gravitonian commented Nov 28, 2016

I would probably create a new AbstractRunMojo class and then have the RunMojo (alfresco:run) and BuildWarsMojo (alfresco:build-wars) extend this base class. You would have to just keep a variant of the execute() method in the AbstractRunMojo class that builds the WARs, it would basically do everything except kicking off tomcat, something like:

public void execute() throws MojoExecutionException {
       execEnv = executionEnvironment(
               project,
               session,
               pluginManager
       );

       if (enableSolr) {
           unpackSolrConfig();
           fixSolrHomePath();
           replaceSolrConfigProperties();
           installSolr10InLocalRepo();
       }

       if (enableTestProperties && enablePlatform) {
           copyAlfrescoGlobalProperties();
           renameAlfrescoGlobalProperties();
       }

       if (enablePlatform) {
           buildPlatformWar();
       }

       if (enableShare) {
           buildShareWar();
       }

       if (enableActivitiApp) {
           buildActivitiAppWar();
       }

     //  if (startTomcat) {
       //    checkDatabaseConfig();
         //  startTomcat();
      // }
   }

The BuildWarsMojo would basically just use what is in the AbstractRunMojo class.

@jgoldhammer

This comment has been minimized.

Collaborator

jgoldhammer commented Nov 30, 2016

I just started to implement it, but got an weird error after the build process is success.
I will publish code tomorrow in a PR, but it is basically the same from your comment- everything without starting tomcat...

Exception:

[INFO] Configured Artifact: de.jgoldhammer:testing-sdk-beta6:1.0-SNAPSHOT:jar
[INFO] Copying testing-sdk-beta6-1.0-SNAPSHOT.jar to /Users/jgoldhammer/development/sources/alfresco-sdk/testing-sdk-beta6/target/platform-war/WEB-INF/lib/testing-sdk-beta6-1.0-SNAPSHOT.jar
[INFO] NOT copying Alfresco Enterprise license, running Community edition
[INFO] Installing /Users/jgoldhammer/development/sources/alfresco-sdk/testing-sdk-beta6/target/platform.war to /Users/jgoldhammer/development/maven/de/jgoldhammer/testing-sdk-beta6-platform/1.0-SNAPSHOT/testing-sdk-beta6-platform-1.0-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.900 s
[INFO] Finished at: 2016-11-30T22:20:05+01:00
[INFO] Final Memory: 44M/473M
[INFO] ------------------------------------------------------------------------
java.lang.NoClassDefFoundError: de/schlichtherle/truezip/fs/FsLockController$1Sync
	at de.schlichtherle.truezip.fs.FsLockController.sync(FsLockController.java:240)
	at de.schlichtherle.truezip.fs.archive.zip.KeyController.sync(KeyController.java:128)
	at de.schlichtherle.truezip.fs.FsDecoratingController.sync(FsDecoratingController.java:131)
	at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.sync(FsFalsePositiveArchiveController.java:480)
	at de.schlichtherle.truezip.fs.FsManager.sync(FsManager.java:105)
	at de.schlichtherle.truezip.fs.FsDefaultManager.sync(FsDefaultManager.java:190)
	at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.fs.FsLockController$1Sync
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 7 more

@gravitonian : Any ideas?

@gravitonian

This comment has been minimized.

Contributor

gravitonian commented Dec 1, 2016

Have you mixed running stuff as root at one point and then as a standard user? What I mean is, could there be files in local Maven repo or /target that are owned by the root user?

@ohej ohej modified the milestones: Future Version, 3.0.0 Mar 23, 2017

@ohej

This comment has been minimized.

Collaborator

ohej commented Mar 23, 2017

De-scoping for 3.0

@karthickmani1

This comment has been minimized.

karthickmani1 commented Apr 27, 2017

+1 For this. Any timelines around this?

@archimadhu

This comment has been minimized.

archimadhu commented Apr 27, 2017

+1 for this. Can we have any ETA for this?

@eyaroslavtsev

This comment has been minimized.

eyaroslavtsev commented Apr 28, 2017

+1 for that

@jonfrink

This comment has been minimized.

jonfrink commented Jun 2, 2017

+1

1 similar comment
@binduwavell

This comment has been minimized.

Collaborator

binduwavell commented Jun 2, 2017

+1

@gravitonian

This comment has been minimized.

Contributor

gravitonian commented Jun 7, 2017

Hi,

A simple workaround that might be suitable for most use-cases is to include the following profile in the parent POM in an All-In-One (AIO) project:

<profiles>
       <profile>
           <!-- Invoke your build with -Pgenerate-wars to run the system, but only to the point
                where the wars are generated, skip starting Tomcat.
            -->
           <id>generate-wars-only</id>
           <properties>
               <maven.alfresco.startTomcat>false</maven.alfresco.startTomcat>
           </properties>
       </profile>
   </profiles>

Include the <profiles> section after for example the <build> section.

Then what you need to do is as follows to just generate the WARs without running Tomcat:

$ mvn clean install alfresco:run -Pgenerate-wars-only

You will find the WARs in the target directory:

target martin$ ls -l
total 447592
drwxr-xr-x   5 martin  staff        170  7 Jun 09:17 dependency-maven-plugin-markers
drwxr-xr-x   3 martin  staff        102  7 Jun 09:17 modules
drwxr-xr-x  12 martin  staff        408  7 Jun 09:17 platform-war
-rw-r--r--   1 martin  staff  155090333  7 Jun 09:17 **platform.war**
drwxr-xr-x  18 martin  staff        612  7 Jun 09:17 share-war
-rw-r--r--   1 martin  staff   74072640  7 Jun 09:17 **share.war**
drwxr-xr-x   9 martin  staff        306  7 Jun 09:17 test-classes
@jrosler

This comment has been minimized.

jrosler commented Jun 19, 2017

When I try this, I get a No class def found error. Any thoughts?

java.lang.NoClassDefFoundError: de/schlichtherle/truezip/fs/FsLockController$1Sync
at de.schlichtherle.truezip.fs.FsLockController.sync(FsLockController.java:240)
at de.schlichtherle.truezip.fs.archive.zip.KeyController.sync(KeyController.java:128)
at de.schlichtherle.truezip.fs.FsDecoratingController.sync(FsDecoratingController.java:131)
at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.sync(FsFalsePositiveArchiveController.java:480)
at de.schlichtherle.truezip.fs.FsManager.sync(FsManager.java:105)
at de.schlichtherle.truezip.fs.FsDefaultManager.sync(FsDefaultManager.java:190)
at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.fs.FsLockController$1Sync
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)

@davidabad

This comment has been minimized.

davidabad commented Jul 11, 2017

At this time, built wars includes changes that isn't suitable for deployment on production or integration environment e.i. platform web.xml is updated, properties for hotswaping are injected etc..

At least "org.alfresco.maven.plugin.AbstractRunMojo.buildPlatformWar()" and
"org.alfresco.maven.plugin.AbstractRunMojo.buildShareWar()" methods should test the "startTomcat" flag to avoid unwanted modifications.

@toonconvents

This comment has been minimized.

toonconvents commented Jul 26, 2017

Any update on this guys? Or a viable workaround?

@toonconvents

This comment has been minimized.

toonconvents commented Jul 26, 2017

For anyone who is interested: I have forked the SDK and introduced some minor changes to able to build clean WARS using the alfresco-maven-plugin for deployment to a production system.
https://github.com/toonconvents/alfresco-sdk

@trycoon

This comment has been minimized.

trycoon commented Sep 19, 2017

+1

1 similar comment
@ikaygorodov

This comment has been minimized.

ikaygorodov commented Oct 5, 2017

+1

@ikaygorodov

This comment has been minimized.

ikaygorodov commented Oct 5, 2017

BTW
mvn clean deploy alfresco:run -Pgenerate-wars-only
Maven SDK deploys AMPs and Jars but only installs WARs to local ~/.m2 folder.
This is not great.

@mauro1855

This comment has been minimized.

mauro1855 commented Oct 5, 2017

+1 It would be great if I can get just the wars so I can deploy on my own tomcat.

@abhinavmishra14

This comment has been minimized.

abhinavmishra14 commented Oct 10, 2017

+1 It would be great if I can get the option to generate platform and share war files. It makes deployment process easy.

@Yogesh102

This comment has been minimized.

Yogesh102 commented Nov 13, 2017

Does this work - generate war files - https://github.com/toonconvents/alfresco-sdk ?
I have tried in my local but it does not make any change. It still generates the jars.

@dhaval1671

This comment has been minimized.

dhaval1671 commented Mar 1, 2018

Hi Yogesh102, you can use https://github.com/dhaval1671/SDK-3.0.1-alfresco-plugin
this project which will generate alfresco.war and share.war instead of platform.war add same into your maven dependency

@DEEPAK-KESWANI

This comment has been minimized.

DEEPAK-KESWANI commented Nov 11, 2018

When I try this, I get a No class def found error. Any thoughts?

java.lang.NoClassDefFoundError: de/schlichtherle/truezip/fs/FsLockController$1Sync
at de.schlichtherle.truezip.fs.FsLockController.sync(FsLockController.java:240)
at de.schlichtherle.truezip.fs.archive.zip.KeyController.sync(KeyController.java:128)
at de.schlichtherle.truezip.fs.FsDecoratingController.sync(FsDecoratingController.java:131)
at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.sync(FsFalsePositiveArchiveController.java:480)
at de.schlichtherle.truezip.fs.FsManager.sync(FsManager.java:105)
at de.schlichtherle.truezip.fs.FsDefaultManager.sync(FsDefaultManager.java:190)
at de.schlichtherle.truezip.fs.FsSyncShutdownHook$Hook.run(FsSyncShutdownHook.java:93)
Caused by: java.lang.ClassNotFoundException: de.schlichtherle.truezip.fs.FsLockController$1Sync
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)

The below command solved my problem
mvn dependency:resolve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment