|
By Seema Alevoor, March 30, 2006
|
|
|
Note: Also see a March 16, 2007 article, Running
Roller Weblogger on Sun Java System Web Server 7.0.
This article lists the steps to install Roller Weblogger 2.0 or 2.1.1 on Sun Java System Web
Server 6.1 SP5 (hereafter Web Server 6.1 SP5) with MySQL 4.x. As you know, Roller is a
popular open source Web application, written in the Java programming language, that
supports multiple, simultaneous weblog users and visitors. You might enjoy a trip to Roller's Web site.
Contents
Setting Up
Before you begin, be sure your system hosts
- Web Server 6.1 SP5 (JDK version 1.4.2); download and install it now if necessary.
- A MySQL database
- A configured MySQL
With the preceding in place, establish Roller on your system as follows:
1. Download
the Roller 2.0 application and unpack the ZIP or TAR file into a temporary directory.
On UNIX:
% cp roller-2.0-incubating.tar.gz roller_temp_dir
% cd roller_temp_dir
% tar xzvf roller-2.0-incubating.tar.gz
|
where roller_temp_dir could be /tmp
On Windows:
Use winzip to extract roller-2.0-incubating.zip into roller_temp_dir
where roller_temp_dir could be C:\tmp
This article assumes /tmp for UNIX and C:\tmp for Windows as the roller_temp_dir.
2. Follow the steps in Roller's Install Guide to create Roller tables in your database.
Now it's time for Web Server and Roller to meet.
Configuring Roller 2.0 for Web Server 6.1 SP5
This section describes six tasks:
- Download and install the JDBC driver
.jar file.
- Configure the JDBC connection pool.
- Create and configure a JDBC resource.
- Customize JDBC Security Realm
.jar file.
- Add a JDBC realm (and make it the default realm if you so choose).
- Edit
login.conf.
For these tasks we use the terminology from the Roller installation example: user Scott with password tiger; database, roller; and so forth.
Download, Install, and Set Up the JDBC Driver JAR File
Copy the JDBC driver.jar file, for example, mysql-connector-java-3.0.17-ga-bin.jar), of MySQL Connector/J to webserver_install_path/bin/https/jar.
Here's how you add the .jar file to Web Server's class path.
1. Log in to the Administration GUI and select a server instance.
2. Click the Java tab.
A pane like that shown in Figure 1 is displayed.
 |
|
Figure 1: Adding a .jar File to Web Server's Classpath
|
- Click the JVM Path Settings link on the left.
- Type the JDBC driver
.jar path in the Classpath Suffix text field.
- Click OK, and click Apply to save the settings.
Configure the JDBC Connection Pool
1. Log in to the Administration GUI and select a server instance.
2. Click the Java tab.
A pane like that shown in Figure 2 is displayed.
 |
|
Figure 2: Adding a JDBC Connection Pool
|
- Click the JDBC Connection Pools link on the left.
- Click the New button to add a new connection pool.
- For MySQL, select Other for Database Vendor. Click Next.
- In the Add New JDBC Connection Pool pane, specify the required values.
 |
Pool Name |
mysql40
|
DataSource Classname |
com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
|
|
Properties |
serverName |
localhost
|
portNumber |
3306
|
User |
scott
|
Password |
tiger
|
databaseName |
roller
|
Note: The Pool Settings in Figure 2 are the defaults.
3. Click OK, and click Apply to save the settings.
Create a JDBC Resource
1. Log in to the Administration GUI and select a server instance.
2. Click the Java tab.
A pane like that shown in Figure 3 is displayed.
 |
|
Figure 3: Adding a JDBC Resource
|
- Click the JDBC Resources link on the left.
- Click New to add a new resource.
- Specify the required values.
 |
JNDI Name |
jdbc/rollerdb
|
Pool Name |
mysql40
|
Data Resource Enabled |
on
|
3. Click OK, and click Apply to save the settings.
Customize a JDBC Security Realm JAR File
Copy the JAR file for JDBC Security Realm modified for Roller to web_server_install_path/bin/https/jar.
1. Log in to the Administration GUI to add the JAR file to the Web Server's class path, and select a server instance.
2. Click the Java tab.
A pane like that shown in Figure 4 is displayed.
 |
|
Figure 4: Customizing a JDBC Security Realm JAR File
|
- Click the JVM Path Settings link on the left.
- Type the JDBC security realm JAR file (
jdbcrealm.jar) path in the Classpath Suffix text field.
See Appendix A for information about how to create jdbcrealm.jar for Web Server 6.1 SP5.
- Click OK, and click Apply to save the settings.
Add a JDBC Realm
1. Log in to the Administration GUI and select a server instance.
2. Click the Java tab.
A pane like that shown in Figure 5 is displayed.
 |
|
Figure 5: Adding a JDBC Realm
|
- Click the Security Realms link on the left.
- Click New to add the realm.
- Specify the required values.
 |
Realm Name |
jdbc
|
Classname |
samples.security.jdbcrealm.JDBCRealm
|
|
Properties |
dbusername |
scott
|
dbpasswd |
tiger
|
dbdrivername |
com.mysql.jdbc.Driver
|
dburl |
jdbc:mysql://localhost:3306/roller?autoReconnect=true
|
usertable |
rolleruser
|
roletable |
userrole
|
usernamecol |
username
|
userpasswdcol |
passphrase
|
usergroupcol |
rolename
|
jaas-context |
jdbcRealm
|
- Click OK, and click Apply to save the setting.
This realm can either be configured as the default realm in server.xml or be specified in web.xml (see Appendix B) of the Roller application.
To add this realm as the default realm:
1. Log in to the Administration GUI and select a server instance.
2. Click the Java tab.
A pane like that shown in Figure 6 is displayed.
 |
|
Figure 6: Setting the Realm as the Default
|
- Click the Java Security link on the left.
- Select jdbc as the Default Realm.
- Click OK, and click Apply to save the settings.
Edit login.conf
Add the following lines to the login.conf file in the webserver_instance_root/config directory.
jdbcRealm {
samples.security.jdbcrealm.JDBCLoginModule required debug=false;
};
|
Deploying Roller to Web Server 6.1 SP5
Before deploying Roller to Web Server 6.1 SP5, do three things:
- Edit
web.xml.
- Edit or create
sun-web.xml.
- Create a Web archive (WAR) file.
For web.xml editing, refer to Appendix B.
Here is the code you use to create the sun-web.xml file in the /tmp/roller/WEB-INF directory.
sun-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Sun ONE Web Server 6.1 Servlet 2.3//EN'
'http://www.sun.com/software/sunone/appserver/dtds/sun-web-app_2_3-1.dtd'>
<sun-web-app>
<security-role-mapping>
<role-name>editor</role-name>
<principal-name>roller</principal-name>
<group-name>editor</group-name>
</security-role-mapping>
<resource-ref>
<res-ref-name>jdbc/rollerdb</res-ref-name>
<jndi-name>jdbc/rollerdb</jndi-name>
</resource-ref>
</sun-web-app>
|
Create the WAR file as follows:
% cd /tmp/roller
% jar cvf .../roller.war *
|
Now deploy temp_dir/roller.war to Web Server 6.1 SP5!
- Log in to the Administration GUI and select a server instance.
- Click the Virtual Server Class tab.
- Select a virtual server class and click the Manage button.
- Click the required virtual server.
- Click the Web Applications tab.
A pane like that shown in Figure 7 is displayed.
 |
|
Figure 7: Deploying Roller to Web Server 6.1 SP5
|
- Click the Deploy Web Application link on the left and specify the required information as shown in Figure 7.
- Specify
/roller for the Application URI.
- Click OK to deploy.
Restart Web Server 6.1 SP5 and verify that the application is working by accessing http://localhost:WebServer-port/roller.
Configuring Roller 2.1.1 for Web Server 6.1 SP5
The configuration changes are the same as those for Roller 2.0 on Web Server 6.1 SP5 with these exceptions:
- The Roller 2.1.1 Web application is named
roller-2.1.1-incubating.tar.gz. Download
it and unpack the ZIP or TAR file into a temporary directory, as described in "Setting
Up."
- Roller 2.1.1 uses Acegi Security framework-hence, no custom JDBC-realm-related settings. So ignore the following steps from Roller 2.0 on Web Server 6.1 SP5; they are not required.
- Customize the JDBC Security Realm JAR file.
- Add a JDBC Realm.
- Edit the
login.conf file.
Roller 2.1.1 requires JDK 1.5.X, but Web Server 6.1 SP5 by default points to JDK 1.4.X within Web Server's install directory. Web Server picks up the JDK path information from two places: from server.xml file within webserver_instance_dir/config directory or from wsenv in webserver_install_dir/bin/https/bin directory. To use JDK 1.5.X, change the files as follows.
 |
server.xml: (all on one line)
<JAVA *javahome="webserver_install_dir/bin/https/jdk"*> serverclasspath="..."... >
|
server.xml: (all on one line)
<JAVA *javahome="JDK1.5.X_path" *serverclasspath="..."... >
|
wsenv: (all on one line)
WS_JAVA=*webserver_install_dir/bin/https/jdk*; export WS_JAVA
|
wsenv: (all on one line) WS_JAVA = JDK1.5X path; export WS_JAVA
|
- In addition to the
web.xml changes described in Appendix B, add the following lines in web.xml to register the ContextLoaderListener listener.
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
|
Appendix A: Custom JDBC Realm
The JDBC realm program for Roller can be made from the sample program in Web Server 6.1. Download the sample (in HTML) used for modification. The code lines you must change appear in blue-bold in the code file; these changes are required for the Roller application.
After modifying the code of JDBCLoginModule.java, follow the sample's tutorial steps (in web_server_install_path/plugins/java/samples/webapps/security/jdbcrealm) to build the JDBC Realm JAR file (jdbcrealm.jar).
Appendix B: web.xml Changes for Web Server 6.1 SP5
web.xml of the Roller application requires the following changes on Web Server 6.1 SP5.
Note: If you are running Roller 2.1.1, don't forget to register the ContextLoaderListener listener.
Note: "dispatcher" elements should be commented out for Servlet API 2.3 containers like Web Server 6.1.
<web-app >
<display-name>Roller Weblogger</display-name>
.
.
.
<!-- Ensures character encoding set to UTF-8 and JSTL and Struts locales are in sync.
Note: Any filters preceding this one MUST not cause request parsing. -->
<filter-mapping>
<filter-name>CharEncodingFilter</filter-name>
<filter-mapping>
<filter-name>CharEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
<!-- This filter-mapping is there only in Roller 2.1.1 -->
<!-- Acegi Security filters - controls secure access to different parts of Roller -->
<filter-mapping>
<filter-name>securityFilter</filter-name>
<url-pattern>/*</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
.
.
.
<!-- Map everything to the PersistenceSessionFilter.
NOTE: Any filters preceding this one MUST NOT use persistence sessions.-->
<filter-mapping>
<filter-name>PersistenceSessionFilter</filter-name>
<url-pattern>/*</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
.
.
.
<!-- This filter-mapping is there only in Roller 2.0 -->
<!-- RememberMe Filter -->
<filter-mapping>
<filter-name>loginFilter</filter-name>
<url-pattern>/login.jsp</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
.
.
.
<!-- "dispatcher" elements are there only in Roller 2.1.1 -->
<!-- Main Page Caching -->
<filter-mapping>
<filter-name>MainPageCacheFilter</filter-name>
<url-pattern>/main.do</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
<!-- "dispatcher" elements are there only in Roller 2.1.1 -->
<!-- Planet Roller Caching -->
<filter-mapping>
<filter-name>PlanetCacheFilter</filter-name>
<url-pattern>/planet.do</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
.
.
.
<!-- "dispatcher" elements are there only in Roller 2.1.1 -->
<filter-mapping>
<filter-name>RequestFilter</filter-name>
<url-pattern>*.do</url-pattern>
<!--
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
-->
</filter-mapping>
<!-- This listener is required only for Roller 2.1.1 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--
To use non XDoclet listeners, create a listeners.xml file that
contains the additional listeners and place it in your
project's merge dir.
-->
<listener>
<listener-class>org.roller.presentation.RollerSession</listener-class>
</listener>
.
.
.
<!-- Login and login error pages -->
<login-config>
<!-- RESIN_AUTHENTICATOR -->
<auth-method>FORM</auth-method>
<!-- Refer to JDBC Realm Settings, not required in case of Roller 2.1.1 -->
<realm-name>jdbc</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/loginerror.jsp</form-error-page>
</form-login-config>
</login-config>
.
.
.
</web-app>
|
|