JAPANESE

Apache Forrest TIPS

Published : 2012-02-25
Last update : $Date: 2012-03-19 00:49:13 +0900 (Mon, 19 Mar 2012) $

Preface

This document have some TIPS about Apache Forrest that I studied in personal. I intend this is correct in technically, but I may tell a lie , or this may be not effective way or this may be aged. It may not be easy to read and understand beacause this is my frontline of understanding.

Contents

  1. Environment
  2. Solve the bug for Forrest-0.9
  3. Reference

Environment

Solve the bug for Forrest-0.9

NullPointerException in tutorial

According to the first tutorial Explanation and features ,

>forrest seed
>forrest

should be executed. But at the time >forrest , the stacktrace of NullPointerException will came. (like this) I'll clear this as the first step.

java.lang.NullPointerException
        at org.apache.cocoon.environment.AbstractEnvironment.release(AbstractEnvironment.java:563)
        at org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade.release(MutableEnvironmentFacade.java:314)
        at org.apache.cocoon.generation.FileGenerator.recycle(FileGenerator.java:64)
        at org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool.put(InstrumentedResourceLimitingPool.java:407)
        at org.apache.avalon.excalibur.component.PoolableComponentHandler.doPut(PoolableComponentHandler.java:212)
        at org.apache.avalon.excalibur.component.ComponentHandler.put(ComponentHandler.java:425)
        at org.apache.avalon.excalibur.component.ExcaliburComponentSelector.release(ExcaliburComponentSelector.java:307)
        at org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:301)
        at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.recycle(AbstractProcessingPipeline.java:723)
        at org.apache.cocoon.components.pipeline.impl.BaseCachingProcessingPipeline.recycle(BaseCachingProcessingPipeline.java:78)
        at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.recycle(AbstractCachingProcessingPipeline.java:1130)
        at org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool.put(InstrumentedResourceLimitingPool.java:407)
        at org.apache.avalon.excalibur.component.PoolableComponentHandler.doPut(PoolableComponentHandler.java:212)
        at org.apache.avalon.excalibur.component.ComponentHandler.put(ComponentHandler.java:425)
        at org.apache.avalon.excalibur.component.ExcaliburComponentSelector.release(ExcaliburComponentSelector.java:307)
        at org.apache.cocoon.components.ExtendedComponentSelector.release(ExtendedComponentSelector.java:301)
        at org.apache.cocoon.components.EnvironmentDescription.release(CocoonComponentManager.java:695)
        at org.apache.cocoon.components.CocoonComponentManager.endProcessing(CocoonComponentManager.java:262)
        at org.apache.cocoon.Cocoon.process(Cocoon.java:739)
        at org.apache.cocoon.bean.CocoonWrapper.getPage(CocoonWrapper.java:514)
        at org.apache.cocoon.bean.CocoonBean.processTarget(CocoonBean.java:499)
        at org.apache.cocoon.bean.CocoonBean.process(CocoonBean.java:356)
        at org.apache.cocoon.Main.main(Main.java:321)

If you are in urgent, copy this jar file to %FORREST_HOME%\lib\core\. And rename cocoon.2.1.12-dev.jar to other file extension so that forrest does not use it. With this modification, no NullPointerException will happen.

For distrustful persons. You can build this jar file adding small modification to the source of Cocoon2.1.11 and build.

  1. Download cocoon-2.1.11-src.zip from http://cocoon.apache.org/mirror.cgi.
  2. Extract the zip to some working folder.
  3. Add check against null at line 562 of\src\java\org\apache\cocoon\environment\AbstractEnvironment.java
    Before.
    public void release(final org.apache.excalibur.source.Source source) {
        if (null != source) {
            this.sourceResolver.release(source);
        }
    }
    
    After.
    public void release(final org.apache.excalibur.source.Source source) {
        if (null != source && this.sourceResolver != null ) {
            this.sourceResolver.release(source);
        }
    }
    
  4. Build jar file with build.bat in zip file. You need JDK 5, Java6 can't build it. Refer Installing Apache Cocoon in detail.

You may think that "Is this modification OK? No side effect? " But now I don't know correct way. Please treat this as some workaround or one of hack.

Mojibake in Japanese

If you execute >forrest seed , you will get the template file of the content. You wants to edit xml files under \src\documentation\content\xdocs , but to edit Japanese Charactor (or some charactor except for us-ascii , CJKV or else), you need modify some setting file.

Add encoding="UTF-8" attribute at fixcrlf task at the line 255 of %FORREST_HOME%\main\targets\site.xml (Forrest version0.9) Setting UTF-8, but you need set actual encoding setting as you use. I guess UTF-8 is no problem for modern selection.With this , you can execute >forrest without mojibake exactly.

<fixcrlf srcdir="${project.site-dir}" encoding="UTF-8"> <!-- add attribute here -->
<include name="**/*.html"/>
<!-- The CSS Includes are a workaround for FOR-925 -->
<include name="**/*.css"/>
</fixcrlf>

Mojibake in html contents will cleard, but PDF file will not.(font problem?) I'll check this later.


Creative Commons License
This work is licensed under a Creative Commons Attribution 2.1 Japan License.
Author: Fukuhara Kazuro.

top page