Kohei Nozaki's blog 

Entries tagged [roller]

Review of Apache Roller 4.0 Beginner's Guide


Posted on Wednesday Jan 14, 2015 at 11:53PM in Technology


The book seems little obsolete because it was published on 2009 and intended to use with version 4.0. but most part of the book makes sense to me because major features of Roller are unchanged till current version 5.1.1.

A instruction about weblog itself is interested and fun to read. the book has many step-by-step instruction about its function and it's very easy to read. especially, instruction of creating a new template from scratch was good for me. some contents are obsoleted surely but I can recommend this book for beginners of Roller.

But maybe you should read the official documents first than buy this book. official document can be obtained from here as PDF or ODT.

NOTE: an additional Section 9, which is not included the book and the book claims that it can be downloaded via packtpub.com but the URL returns 404 now. the support desk send me PDF after I sent an email to ask how can I get section 9. they said the link got updated after renewal of their web site. it needs to add /sites/default/ as prefix of the path now.


Roller Asciidoctorj Plugin


Posted on Tuesday Jan 13, 2015 at 09:54PM in Technology


I don’t know about Asciidoc very well yet but it works fine anyway so I pushed it to GitHub, and this is the first post with that plugin. I’ve never tried it on except WildFly yet, but it would work with Tomcat or any other application servers. report on various application server or any feedback are welcome.

Distribution, installation instruction and more can be found at: https://github.com/lbtc-xxx/roller-asciidoctorj-plugin

Information about Asciidoctorj can be found at: http://asciidoctor.org/docs/asciidoctorj/


Debugging Roller's salt processing


Posted on Saturday Jan 10, 2015 at 05:52PM in Technology


Recently I'm getting "javax.servlet.ServletException: Security Violation" 1 or 2 times per day from Roller (the blog engine this blog running on) and lost some unsaved paragraphs every time. I tried to back in such case, Safari and Firefox said the page has expired, and I couldn't take back my unsaved paragraphs. it's annoying so I started to find what the cause is.

Looking at stacktrace and I found that it comes from ValidateSaltFilter, and its related caching classes such as ExpiringLRUCacheFactoryImpl, but it's hard to reproduce, so I added some logging configuration and logging procedure to Roller to acquire more information.

Users can configure log4j which is logging framework Roller used at roller-custom.properties. I added following:

# Appender definition

log4j.appender.roller-debug=org.apache.log4j.DailyRollingFileAppender
log4j.appender.roller-debug.File=/Users/kyle/tmp/roller511/rollerdata/roller-debug.log
log4j.appender.roller-debug.layout=org.apache.log4j.PatternLayout
log4j.appender.roller-debug.layout.ConversionPattern=%-5p %d{yyyy-MM-dd HH:mm:ss,SSS} %C{1}:%M - %m%n
log4j.appender.roller-debug.Threshold=DEBUG

# Assign loggers to the appender which defined at the preceding.
# log4j.additivity means that stopping propagate to parent logger.

log4j.logger.org.apache.roller.weblogger.util.cache=DEBUG, roller-debug
log4j.additivity.org.apache.roller.weblogger.util.cache=false

log4j.logger.org.apache.roller.weblogger.ui.rendering.util.cache=DEBUG, roller-debug
log4j.additivity.org.apache.roller.weblogger.ui.rendering.util.cache=false

log4j.logger.org.apache.roller.weblogger.ui.core.filters.ValidateSaltFilter=DEBUG, roller-debug
log4j.additivity.org.apache.roller.weblogger.ui.core.filters.ValidateSaltFilter=false
And some debugging procedures are added to ValidateSaltFilter#doFilter() like following:
     public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpReq = (HttpServletRequest) request;

        // note enctype="multipart/form-data" does not send parameters (see
        // ROL-1956) requests of this type are stored in salt.ignored.urls in
        // roller.properties
        if (httpReq.getMethod().equals("POST")
                && !isIgnoredURL(httpReq.getServletPath())) {

            String salt = httpReq.getParameter("salt");
            SaltCache saltCache = SaltCache.getInstance();

            if (log.isDebugEnabled()) {

                try {
                    final Field contentCache = SaltCache.class.getDeclaredField("contentCache");
                    contentCache.setAccessible(true);
                    Object contentCacheValue = contentCache.get(saltCache);
                    
                    final Field cache = LRUCacheImpl.class.getDeclaredField("cache");
                    cache.setAccessible(true);
                    Object cacheValue = cache.get(contentCacheValue);
                    
                    Map cacheMap = (Map) cacheValue;
                    final Set set = cacheMap.keySet();
                    
                    log.debug("Salt which is just received: " + salt);
                    for (Object o : set) {
                        log.debug("Salt in the map: " + o);
                    }
                    
                } catch (NoSuchFieldException e) {
                    throw new RuntimeException(e);
                } catch (IllegalAccessException e) {
                    throw new RuntimeException(e);
                }

                if (salt == null) {
                    log.debug("salt == null");
                }
                else if (saltCache.get(salt) == null) {
                    log.debug("saltCache.get(salt) == null. salt=" + salt);
                }
                else if (saltCache.get(salt).equals(false)) {
                    log.debug("saltCache.get(salt).equals(false). salt=" + salt);
                }
            }

            if (salt == null || saltCache.get(salt) == null
                    || saltCache.get(salt).equals(false)) {

                if (log.isDebugEnabled()) {
                    log.debug("Salt value not found on POST to URL : "
                            + httpReq.getServletPath());
                }

                throw new ServletException("Security Violation");
            }
        }

        chain.doFilter(request, response);
    }

I added all of additional procedures inside if (log.isDebugEnabled()) so I won't need to remove these procedures after investigation. all I need will that just edit roller-custom.properties and reload Roller.

Now I can see how all of salts are creating, removing and be judged which was hit or miss from the log, so I'll take a look it when the problem occurred again.

UPDATE: I think I found the cause. see JIRA.


A quick workaround for list element issue of Roller5.1.0-SNAPSHOT mobile


Posted on Saturday May 17, 2014 at 03:36PM in Technology


I wrote a entry which uses list elements (ul, ol, li), and I got into some problem. so I leave this entry as a note of my solution.

I wrote some HTML as a content of a entry like this:

<ol>
  <li>element 1
  <li>element 2
  <ul>
    <li>nested element 1
    <li>nested element 2
  </ul>
</ol>

Then it showed in PC browsers as I expected like this:

List0

But, it showed in mobile version like this:

NewImage

all of list elements are disappeared. instead of list elements, the bottom of the entry became clickable. when I click the bottom, page transits to:

NewImage

I don't want this behavior, just want html lists to stay inline on the page. fortunately, I found a quick workaround of it that just copy template named "_day" of Standard to Mobile. 

  1. Go to blog settings
  2. Click design tab
  3. Click template
  4. Click "_day"
  5. Copy whole of template from "Standard"
  6. Click "Mobile" tab
  7. Paste the template
  8. Save

That's all. now mobile version looks like this:

NewImage


Install Apache Roller 5.1.0-SNAPSHOT to WildFly


Posted on Friday May 16, 2014 at 05:40PM in Technology


I installed Apache Roller 5.0.3 to WildFly at this article, but unfortunately it was so annoying procedure. Roller 5.0.3 comes with official installation guide to JBoss6, but it seems to be obsoleted for WildFly, so I had to such struggle to install Roller to WildFly.

But, I heard that from a developer of Roller, latest Roller and its installation guide is updated as compatible with newer JBoss version. also some problems at deploying to WildFly are fixed, so it became more easy to deploy to newer JBoss version, so I recommend latest Roller to who wants to use Roller with WildFly. The guide is fine and I guess that it's might be better to read it than this entry.

Environment

  • Apache Roller 5.1.0-SNAPSHOT
  • Apache Maven 3.1.1
  • WildFly 8.1.0.CR1
  • Oracle JDK8u5
  • PostgreSQL 9.2.4
  • OS X 10.9.3

Preconditions

  • Appropriate JDBC driver is already installed.

Procedures

  1. Checkout latest Apache Roller
    svn co https://svn.apache.org/repos/asf/roller/trunk roller_trunk
    
  2. Build
    cd roller_trunk; mvn clean install
    

    The WAR file will be built at roller_trunk/app/target/roller.war

  3. Create a database (with psql)
    create database roller owner wildfly encoding 'UTF8' TEMPLATE template0;
    
  4. Create a DataSource (with jboss-cli)
    data-source add \
     --name=RollerDS \
     --driver-name=postgresql-9.3-1100.jdbc41.jar \
     --connection-url=jdbc:postgresql://localhost:5432/roller \
     --jndi-name=java:/RollerDS \
     --user-name=wildfly \
     --password=*** \
     --check-valid-connection-sql="SELECT 1" \
     --background-validation-millis=60000 \
     --validate-on-match=true \
     --jta=false
    
  5. Set default datasource
    /subsystem=jpa:write-attribute(name=default-datasource, value="java:/RollerDS")
    
  6. Create a JavaMail session
    /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=RollerSMTP:add( \
    host=smtp.gmail.com, \
    port=465)
    
    /subsystem=mail/mail-session=RollerMail:add(jndi-name="java:/RollerMail", from="jane.doe@gmail.example.com", debug=true)
    
    /subsystem=mail/mail-session=RollerMail/server=smtp:add( \
    outbound-socket-binding-ref=RollerSMTP, \
    ssl=true, \
    username=jane.doe@gmail.example.com, \
    password=***)
    

    How to define a JavaMail session using CLI might be useful if you want further information about configuration of JavaMail session for WildFly.

  7. Create a directory at $WILDFLY_HOME/modules/org/apache/roller/configuration/main and put files below
    • module.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="org.apache.roller.configuration">
         <resources>
             <resource-root path="."/>
         </resources>
      </module> 
      
    • roller-custom.properties
      installation.type=auto
      
      mediafiles.storage.dir=/Users/kyle/tmp/roller510/rollerdata/mediafiles
      search.index.dir=/Users/kyle/tmp/roller510/rollerdata/searchindex
      log4j.appender.roller.File=/Users/kyle/tmp/roller510/rollerdata/roller.log
      
      database.configurationType=jndi
      database.jndi.name=java:/RollerDS
      mail.configurationType=jndi
      mail.jndi.name=java:/RollerMail
      
    • hibernate.cfg.xml
      <hibernate-configuration>
            <session-factory>
               <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect</property>
            </session-factory>
      </hibernate-configuration>
      
  8. Restart wildfly
  9. Browse /roller of your application server and do some initializing process
  10. Set installation.type=manual in roller-custom.properties

Remarks

It works fine now, so I would try some customizing and posting with Roller.

I still seeing an error of JavaMail or something. I would investigate it later.

WARN  2014-05-16 16:01:39,233 WebloggerStartup:prepare - Failed to setup mail provider, continuing anyways.
Reason: ERROR connecting to mail server

References

  1. How to Build Roller