Krishnamohan Meduri's weblog
Thursday Feb 07, 2008
View exception stack in browser instead of "Server Error" with SJS Web Server 7.0 Update 2
Are you an application developer using SJS Web Server 7 Update 2?
Now you can see exception stack in browser itself. You don't need to go through error log to see what's wrong with the JSP page.
In Web Server releases prior to 7.0 Update 2, when an exception occurs in the servlet container at the request time, a "Server Error" is displayed in browser without exposing internal application details and the exception is logged in the error log. This is what is wanted for production environment. However, displaying exception details in browser would save quite some time for developers (in development environment) as they don't have to dig through the error log for trivial errors in their applications. A simple example could be an invalid JSP standard action in a JSP page. This would throw a "Server Error" at the request time and it could be caused b/c of a simple typo.
In Sun Java System Web Server 7.0 Update 2 release, the "Display Exception" functionality was added to address this concern. By default, this functionality is disabled. You can enable it using administration CLI or GUI. In this blog, I'll show below how to enable this functionality using Administration GUI.
1) Start the admin server.
<WS7_INSTALLATION_DIR>/
admin-server/bin/startserv2) Open https://localhost:8989/ from browser and Log into Admin console. (if you are running admin server locally)
3) From the Home page, Click "Edit Java Settings"
4) Select "Servlet Container" tab and enable "Display Exception" check box.
5) Click "Save" and then click "Deployment pending" link.
6) Now that you enabled "Display Exception" feature, for a error such as
<jsp:include path="foo.jsp" /> in a JSP page, you will see below
exception stack in the browser which otherwise would have been "Server
Error".
This is intended for development environment only. Please turn off this functionality for production environment
Posted at 06:00PM Feb 07, 2008 by kmeduri in Personal | Comments[0]
Wednesday Feb 06, 2008
Run Liferay Portal on Sun Java System Web Server 7 Update 2
Prerequisites
1. Create a directory say C:\Liferay (or /home/userid/Liferay).
2. Go to http://www.liferay.com/web/guest/downloads/additional and download
- "Liferay Portal 4.4.0 WAR (Servlet 2.4)" file to say C:\Liferay.
- "Liferay Portal 4.4.0 Dependencies" file and unzip to say, C:\Liferay\dependencies.
- "Liferay Portal 4.4.0 SQL Scripts" file and unzip to say, C:\Liferay\sql.
- "Liferay Plugins SDK 4.4.0" file and unzip to say, C:\Liferay\sdk.
- optionally other files like Java documentation etc.
For this blog, I downloaded MySQL JDBC driver from http://dev.mysql.com/downloads/connector/j/5.1.html and used mysql-connector-java-5.1.5-bin.jar.
4. Download Java Transaction API classes (
jta-1_1-classes.zip) from
http://java.sun.com/products/jta/5. Have "Java Message Service API classes" (jms.jar) ready.
(Note: I could not find any link to download "Java Message Service API classes". However I found
jms.jar in
liferay-portal-tomcat-5.5-jdk5-4.4.0 installation that I got from
http://www.liferay.com/web/guest/downloads/portal.
I also found these classes in javaee.jar in glasfish.)Database Setup
1. Login as administrator into your Database Server
2. Any of create-minimal-*.sql scripts in the C:\Liferay\sql\create directory drops and creates database named
lportal, creates all
necessary tables and indexes and loads the minimal necessary data.
create-*.sql does the same and additionally loads example data. Select
either of them suitable for your database server (e.g.
create-mysql.sql) and run the script.mysql>source create-mysql.sqlNote: Preferably create a separate database user and grant it SELECT, INSERT, UPDATE, and DELETE permissions on all tables in the
lportal
database.Sun Web Server configuration
1. Stop the Web Server instance if it is running.
https-<config>\bin\stopserv2. Copy the following list of JAR/Zip files to the Web Server's
https-<config>\lib (Create lib directory if it does not exist).- JAR files files under C:\Liferay\dependencies\liferay-portal-dependencies-4.4.0
xercesImpl.jarfile under C:\Liferay\sdk\lib- JDBC driver for your database
jta-1_1-classes.zipjms.jar
https-<config> directory as <instance-dir> in this blog.3. Start Web Server's Administration Server and make required changes to the configuration using Administration CLI
wadm.- Start Administration server
admin-server\bin\startserv- Log into
wadmas administrator
- List available configurations and choose one. Following commands assume <config> as the configuration.
wadm> list-configs- Create a mail resource with the JNDI name
mail/MailSession
wadm> create-mail-resource
--config=<config> mail/MailSession- Create a JDBC resource with the JNDI name
jdbc/LiferayPool. (Note: In below command, replace MySQL datasource class wth the datasource class for your database)
wadm> create-jdbc-resource
--config=<config>
--datasource-class=com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
jdbc/LiferayPool- Set JDBC resource user properties viz. user, password, url for the JDBC resource (Note: In below command, replace MySQL url with the url for your database)
wadm> create-jdbc-resource-userprop
--config=<config> --jndi-name=jdbc/LiferayPool user=<user>
password=<password> url="jdbc:mysql://localhost/lportal"- Enable connection validation
wadm> set-jdbc-resource-prop
--config=<config> --jndi-name=jdbc/LiferayPool
connection-validation-table-name=<config>
connection-validation=table- Deploy the liferay web application and make it the default web application for the instance. Here you have an option not to precompile JSP pages.
a) If you choose to precompile, it may
take 15-20 minutes (depending on machine configuration) to precompile
600+
JSP pages of Liferay application but the application loading and
response time will be faster.
To deploy with the precompile option,
To deploy with the precompile option,
wadm> set-jvm-prop
--config=<config>
class-path-suffix=<instance-dir>/lib/jms.jar; \<instance-dir>/lib/jta-1_1-classes.zip;<instance-dir>/lib/xercesImpl.jar;
\<instance-dir>/lib/portal-kernel.jar;<instance-dir>/lib/portal-service.jar;
\<instance-dir>/lib/portlet.jar;<instance-dir>/lib/<jdbc-driver-jar>wadm> add-webapp
--config=<config> --vs=<config> --uri=/ --precompile-jsp
liferay-portal-4.4.0.warb) If you don't precompile, the deploy
is quick but the application loading and response time will be
slow.
To deploy without precompile option,
To deploy without precompile option,
wadm> add-webapp
--config=<config> --vs=<config> --uri=/
liferay-portal-4.4.0.war- Deploy the configuration changes. This also may take time.
wadm> deploy-config <config>4. Start the Web Server instance
https-<config>\bin\startservIn your browser, Go to http://localhost:8080 if you are running the instance locally.
Posted at 06:54PM Feb 06, 2008 by kmeduri in Personal | Comments[4]