Sunday, 10 January 2016

Liferay : Solution : Possible errors while installing Maven with Liferay.

Hello,

During the installation of Maven with Liferay, I have faced numerous errors, documentation for Maven installation given by Liferay is good but I did not find any solution for below errors, here I would like to share solutions of following errors.

Here, You can find steps for installation of Maven with Liferay, this documentation is for 6.1 EE version but it will still work for Liferay 6.2 EE and CE.

Environment details :
  • Window 10. 
  • Liferay 6.2 SP14 + Tomcat-7.0.62.
  • Liferay-portal-maven-6.2-ee-sp14,
  • Apache-maven-3.3.9.
  • Local M2 repository. 

As per Liferay documentation we just need just execute "ant install" command from Liferay-portal-maven-6.2-ee-sp14, it will install all artifacts of Liferay to your local repository, while execute these command I have faced three problems one after another, lets go through the solution of each one of them.

Error  1 : Property lp.maven.repository.url or lp.maven.repository.id  was circularly defined

Error 1 : Property lp.maven.repository.url or lp.maven.repository.id  was circularly defined.



Solution for Error 1 : I need these artifacts inside my local repository so I do not need to create build.<username>.properties file, reason of this error is cause value of lp.maven.repository.id and lp.maven.repository.url properties in build.properties file.

build.properties : (this is what by default comes)

gpg.keyname=
gpg.passphrase=
lp.maven.repository.id=${lp.maven.repository.id}
lp.maven.repository.url=${lp.maven.repository.url}
lp.version.maven=6.2.10.15

build.properties : (this is what you need to change, just remove value)

gpg.keyname=
gpg.passphrase=
lp.maven.repository.id=
lp.maven.repository.url=
lp.version.maven=6.2.10.15

Error 2 : Execute failed: java.io.IOException: Cannot run program "mvn.bat": CreateProcess error=2, The system cannot find the file specified

Error 2 : Cannot run mvn.bat

Solution for Error 2:

it seems that apache mvn.bat is renamed to mvn.cmd with maven 3.3.1 version onward (Check), that means if you extract zip file of apache-maven-3.3.9, you will find following structure inside the bin folder,in order to resolve this you need to rename mvn.cmd to mvn.bat file


NO .bat FILE EXIST

Error 3   :  M2_HOME is set to invalid directory.

Error 3   :  M2_HOME is set to invalid directory.


Solution for Error 3:

So while resolving Error 2 we renamed mvn.cmd to mvn.bat that means we dont have any mvn.cmd available inside the "/bin" folder but some of the file are still expect mvn.cmd inside "/bin" folder which means we need to create a copy and make sure that we will be have two files mvn.bat and mvn.cmd inside "/bin" folder as shown below 
(Note : Both are the same files just name are different as they are expecting mvn.cmd inside some script)















Hope this will helpful to other and save some time.

Feel free to drop a question or comment.

Thanks,
Sagar Vyas