How to deploy a .JAR file to the Liferay on the AWS EC2 instance

Keywords: Liferay - AWS - How to - Plugins installation/configuration

Description:
I have the deployed a Bitnami 7.4.3-4-11 into an EC2 Instance on AWS. I can open the Liferay portal using the link provided.
I developed a simple Hello World Portlet using Liferay Developer Studio deployed and tested it locally. All good.
Now I want to deploy this Hello World portlet into Liferay on EC2.
I did the followings:

  1. Create a .JAR file of the Hello World portlet.

  2. SSH to my Bitnami EC2 instance

  3. Navigate to /opt/bitnami/liferay/deploy folder.

  4. Upload the .JAR file into this deploy folder using scp command

  5. I can see the .JAR file uploaded into the deploy folder.

I am expecting the Auto Deploy will get triggered and processed the .JAR file. And the .JAR fill will be disappeared. But nothing happened, the .JAR file still there.

I also update the portal-ext.properties with these values
auto.deploy.enabled=true
auto.deploy.deploy.dir=/opt/bitnami/liferay/deploy

But, still nothing happened. my portlet is still not deployed into Liferay.

Any suggestion why?
What am I missing?

Cheers,
Neil

Hello @neil,

Thank you for using our solution. Please note that Bitnami packages and configures already existing applications. However, we can only offer support and help on basic and most frequent application configurations. Always based on the default configuration or on our guides.

If the question is related to the application itself or any third party tool, probably someone with more experience and knowledge about that specific tool can help you better than we can. We suggest you to post your question on the official support forums of the application so others can help you.

Do not hesitate to write us back if you have any other questions regarding the Bitnami solutions or their configuration.

Hi David, thanks for your response.

I think my question is about the package itself, not the application.
How to deploy a new module into bitnami running on AWS EC2.

The documentation says that I can just copy my module into the /opt/bitnami/liferay/deploy folder and the liferay will do an auto deployment.

I did that, but it doesn’t seem to be working (everything is using default configuration)

Questions:

  • Does the default configuration do the auto deployment?
  • If not, what configuration I need to ensure in place to make it working?
  • else, what other config I need to check?

Cheers,
Neil

Hi @neil,

Thanks for your message. I couldn’t find our documentation on how to deploy a Liferay module, can you share the link with us?

What I found is a guide for deploying a custom Java application. I’m sharing the link below

https://docs.bitnami.com/aws/apps/liferay/administration/create-custom-application-tomcat/

Apart from that, I built a sample module using the official documentation and copied it to the /opt/bitnami/liferay/deploy folder

https://learn.liferay.com/dxp/latest/en/liferay-internals/fundamentals/module-projects.html#deploy-a-simple-module

I updated the file permissions so it is owned by bitnami user and tomcat group, and the auto-deployment process was started, although the modules seems not to be valid. I got the next lines from the /opt/bitnami/liferay/logs folder

2022-01-10 11:00:56.418 ERROR [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:250] com.liferay.portal.kernel.deploy.auto.AutoDeployException: liferay-k8s2.jar is an invalid module
com.liferay.portal.kernel.deploy.auto.AutoDeployException: liferay-k8s2.jar is an invalid module
        at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.deploy(AutoDeployDir.java:93) ~[portal-kernel.jar:?]
        at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.processFile(AutoDeployDir.java:245) [portal-kernel.jar:?]
        at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.scanDirectory(AutoDeployDir.java:305) [portal-kernel.jar:?]
        at com.liferay.portal.kernel.deploy.auto.AutoDeployScanner.run(AutoDeployScanner.java:67) [portal-kernel.jar:?]

Can you tell us which module are you trying to deploy? Can you also check the content of the log file? I also think that running the bndiagnostic tool can be of help

https://docs.bitnami.com/general/how-to/understand-bndiagnostic/

Hi @gongomgra, thanks for your response.

Basically, we have just deployed the Bitnami into AWS EC2, then created a “Demo” page that I will put my portlet into it.

I created a simple Demo portlet then deployed and tested it in my liferay portal running on my laptop.
To deploy it:

  1. I created .JAR file, in this case com.demo.jar file
  2. I copied the .jar file into the deploy folder on my liferay portal
  3. It’s all running ok, it deploys the .jar file into my portal, and I can put that portlet into the page.

The same .jar file I copied into bitnami running on AWS EC2.
I followed you instruction to change the permission, and now it can deploy, but I got this error

2022-01-12 01:31:21.359 ERROR [ajp-nio-127.0.0.1-8009-exec-5][render_portlet_jsp:77] null
java.io.FileNotFoundException: /opt/bitnami/liferay/work/com.demo-1.0.0/org/apache/jsp/view_jsp.java (No such file or directory)

  • at java.io.FileOutputStream.open(FileOutputStream.java:298) ~[?:?]*
  • at java.io.FileOutputStream.(FileOutputStream.java:237) ~[?:?]*
  • at java.io.FileOutputStream.(FileOutputStream.java:126) ~[?:?]*

I also run the bndiagnostic tool and uploaded to your server

Here is the number:
2decb17d-a2be-d700-d958-56f17c758d60

Questions:

  1. Why did I get the FileNotFoundException? which never happen on my local
  2. Can you see anything on the bndiagnostic tool report I uploaded to your server?

Please advice,

Neil

Hi @neil,

Thanks for your message. I found the next lines in the Tomcat log related to your JAR file plus the error message you are getting.

2022-01-12 00:21:02.774 INFO  [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:238] Processing com.demo.jar
2022-01-12 00:21:12.237 INFO  [fileinstall-directory-watcher][BundleStartStopLogger:46] STARTED com.demo_1.0.0 [1452]
2022-01-12 00:22:30.637 WARN  [ajp-nio-127.0.0.1-8009-exec-7][PortalImpl:1044] Redirect URL https://34.192.211.74/demo is not allowed
2022-01-12 00:22:53.186 INFO  [ajp-nio-127.0.0.1-8009-exec-9][DemoPortlet:56]  This is render method of DemoPortlet
2022-01-12 00:22:53.187 INFO  [ajp-nio-127.0.0.1-8009-exec-9][DemoPortlet:49]  This is doView method of DemoPortlet
2022-01-12 00:22:56.396 ERROR [ajp-nio-127.0.0.1-8009-exec-9][PortletRequestDispatcherImpl:304] Unable to dispatch request: java.io.FileNotFoundException: /opt/bitnami/liferay/work/com.demo-1.0.0/org/apache/jsp/view_jsp.java (No such file or directory)

Unfortunately, the bndiagnostic tool didn’t get any information from the liferay folder (I have notified our engineering team to fix that in a future release of the tool), can you check if the file exists and its permissions? Does any of the folders under /opt/bitnami/liferay path exists as well?

sudo ls -lart /opt/bitnami/liferay/work/com.demo-1.0.0/org/apache/jsp/view_jsp.java

Apart from that, I’m afraid I don’t know how Liferay deploys those custom modules internally, but it looks like the auto-deployment feature is working. Can you check this error in the Liferay community? I understand they can provide you with more details on how to debug it.

https://liferay.dev/

Hi @gongomgra,

I cannot find any folder named as work under /opt/bitnami/liferay path.

It looks like the auto deployment failed to create work folder and any files and folder in it.
Is this something to do with permission?

I don’t think the auto deployment is working as expected.
It deploys the module, but not the one under the work folder. It fails to create this folder and its content.

Cheers,
neil

FYI. auto deployment works on my local liferay (installed on my macbook)

but it doesn’t work on liferay installed on AWS EC2

Hi @neil,

Thanks for your message. I launched a fresh new instance and checked the permissions. I think it can be related to permissions, yes, as the tomcat group doesn’t have writing permissions for the /opt/bitnami/liferay folder.

$ ls -lart /opt/bitnami/ | grep liferay
drwxr-xr-x  9 bitnami tomcat  4096 Jan 13 09:46 liferay

Can you check if updating the permissions it allows the auto-deployment process to create the missing directories?

sudo chmod 775 /opt/bitnami/liferay

Hi @gongomgra

I change the permission of the liferay as per suggestion
sudo chmod 775 /opt/bitnami/liferay

But, I also need to change the permission of .JAR file
sudo chmod 777 /opt/bitnami/liferay/deploy/com.demo.jar

Now it works!

Thanks @gongomgra

Hi @neil,

Thanks for the info. I’m glad you fixed your issue! We will close this thread as solved. Please do not hesitate to open a new one with any other questions you may have.