Monday, March 5, 2007

Roller v3.0 on WebLogic v9.2

After some tinkling, I managed to get Roller v3.0 running on WebLogic 9.2 as well. So here's the steps.


Preparation
1) Download source code for Roller v3.0.
2) Create a temp folder (we shall named it as {temp} from here onwards). Place downloaded source code in '{temp}\roller'.
3) Create a new Dynamic Web Project in WLP 9.2 named 'roller'. Use the default settings for Project Facets selection. Change 'Content Directory' to 'roller' (We will refer to the application directory as 'roller' from here onwards).
4) Rename '{roller}\roller\WEB-INF\web.xml' to '{roller}\roller\WEB-INF\web.bak'
5) Rename '{roller}\roller\index.jsp' to '{roller}\roller\index.bak'. (in case you want to keep it for later).
 
First compilation of roller
(The steps for compiling roller is still the same as before).
 

Setup WebLogic roller
1) Remove the additional filter added by XDoclet.

<filter>
<filter-name></filter-name>
<filter-class>org.apache.roller.ui.webapp.RollerAuthenticationProcessingFilter</filter-class>
</filter>


2) Copy '{roller}\roller\WEB-INF\classes\META-INF\tlds\roller.tld' to '{roller}\roller\WEB-INF'.
3) Open up '{roller}\roller\jsps\tiles\search.jsp', under line 37, change the special character '»' to '&raquo;'.
4) Amend '{roller}\roller\jsps\authoring\spellcheck-entry.jsp' and add the following.
  (Hint: Paste after the </script> tag.)
  <%!
  public static String makeSelect(String word, List words)
  {
    StringBuffer buf = new StringBuffer("<select name=\"");
    buf.append("replacementWords\"style=\"font-size: 10px;\">");
    buf.append("<option selected=\"selected\" value=\"").append(word);
    buf.append("\">").append(word).append("</option>");
    if (words == null || words.size() < 1)
    {
      buf.append("<option value=\"").append(word);
      buf.append("\">No Suggestions</option>");
    }
    else
    {
      for (Iterator it2=words.iterator(); it2.hasNext();)
      {
        word = it2.next().toString();
        buf.append("<option value=\"").append(word);
        buf.append("\">").append(word).append("</option>");
      }
    }
    buf.append("</select>");
    return buf.toString();
  }
  %>
 
  (Hint: Paste after the 'Use Spell Check Results' wordings.)
  <%
    String escapeText = StringUtils.replace( text, "<", "{" );
    escapeText = StringUtils.replace( escapeText, ">", "}" );
    StringBuffer newText = new StringBuffer(escapeText);
    ArrayList events = (ArrayList) session.getAttribute("spellCheckEvents");
    SpellCheckEvent event = null;
    String word = null;
    int start = -1;
    int end = -1;
    String select = null;
    for(ListIterator it=events.listIterator(events.size()); it.hasPrevious();)
    {
      event = (SpellCheckEvent)it.previous();
      word = event.getInvalidWord();
      start = event.getWordContextPosition();
      end = start + word.length();
      select = makeSelect(word, event.getSuggestions());
 
      newText.replace( start, end, select );
    }

    escapeText = StringUtils.replace(newText.toString(), "}", "&gt;" );
    escapeText = StringUtils.replace(escapeText, "{", "&lt;" );
  %>

5) Create the necessary datasource with JNDI name, jdbc/rollerdb" as well as the mail session with JNDI name mail/Session" in WebLogic console.

6) Amend the line, "${catalina.base}/logs/roller.log" in '{roller}\roller\WEB-INF\classes\log4j.properties' to the right place where you want your log to be.

7) Next we need to amend '{roller}\roller\WEB-INF\classes\hibernate.cfg.xml' with the following (See sample below, I'm using Oracle so modify for your DB).
 
  <!-- By default Roller uses a JNDI DataSource -->
  <property name="jndi.url">t3://localhost:7001</property>
  <property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
  <property name="connection.datasource">jdbc/rollerdb</property>
  <property name="show_sql">false</property>

  <property name="current_session_context_class">thread</property>

  <!-- select SQL dialect, MySQL 3.X or 4.X by default -->
  <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>

8) Comment off the line in web.xml as below:
 
  <!--<listener>
  <listener-class>org.apache.roller.ui.core.RollerContext</listener-class>
  </listener>-->

9) Modify '{temp}\roller\src\org\apache\roller\business\utils\UpgradeDatabase.java' at
line 190 if you are using Oracle like me.
 
  PreparedStatement websitesQuery = con.prepareStatement(
    "select w.id as wid, u.id as uuid, u.username as uname from "
    + "website w, rolleruser u where u.id=w.userid");

10) Change the context-root in '{roller}\roller\WEB-INF\weblogic.xml' to "roller" if it is not already so.
 
11) Deploy and enjoy.

No comments: