ACloudGuru vs LinuxAcademy Vs CloudAcademy

DISCLAIMER – This post is based on my personal experience. Please let me know if you find any inaccuracy.

DISCLAIMER 2 – This post is not finalized yet. I am going to add comparison for CloudAcademy soon

 ACloudGuruLinuxAcademy
Pricing ModelYou buy a particular course and you get lifetime access to course contentsYou get access to the website. As long as you have access you can access all the courses
Courses / ContentMostly AWS and cloud related courseWide variety of courses - AWS, Linux, Big Data, Devops, Azure etc
Practice Exams/QuizzesAt the time of writing this blog post it has 1 mini exam, 1 practice exam and 11 quizzes. Almost all topics have quizzesAt the time of writing this blog post it has just two quizzes - overview quiz and S3 quiz and 1 practice exam
LabsCourse videos have labs for most of the topics, you have to follow the video and complete the labCourse has 9 Live Labs . You can launch and do the live lab in the AWS account created by you by the course

 

 

Default profile (default.properties) for Patching Liferay on Jboss

You can always use patching tool’s auto-discovery option to generate a profile. In case you are not able to use that following are the sample settings for JBoss. Just create default.properties under patching-tool directory

Key properties to remember are war.path which should point to your ROOT.war directory and global.lib.path which should point to your jar directory

Note: Tested with liferay 6.2 and Jboss 6.4. Example is for Windows OS but same should work for Unix based environments

Tomcat – How to resolve java.util.zip.ZipException: error in opening zip file

This post is not necessarily about any specific technology. Just wanted to tell you about one possible reason for this commonly faced problem. I was working on a Spring MVC application lately and I got the following error

SEVERE [localhost-startStop-4] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/springcaptcha]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [org.apache.catalina.webresources.StandardRoot@70d8c322]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4958)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5088)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
… 10 more
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@2e94c523]
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:136)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:699)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
… 13 more
Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: error in opening zip file
at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:139)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
… 16 more
Caused by: java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:219)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at org.apache.catalina.webresources.JarResourceSet.initInternal(JarResourceSet.java:136)
… 17 more

Now, there could be various reasons why this could be happening. I am just going to tell how I resolved it.

I was using Maven for my builds and it happened that some of the dependency jars downloaded by Maven are not valid. They were Zero Byte, 1Byte jars. Obviously, Tomcat was trying to load those jars and was not able to do so. I resolved this error by manually copying jars from Maven Repos and changing some of the dependencies. In your case check if you can do the same.

Other Possible Reasons:

  • Check if your jar has proper permissions for the system user which is running Tomcat
  • Try to open the file in Zipeg , Winrar, Winzip or any equivalent unzipping system and verify if any of the jar in the classpath is not corrupt. Look for suspiciously smaller sized files

Patching Liferay Source Code

      No Comments on Patching Liferay Source Code

In Liferay development, it’s very useful to have Source Code available to you for the purpose of troubleshooting and debugging. This is especially useful when you get an error in the log on the server with a stack trace and a line number. With the source code, you can always look at the code and investigate in detail the root cause of the error. You can always download the Source Code of your portal from liferay.com and setup with your IDE(this is useful for local debugging with breakpoints)

However, this becomes challenging when you have Liferay EE subscription and you have applied patches to your portal. It is possible that your source code is out-of-date/out-of-sync with your deployed portal code. Luckily, Liferay patching tool provides you a way to patch your source code.

To begin, go to your patching-tool directory

Step 1:

Step 2:

Create a new profile to be used for patching the source code. To achieve this create patch-source.properties under patching-tool directory

In the above example, we have set a patching mode and location of the source code which has to be patched. For more details refer to the documentation or run ./patching-tool.sh help

Step 3

Run the patching tool with the custom profile created in above step. Since the name of our file was patch-source.properties our profile name is patch-source

 

 

Custom Display, Review and Expiry date in Liferay

Recently we had a requirement where we want all our new articles to go live next day, up for review in 6 months and automatically expire in 1 year. Of course, all this can be overriden by content authors at the time of content creation. But these are the defaults we wanted. To achieve this you have to override JournalArticle model hint as defined in portal-model-hints.xml. Here are the defaults in Liferay

To override this you will have to create an ext(unfortunately that’s the only way to go). In your ext’s ext-impl/src/META-INF folder create ext-model-hints.xml. Copy the <model name=”com.liferay.portlet.journal.model.JournalArticle”> section from portal-model-hints.xml and change the relevant settings. here are the changes we made to meet our needs

Multiple files upload in Liferay 6.1

Today I have found a weird bug in Liferay’s UploadServletRequestImpl in the following method

 

The intention of the above code is to return the full name of the file(s) being uploaded. But actually the above code returns the name of the first file uploaded on the form with the name field.

But what if I have multiple files uploads on my form with the same name like this

 

If you upload two files on the above form the following code will always print name of the first file

 

Workaround

You can use uploadPortletRequest.getMultipartParameterMap() to get all the multipart parameters for a parameter name. The following code will print the name of all the files

 

 

JournalVmUtil in Liferay 6.1

      No Comments on JournalVmUtil in Liferay 6.1

Disclaimer – Following is not the best or optimal solution. If you have better suggestion please write in comments

JournalVmUtil was present upto Liferay 5.2 and then deprecated in Liferay 6.0 and then completed removed in Liferay 6.1. If you are upgrading to 6.1 and make extensive use of JournalVmUtil you can do the following.

Extend VelocityTemplateParser.java. Following code example is just a sample. Feel free to add any pre-processing or post-processing as required

 

Now inject MyVelocityTemplateParserImpl in your velocity templates and just call getNodes method like this

 

 

No theme found for specified theme id abc_WAR_xyztheme

As far as my experience is concerned, this error means that your database is referring to theme which is not present. To make sure run the following commands

Now go to liferay’s Control Panel -> Plugin Configuration -> Theme Plugins tab and click on the theme in question. See the
Plugin ID of the theme. It should match what is there in layout and layoutset tables. If it doesn’t then you have to either change themeid or update database tables. If you happen to update DB don’t forget to restart or clear DB cache.