Showing posts with label tomcat. Show all posts
Showing posts with label tomcat. Show all posts

Thursday, January 16, 2014

Liferay: Custom 404 Page for plugins

Liferay portal runs and is configured as ROOT application with in tomcat sever.
By default, if tried to request a plugin in Liferay (say we have a theme plugin named as "error-theme"), a 404 Error is raised and the user is served Tomcat's default 404 error page as below:


To make your 404 page a bit more presentable, provide the user with a link back into your site, as well as hide the Tomcat version in use, you can easily add a custom 404 error page.

Step 1:

Create a jsp name it 404.jsp, with below content:


The requested resource is not available. Please provide the correct URL or try again later.
<br/>
<a href="#" onclick="javascript:history.go(-1);">Go back to main site.</a>

Step 2:

Now create a new directory as error-theme/docroot/errors in Lifeay IDE and copy the above created 404.jsp to it.

Step 3:

Last step is to add the below code to the web deployment descriptor (web.xml) of the plugin:

         <error-page>
  <error-code>404</error-code>
  <location>/errors/404.jsp</location>
 </error-page>

Now, when someone goes to the plugin link that does not exist, they get the custom 404 page we created.





Thursday, June 27, 2013

Liferay 6: Monitoring tomcat.

The Liferay tomcat bundle is available for download on http://www.liferay.com/downloads/liferay-portal/available-releases and instant use. It ships pre-configured with hypersonic database and you can switch to mysql, oracle, etc for permanent solutions.

When moving your site or solution to production server there is always uncertainty on how much the load will be coming at peak time, how many request the tomcat will be able to server with Liferay. Although the Apache tomcat comes with tomcat-manager application that allows you to monitor all the resources via JMX beans. but since this have been removed in Liferay-tomcat bundle thus it is hard to monitor the resources and threads the tomcat server is consuming. Thus to over come this shortcoming, below are the steps to enable the monitoring in the tomcat:

Server Details
Liferay: 6.1.2 GA2 Enterprise
Tomcat Bundle: 7.0.27
Java 6

Step 1:
Stop the running Liferay tomcat server and clean the temp and work folder.

Step 2:
Download the vanilla apache tomcat server of the same version and unzip it at some temporary location.

Step 3:
Copy host-manager and manager application <tomcat>/webapps directory to liferay installation at <liferay-tomcat-bundle>/tomcat-7.0.27/webapps

Step 4:
Create a manager.xml file at location <liferay-tomcat-bundle>/tomcat-7.0.27/conf/Catalina/localhost.
And the following content to it and save it

<Context antiResourceLocking="false" privileged="true" useHttpOnly="true">
 
 </Context>
Step 5:
Now open file <liferay-tomcat-bundle>/tomcat-7.0.27/conf/tomcat-users.xml in edit mode. And the below content inside the tag <tomcat-users>.

<tomcat-users>
...

  <role rolename="tomcat"/>
  <role rolename="manager-gui"/>
  <role rolename="standard"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="tomcat" password="tomcat" roles="manager,admin,standard,manager-gui,tomcat"/>

...
</tomcat-users>

Step 6:
Now restart the tomcat server and go to the URL: http://localhost:8080/manager/html and you will be prompted for username and password which should be the same as defined above.



And now you can monitor the tomcat resources and can tune them accordingly.



Thursday, June 07, 2012

Liferay Tomcat Performance

Motive

To get performance improvement in terms of time taken by liferay tomcat to start.

Solution

Tomcat's core libraries are available in Java Byte code normally. Apache Tomcat Native Library is a Java Native Interface that provide most of the core functionality in native code. Using these libraries only mean one thing to you and i.e. SPEED.
 For Windows
  1. Download http://archive.apache.org/dist/tomcat/tomcat-connectors/native/1.1.15/binaries/win64/x64/
  2. Copy tcnative-1-ip4.dll to %TOMCAT_HOME%/bin
  3. Restart Tomcat and check the tomcat startup performance.