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/startserv

2) 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

Wednesday Feb 06, 2008

Run Liferay Portal on Sun Java System Web Server 7 Update 2

Run Liferay Portal on Sun Java System Web Server Here are the steps to run Liferay Portal on Sun Java System Web Server 7.0 Update 2. Let me divide the steps into 3 parts. First you need to download several Liferay bundles and unzip them. Then, you need to setup your Database Server. Then, you have to configure Web Server for running Liferay Portal

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.
3. Have the JDBC driver ready for your database server.
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.sql

Note: 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\\stopserv

2. 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.jar file under C:\\Liferay\\sdk\\lib
  • JDBC driver for your database
  • jta-1_1-classes.zip
  • jms.jar
    Note: I will refer to Web Server's 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 wadm as 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,

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.war

b) If you don't precompile, the deploy is quick but the application loading and response time will be slow.

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\\startserv

In your browser, Go to http://localhost:8080 if you are running the instance locally.

Thursday Dec 06, 2007

Running Metro on SJS Web Server 7 Update 1

Recently I found that one can run Metro on SJS Web Server 7.0 Update 1 in minutes. If you want to give it a try, following steps would help you get going:

Set up SJS Web Server:
  • Download Metro bundle and unzip it say, under USER_DIR. I will refer to USER_DIR/metro as METRO_HOME.

  • SJS WS 7.0 Update 1 bundles JAX-WS 2.0 libraries. Therefore you need to override them with the latest libraries from Metro. For this, use wadm set-jvm-prop CLI command to set its class-path-prefix property to the jar files under METRO_HOME/lib directory.

    For example,

    $cd WS7_INSTALL_DIR/bin
    $./wadm --user=admin_user --password-file=admin_passwd_file

    wadm> set-jvm-prop --config=<config> class-path-prefix=METRO_HOME/lib/webservices-api.jar: METRO_HOME/lib/webservices-extra-api.jar:METRO_HOME/lib/webservices-extra.jar: METRO_HOME/lib/webservices-rt.jar:METRO_HOME/lib/webservices-tools.jar

    wadm> deploy-config <config>

    For more details on SJS Web Server's administration command line tool wadm, please refer to the first two sections of my SDN article on SJS Web Server.

    Note: When you set class-path-prefix, make sure you don't have one already set. If you already have one set, append its value to the above command so you won't lose it. Use the appropriate path separator (: for unix and ; for windows) for class-path-prefix value.
Run Metro sample (mtom):
  • Set METRO_HOME environment variable. For example,
         bash$export METRO_HOME=USER_DIR/metro

  • Build the war file.

    $cd METRO_HOME/samples/mtom
    $ant server


    This target builds jaxws-mtom.war under METRO_HOME/samples/mtom/build/war directory.

  • Add this web application to the configuration and deploy changes to all instances.

    wadm> add-webapp --config=<config> --vs=<vs> --uri=/jaxws-mtom METRO_HOME/samples/mtom/build/war/jaxws-mtom.war

    wadm> deploy-config <config>


  • Start the instance.

    $cd WS7_INSTALL_DIR/https-<hostname>/bin
    $./startserv


    (At this point, you can find the endpoint details at http://<host>:<port>/jaxws-mtom/mtomsample)

  • Build and run the client.

    $cd METRO_HOME/samples/mtom
    $ant client run


    Note: This client assumes that the server is running on port 8080. If the server port is different, you must modify the port in its build.xml appropriately.


Monday Oct 02, 2006

Want to run Sun Java System Web Server 7.0 Technology Preview 3 with Java EE 5 Web Container ?

If you want to run Sun Java System Web Server 7.0 Technology Preview 3 with Java EE 5 compliant web container from Project Glassfish, you can do so. As it stands today, it has a few known issues and hence is good for experimental purpose only.

Here are the steps:

1. Download and install Web Server 7.0 Technology Preview 3.

2. Checkout and build web container from project glassfish

    Prerequisites to building GlassFish
  • The user must have Maven v1.0.2 and JDK 5.0 (Java SE Development kit) installed.
  • The user must have a login on java.net and must have access to the CVS repository for the GlassFish project.
    Build instructions

     $mkdir workspace
     $cd workspace
     $cvs -d :pserver:<userid>@cvs.dev.java.net:/cvs checkout -r PWC12Dev_Branch glassfish/bootstrap

Create  workspace/glassfish/bootstrap/build.properties -or-
one-time process is to create ${HOME}/build.properties (Unix)  or %HOMEPATH%\\build.properties (Windows) and set the following variables:
    glassfish.os.name= <Possible values:WINNT, SunOS, Linux, SunOS_X86 or Darwin>
    glassfish.cvs.username= <java.net id>

     $cd glassfish/bootstrap
     $maven checkout-pwc bootstrap-pwc build-pwc

         Note: These targets checkout, bootstrap and build only those components that are relevent to web container.
 
3. Modify the Web Server 7.0 installation to use the Java EE 5 compliant web container binaries from project glassfish

     $cp workspace/publish/pwc/pwc.jar WS7_INSTALL_DIR/lib/pwc.jar
         $cp workspace/publish/pwc/appserv-jstl.jar WS7_INSTALL_DIR/lib/webserv-jstl.jar

Monday Aug 07, 2006

How to deploy a war file on Sun Java System Web Server 7 using its Admin console


1) Start the admin server. To do so,
cd WS7_INSTALLATION_DIR/admin-server/bin (where WS7_INSTALLATION_DIR is the installation directory)
./startserv (On unix or startserv.bat on Windows)
2) Open https://localhost:8989/ from browser (assuming admin server is running on localhost with default settings)
3) You will see Admin Console's login page. Once you login, You will see



Click Add Web Application to see the next page.
Type appropriate values in Location and URI text fields



4) Click OK to see the next page.
5) Click Deployment Pending link on the top right corner to see the next page.
6) Click Deploy and then Close.

Run Apache Lenya on Sun Java System Web Server 6.1

Apache Lenya is an Open Source Java/XML Content Management System that comes with revision control, site management, scheduling, search, WYSIWYG editors, and workflow.

You can run this application on Sun Java System Web Server 6.1. Before I get to the steps to do so, let's first decide on some terminology:

  WS61_INSTALL_DIR specifies Sun Java System Web Server 6.1 installation directory.
  LENYA_HOME specifies the directory where Lenya binary (tar or zip) is extracted
  LENYA_WEBAPP_HOME specifies the directory where LENYA_HOME/lenya.war is extracted.

Steps to setup and run Lenya on SJS WS 6.1:

1. Download Apache Lenya 1.2.4 binary from http://lenya.apache.org/ and extract the tar or zip.
2. Create a new directory named endorsed under WS61_INSTALL_DIR/bin/https/jdk/jre/lib
3. Copy the following three jar files from LENYA_WEBAPP_HOME/WEB-INF/lib to WS61_INSTALL_DIR/bin/https/jdk/jre/lib/endorsed
       xalan-2.6.1-dev-20041008T0304.jar  
       xml-apis.jar
       xercesImpl-2.6.2.jar
(I am not sure what will be the side effects of this change. But to get Lenya running, this is a necessary step. Lenya seems to depend on these jars heavily.)
4. Deploy LENYA_HOME/lenya.war to Web Server instance with say /lenya as uri.
5. Start the web server instance and visit http://hostname:port/lenya in your browser. This shows the index page of Lenya.

To experiment, you can click "Lenya's Weblogs" link and create blogs.
From Lenya home page, you can also click "Default Publication" and open WYSIWYG Editors and do much more.

To my surprise, Apache Lenya sometimes throws some errors. I observed the same errors with jetty also which is a container bundled with Lenya binaries.

Monday Jun 19, 2006

Migrating Web Applications From Apache Tomcat 5.x to Sun Java System Web Server 7.0

Recently Marina Sum (SDN staff writer) and I wrote an article Migrating Web Applications From Apache Tomcat 5.x to Sun Java System Web Server 7.0. I tried to introduce users to Sun Java System Web Server 7.0's (SJS WS7.0) new administration CLI. I tried to explain with examples how to add users to a file realm, how to configure JDBC DataSource with JNDI, and how to configure SSL in Sun Java System Web Server 7.0. Take a look at it. Apache Tomcat users who want to try SJS WS 7.0 Technology Preview 1 will find this article useful.
About

kmeduri

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today