Kohei Nozaki's blog 

Install Apache Roller5


Posted on Thursday May 15, 2014 at 11:54AM in Technology


Environment

  • WildFly 8.1.0.CR1
  • Oracle JDK8u5
  • PostgreSQL 9.2.4
  • roller-weblogger-5.0.3-for-javaee.tar.gz
  • OS X 10.9.2

Preconditions

  • Ensure appropriate JDBC driver is installed to WildFly.

Create a database for Roller

postgres=# create database roller owner kyle encoding 'UTF8' TEMPLATE template0;
CREATE DATABASE
postgres=# 

Create a DataSource

  • Using jboss-cli.
data-source add \
 --name=RollerDS \
 --driver-name=postgresql \
 --connection-url=jdbc:postgresql://localhost:5432/roller \
 --jndi-name=java:jboss/jdbc/RollerDS \
 --user-name=postgres \
 --password=postgres \
 --jta=false \
 --use-java-context=false

Create the WAR with modified persistence.xml

Why need this?

  • Roller5 uses JPA, and defines its JNDI datasource name in persistence.xml as “jdbc/rollerdb”
  • But, WildFly doesn't allow such JNDI name. datasource creation will fail like this:
JBAS010471: Jndi name have to start with java:/ or java:jboss/
  • Also, Roller5 installation guide mentioned about installation procedure for JBoss6, but it seems obsoleted.
  • If possible, I recommend you to use other application servers like Tomcat or GlassFish at the moment because it needs many additional procedures to getting work with WildFly.

Extract the WAR

kyle-no-MacBook:tmp kyle$ pwd
/tmp
kyle-no-MacBook:tmp kyle$ mkdir roller
kyle-no-MacBook:tmp kyle$ cd roller
kyle-no-MacBook:roller kyle$ mkdir war
kyle-no-MacBook:roller kyle$ cd war
kyle-no-MacBook:war kyle$ jar xvf ~/Downloads/tmp/roller-weblogger-5.0.3-javaee/webapp/roller-5.0.3-javaee.war 

Extract roller-planet-business-5.0.3.jar

kyle-no-MacBook:war kyle$ cd ../
kyle-no-MacBook:roller kyle$ mkdir planet
kyle-no-MacBook:roller kyle$ cd planet
kyle-no-MacBook:planet kyle$ jar xvf ../war/WEB-INF/lib/roller-planet-business-5.0.3.jar

Modify persistence.xml inside roller-planet-business-5.0.3.jar

kyle-no-MacBook:planet kyle$ sed -i -e "s/jdbc\/rollerdb/java:jboss\/jdbc\/RollerDS/" META-INF/persistence.xml
  • Now, persistence.xml like this:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
    <persistence-unit name ="PlanetPU" transaction-type = "RESOURCE_LOCAL"> 
        <non-jta-data-source>java:jboss/jdbc/RollerDS</non-jta-data-source>
        <mapping-file>org/apache/roller/planet/pojos/RuntimeConfigProperty.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/planet/pojos/Planet.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/planet/pojos/PlanetGroup.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/planet/pojos/Subscription.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/planet/pojos/SubscriptionEntry.orm.xml</mapping-file> 
    </persistence-unit>
</persistence>

Extract roller-weblogger-business-5.0.3.jar

kyle-no-MacBook:planet kyle$ cd ..
kyle-no-MacBook:roller kyle$ mkdir weblogger
kyle-no-MacBook:roller kyle$ cd weblogger/
kyle-no-MacBook:weblogger kyle$ jar xvf ../war/WEB-INF/lib/roller-weblogger-business-5.0.3.jar 

Modify persistence.xml inside roller-weblogger-business-5.0.3.jar

  • Replace JNDI name
kyle-no-MacBook:weblogger kyle$ sed -i -e "s/jdbc\/rollerdb/java:jboss\/jdbc\/RollerDS/" META-INF/persistence.xml
  • Add declaration of an additional property which enables bind EntityManagerFactory to JNDI. detail information: [3]
        <properties>
           <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/jpa/RollerEMF" />
        </properties>
  • Also, trimming is needed.
kyle-no-MacBook:weblogger kyle$ sed -i -e "s/orm\.xml *</orm\.xml</g" META-INF/persistence.xml
  • If skip this, WildFly will complains like this and deployment fails:
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: RollerPU] Unable to resolve named mapping-file [org/apache/roller/weblogger/pojos/TaskLock.orm.xml                ]
  • Now, persistence.xml is:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
    <persistence-unit name ="RollerPU" transaction-type="RESOURCE_LOCAL"> 
        <non-jta-data-source>java:jboss/jdbc/RollerDS</non-jta-data-source>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogBookmark.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogEntryComment.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogEntryAttribute.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogBookmarkFolder.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogHitCount.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/PingQueueEntry.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/PingTarget.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogReferrer.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/UserRole.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/RuntimeConfigProperty.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/TaskLock.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/User.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogCategory.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogEntry.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogEntryTagAggregate.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogEntryTag.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogTemplate.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/ObjectPermission.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/WeblogPermission.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/Weblog.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/UserAttribute.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/OAuthConsumerRecord.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/OAuthAccessorRecord.orm.xml</mapping-file>
        <mapping-file>org/apache/roller/weblogger/pojos/MediaFile.orm.xml</mapping-file>    
        <mapping-file>org/apache/roller/weblogger/pojos/MediaFileTag.orm.xml</mapping-file> 
        <mapping-file>org/apache/roller/weblogger/pojos/MediaFileDirectory.orm.xml</mapping-file>
        <class>org.apache.roller.weblogger.pojos.AutoPing</class>
        <properties>
           <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/jpa/RollerEMF" />
        </properties>
    </persistence-unit>  
</persistence>

Create jars

kyle-no-MacBook:roller kyle$ cd planet/
kyle-no-MacBook:planet kyle$ jar cvf ../roller-planet-business-5.0.3-for-wildfly.jar .
kyle-no-MacBook:planet kyle$ cd ../weblogger/
kyle-no-MacBook:weblogger kyle$ jar cvf ../roller-weblogger-business-5.0.3-for-wildfly.jar .

Put jars into WEB-INF

kyle-no-MacBook:roller kyle$ pwd
/tmp/roller
kyle-no-MacBook:roller kyle$ cp roller-planet-business-5.0.3-for-wildfly.jar war/WEB-INF/lib/roller-planet-business-5.0.3.jar 
kyle-no-MacBook:roller kyle$ cp roller-weblogger-business-5.0.3-for-wildfly.jar war/WEB-INF/lib/roller-weblogger-business-5.0.3.jar 

Put jboss-web.xml into WEB-INF

  • Path:
kyle-no-MacBook:WEB-INF kyle$ pwd
/tmp/roller/war/WEB-INF
  • It goes like this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <resource-ref>
        <res-ref-name>jdbc/rollerdb</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <jndi-name>java:jboss/jdbc/RollerDS</jndi-name>
    </resource-ref>
    <resource-ref>
        <res-ref-name>jpa/rolleremf</res-ref-name>
        <res-type>javax.persistence.EntityManagerFactory</res-type>
        <jndi-name>java:jboss/jpa/RollerEMF</jndi-name>
    </resource-ref>
    <resource-ref>
        <res-ref-name>mail/Session</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <jndi-name>java:/mail/myMail</jndi-name>
    </resource-ref>
</jboss-web>

Put roller-custom.properties into WEB-INF/classes

  • Path:
kyle-no-MacBook:classes kyle$ pwd
/tmp/roller/war/WEB-INF/classes
  • It goes like this:
jpa.configurationType=jndi
jpa.emf.jndi.name=jpa/rolleremf
installation.type=auto
mediafiles.storage.dir=/Users/kyle/tmp/rollerdata/mediafiles
search.index.dir=/Users/kyle/tmp/rollerdata/searchindex
log4j.appender.roller.File=/Users/kyle/tmp/rollerdata/roller.log
database.jndi.name=java:jboss/jdbc/RollerDS

Create the WAR

kyle-no-MacBook:roller kyle$ pwd
/tmp/roller
kyle-no-MacBook:roller kyle$ cd war
kyle-no-MacBook:war kyle$ jar cvf ../roller.war .

Deploy

cp roller.war ~/apps/wildfly/standalone/deployments
  • It goes like this:
2014-05-15 14:25:17,648 TRACE [org.hibernate.type.TypeFactory] (ServerService Thread Pool -- 311) Scoping types to session factory org.hibernate.internal.SessionFactoryImpl@5fcdf39a
2014-05-15 14:25:17,842 TRACE [org.hibernate.type.TypeFactory] (ServerService Thread Pool -- 310) Scoping types to session factory org.hibernate.internal.SessionFactoryImpl@745bcb72
2014-05-15 14:25:18,626 INFO  [org.apache.roller.weblogger.business.DatabaseProvider] (MSC service thread 1-3) SUCCESS: Got parameters. Using configuration type JNDI_NAME
2014-05-15 14:25:18,626 INFO  [org.apache.roller.weblogger.business.DatabaseProvider] (MSC service thread 1-3) -- Using JNDI datasource name: java:jboss/jdbc/RollerDS
2014-05-15 14:25:18,627 INFO  [org.apache.roller.weblogger.business.DatabaseProvider] (MSC service thread 1-3) SUCCESS: located JNDI DataSource [java:jboss/jdbc/RollerDS]
2014-05-15 14:25:19,998 INFO  [org.apache.roller.weblogger.ui.core.RollerContext] (MSC service thread 1-3) 
--------------------------------------------------------------
Roller Weblogger startup INCOMPLETE, user interaction required
--------------------------------------------------------------
2014-05-15 14:25:19,999 INFO  [org.apache.roller.weblogger.ui.core.RollerContext] (MSC service thread 1-3) Remember Me enabled: true
2014-05-15 14:25:20,000 INFO  [org.apache.roller.weblogger.ui.core.RollerContext] (MSC service thread 1-3) Password Encryption Algorithm set to 'SHA'
2014-05-15 14:25:20,000 INFO  [org.apache.roller.weblogger.ui.core.RollerContext] (MSC service thread 1-3) Initializing Velocity
2014-05-15 14:25:20,136 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.SearchServlet] (MSC service thread 1-3) Initializing SearchServlet
2014-05-15 14:25:20,136 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.FeedServlet] (MSC service thread 1-3) Initializing FeedServlet
2014-05-15 14:25:20,137 INFO  [org.apache.roller.weblogger.ui.rendering.util.cache.WeblogFeedCache] (MSC service thread 1-3) {size=200, id=cache.weblogfeed, timeout=3600, enabled=true}
2014-05-15 14:25:20,139 INFO  [org.apache.roller.weblogger.util.cache.CacheManager] (MSC service thread 1-3) Cache Manager Initialized.
2014-05-15 14:25:20,139 INFO  [org.apache.roller.weblogger.util.cache.CacheManager] (MSC service thread 1-3) Cache Factory = org.apache.roller.weblogger.util.cache.ExpiringLRUCacheFactoryImpl
2014-05-15 14:25:20,142 INFO  [org.apache.roller.weblogger.ui.rendering.util.cache.SiteWideCache] (MSC service thread 1-3) {size=50, id=cache.sitewide, enabled=true, timeout=1800}
2014-05-15 14:25:20,142 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.ResourceServlet] (MSC service thread 1-3) Initializing ResourceServlet
2014-05-15 14:25:20,142 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.PageServlet] (MSC service thread 1-3) Initializing PageServlet
2014-05-15 14:25:20,143 INFO  [org.apache.roller.weblogger.ui.rendering.util.cache.WeblogPageCache] (MSC service thread 1-3) {size=400, id=cache.weblogpage, enabled=true, timeout=3600}
2014-05-15 14:25:20,143 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.PageServlet] (MSC service thread 1-3) Referrer processing enabled = true
2014-05-15 14:25:20,143 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.MediaResourceServlet] (MSC service thread 1-3) Initializing ResourceServlet
2014-05-15 14:25:20,144 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.CommentServlet] (MSC service thread 1-3) Initializing CommentServlet
2014-05-15 14:25:20,153 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured CommentValidator: ブラックリストコメント排除 / org.apache.roller.weblogger.ui.rendering.plugins.comments.BlacklistCommentValidator
2014-05-15 14:25:20,154 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured CommentValidator: 多すぎるリンクが入ったコメントバリケーダ / org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessLinksCommentValidator
2014-05-15 14:25:20,154 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured CommentValidator: コメントバリケーダ / org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
2014-05-15 14:25:20,155 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured 3 CommentValidators
2014-05-15 14:25:20,155 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.CommentServlet] (MSC service thread 1-3) Comment Throttling DISABLED
2014-05-15 14:25:20,155 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.PlanetFeedServlet] (MSC service thread 1-3) Initializing PlanetRssServlet
2014-05-15 14:25:20,156 INFO  [org.apache.roller.weblogger.ui.rendering.util.cache.PlanetCache] (MSC service thread 1-3) Planet cache = {size=10, id=cache.planet, timeout=1800, enabled=true}
2014-05-15 14:25:20,156 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.RSDServlet] (MSC service thread 1-3) Initializing RSDServlet
2014-05-15 14:25:20,157 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured CommentValidator: ブラックリストコメント排除 / org.apache.roller.weblogger.ui.rendering.plugins.comments.BlacklistCommentValidator
2014-05-15 14:25:20,157 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured CommentValidator: 多すぎるリンクが入ったコメントバリケーダ / org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessLinksCommentValidator
2014-05-15 14:25:20,158 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured CommentValidator: コメントバリケーダ / org.apache.roller.weblogger.ui.rendering.plugins.comments.ExcessSizeCommentValidator
2014-05-15 14:25:20,158 INFO  [org.apache.roller.weblogger.ui.rendering.plugins.comments.CommentValidationManager] (MSC service thread 1-3) Configured 3 CommentValidators
2014-05-15 14:25:20,159 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.PreviewServlet] (MSC service thread 1-3) Initializing PreviewServlet
2014-05-15 14:25:20,160 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.PreviewThemeImageServlet] (MSC service thread 1-3) Initializing PreviewThemeImageServlet
2014-05-15 14:25:20,160 INFO  [org.apache.roller.weblogger.ui.rendering.servlets.PreviewResourceServlet] (MSC service thread 1-3) Initializing PreviewResourceServlet

Access to the page

  • Finally the top page is shown!

  • The button triggers schema creation.

roller=# \d
                  List of relations
 Schema |           Name           | Type  |  Owner   
--------+--------------------------+-------+----------
 public | autoping                 | table | postgres
 public | bookmark                 | table | postgres
 public | entryattribute           | table | postgres
...
  • Finally I saw the welcome page!

Don't forget: Reset the installation.type flag

  • Roller installation guide said:

Now that you're done with the installation you should turn off Roller's auto-installation system. Edit your roller-custom.properties file and set installation.type=manual. Then restart your server or Roller so that it accepts the new setting.

  • So, you need to edit the roller-custom.properties and re-deploy.

References

  1. Why not java:global/datasources? | Community
  2. Roller 5 and JBoss 6
  3. Binding EntityManagerFactory/EntityManager to JNDI
  4. Une tasse de cafe
  5. Apache Roller: TJシステム設計



No one has commented yet.

Leave a Comment

HTML Syntax: NOT allowed