Saturday, January 12, 2008

Installing Roller

Am I allowed to write about the opposition (a different blogging tool) here? I decided yesterday that I needed to install a mediawiki and a blog site at work. It wasn't feasible to use an Internet hosted site.

I've read blogs supported by heaps of different engines, but I've only ever used this one, and I've never installed any. I decided that Wikipedia might have info to help me choose a good piece of software. With endorsement from Sun + Apache, Roller must be good.

Installation

My trial system was an old 1.8GHz machine, on which I've installed Ubuntu. Although there was a promise of a 5-minute install, it took hours.

In the end, there were two main things I did to make it work. If only these had been in the instructions!
1. Turn tomcat security off
2. Create a directory /usr/share/tomcat5.5/roller_data (well actually a symlink to /var/roller_data)

So here's the story. There were a number of symptoms that led me to these steps.

There were some errors in catalina.log suggesting that the roller-startup.log could not be created. I tried putting log4j configuration properties into the roller-custom.properties file, but it made no difference. I tried modifying the log4j.properties file inside the webapps directory, and then I started getting different errors.

I decided that the roller-custom.properties wasn't being read. But still errors like this:

Caused by: java.security.AccessControlException: access denied (java.io.FilePermission roller-startup.log write)

I set the log4j.propeties file to be more explicit:
log4j.appender.roller-startup.File=/var/log/roller/roller-startup.log

Then I added a permission to the tomcat policy file:

grant {
permission java.io.FilePermission "/var/log/roller/-", "read,write";
};

The final step in getting the log file was to create the /var/log/roller directory, chown it to tomcat55, and set 755 permissions. Hurrah! Now after a /etc/init.d/tomcat5.5 restart I was getting a roller log.

I found that there was another access problem with ehcache - it wasn't able to create it's diskfile properly. So I used the ehcache properties file to say explicitly where I wanted the cache to go (/var/cache/roller), and then granted the necessary permissions. (Finding the requirement for delete took a little while too!) This took a lot of messing around, because it seems just this first permission wasn't enough:

grant {
permission java.io.FilePermission "/var/cache/roller/-", "read, write, delete";
};

I also had to add a permission for roller to read the /var/cache directory as well:

grant {
permission java.io.FilePermission "/var/cache/-", "read";
};

Great, now the ehcache problem is gone. The next problem is connecting to the database. There was no explicit java.security.AccessControlException - the log just showed this:

INFO 2008-01-11 11:55:07,042 DatabaseProvider:successMessage - SUCCESS: Got parameters. Using configuration type JDBC_PROPERTIES
INFO 2008-01-11 11:55:07,042 DatabaseProvider:successMessage - -- Using JDBC driver class: com.mysql.jdbc.Driver
INFO 2008-01-11 11:55:07,043 DatabaseProvider:successMessage - -- Using JDBC connection URL: jdbc:mysql://localhost:3306/rollerdb
INFO 2008-01-11 11:55:07,043 DatabaseProvider:successMessage - -- Using JDBC username: roller
INFO 2008-01-11 11:55:07,044 DatabaseProvider:successMessage - -- Using JDBC password: [hidden]
INFO 2008-01-11 11:55:07,061 DatabaseProvider:successMessage - SUCCESS: loaded JDBC driver class [
com.mysql.jdbc.Driver]
ERROR 2008-01-11 11:55:07,508 DatabaseProvider:errorMessage - ERROR: unable to obtain database connection. Likely problem: bad connection parameters or database unavailable.
FATAL 2008-01-11 11:55:07,510 RollerContext:contextInitialized - Roller Weblogger startup failed during app preparation
org.apache.roller.weblogger.business.startup.StartupException: ERROR: unable to obtain database connection. Likely problem: bad connection parameters or database unavailable.
at org.apache.roller.weblogger.business.DatabaseProvider.(DatabaseProvider.java:148)

I checked that I could log into mysql with the username and password - no problem. I wrote a small java app to test programmatic connectivity. No problem. Guess an access control issue: look for java permissions to allow connections, and add the following to the policy file:

grant {
permission java.net.SocketPermission "localhost:3306", "connect,resolve";
};

Database connectivity fixed. I added a similar permission for localhost:25 to get past mail configuration errors.

The Tiles problems were harder:

FATAL 2008-01-11 11:55:07,542 TilesListener:contextInitialized - Unable to retrieve tiles factory.
org.apache.tiles.TilesException: Unable to retrieve init parameters. Is this context a ServletContext, PortletContext, or similar object?
at org.apache.tiles.factory.TilesContainerFactory.getInitParameterMap(TilesContainerFactory.java:352)
at org.apache.tiles.factory.TilesContainerFactory.getFactory(TilesContainerFactory.java:143)
at org.apache.tiles.factory.TilesContainerFactory.getFactory(TilesContainerFactory.java:122)
at org.apache.tiles.web.startup.TilesListener.createContainer(TilesListener.java:88)
at org.apache.tiles.web.startup.TilesListener.contextInitialized(TilesListener.java:57)

I spent some time trying to learn about tiles, but gave up. I decided that most people must install tomcat with security turned off. I looked for a way to do this, and found in /etc/init.d/tomcat5.5 there are a couple of lines

# Use the Java security manager? (yes/no)
TOMCAT5_SECURITY=yes

So I changed the yes to a no, and restarted tomcat. What a difference! Finally, the tomcat manager showed that the application was starting up. I clicked on the [/roller] link, and after a few seconds, there I was - a real roller page, offering to configure the database for me. I clicked configure, and it seemed to whirr and clunk for a few seconds.

The next page that came up was a 500 server error. Checking behind to make sure nobody was looking, I just pressed the Reload button on the browser, and I was offered a page asking whether to create a user, a new blog, or modify system settings. I chose to create a new user, but then was informed that the administrator had blocked creation of new users. Clearly a problem.

Decided to revert to a clean roller.war, without any of my fiddles. Also dropped the database inside mysql and started that again. This time, it was sure to work as advertised. Well, nearly. I was still unable to create new users. Check the log file (now /var/log/tomcat5.5/roller.log, and find this error:

ERROR 2008-01-11 14:25:58,853 IndexManagerImpl:initialize - java.io.IOException: No such file or directory
ERROR 2008-01-11 14:25:58,894 IndexManagerImpl:getFSDirectory - Problem accessing index directory
java.io.IOException: Cannot create directory: /usr/share/tomcat5.5/roller_data/search-index
at org.apache.lucene.store.FSDirectory.create(FSDirectory.java:138)
at org.apache.lucene.store.FSDirectory.(FSDirectory.java:128)

I wasn't going to look into lucene. I tried just creating the /usr/share/tomcat5.5/roller_data directory, which was actually a symlink to /var/roller_data, dropped and recreated the database, started again.

At last, success!

Using Roller

I'm not going to write too much here. I'm very new to Roller, and I'm sure I haven't explored all the options. And when one is familiar with one system, it can sometimes be hard to appreciate the complexities of another. In my case, the initial attempts were somewhat more complex than I am used to. I didn't notice any wimpy wysiwyg type support for adding links and formatting: just a couple of filters for preserving linebreaks. I had to type my own <a href=... > details in. Maybe this one (Blogger/Blogspot) really is better, or maybe I just need to set up Roller a bit more, and understand how to use it. Stay tuned for further reaction.

2 comments:

Unknown said...

Just wanted to say thanks for posting this. Helped me out tremendously. Your two suggestions made it work (and nice tip to just reload after the 500 error).

So, thanks!

Anonymous said...

Thanks for the tip to turn off security. Helped me alot!