论坛首页 Java企业应用论坛

Roller4终于在我的Idea8上成功编译并安装,跑起来了!

浏览 3054 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-12-06   最后修改:2008-12-06

经过两天的努力,终于在Debian/Jdk6/Tomcat6/Idea8下跑起来了。

 

小小总结一下:

1,首先,编译项目源文件

    1)向apache-roller-src-4.0/tools/lib/ 下放入mail.jar和activation.jar;

    2)修改apache-roller-src-4.0/apps/weblogger/properties.xmlf 文件,如下:

<fileset id="base.jars" dir="${ro.tools}/lib">
    <include name="commons-id-0.1-SNAPSHOT.jar"/>
    <include name="commons-collections-3.2.jar" />
    <include name="commons-codec-1.3.jar" />
    <include name="commons-digester-1.6.jar" />
    <include name="commons-httpclient-2.0.2.jar" />
    <include name="commons-logging-1.0.4.jar" />
    <include name="commons-lang-2.1.jar" />
    <include name="concurrent-1.3.2.jar"/>
    <include name="jaxen-full.jar" />
    <include name="saxpath.jar" />
    <include name="jdom.jar"/>
    <include name="lucene-1.4.3.jar"/>
    <include name="log4j-1.2.11.jar"/>
    <include name="rome-0.9.jar"/>
    <include name="rome-fetcher-0.9.jar"/>
    <include name="velocity-1.5.jar"/>
    <include name="guice-1.0.jar"/>
    <include name="mail.jar"/><!-- ember added -->
    <include name="activation.jar"/><!-- ember added -->
</fileset>

    3)修改apache-roller-src-4.0/apps/weblogger/build.xml 文件,注释掉svn相关选项:

<!-- Get the SVN last changed rev value w/o using the overly flakey 
             svnant task. This will fail if svn is not in your PATH but the only 
             negative impact will be that the rev number that appears in your 
             log will be "${svn.LastChangedRev}" instead of the correct value. -->

        <!-- ember commeted
        <delete file="${ro.build}/svn.properties" />
        <exec executable="svn" output="${ro.build}/svn.properties" failifexecutionfails="false">
            <arg value="info" />
            <arg value="${root}" />
        </exec>
        <replace dir="${ro.build}">
           <include name="svn.properties" />
           <replacetoken> </replacetoken>
           <replacevalue></replacevalue>
        </replace>
        <property prefix="svn" file="${ro.build}/svn.properties"/>       
        
        <echo file="${build.compile.business}/roller-version.properties">
ro.version=${ro.version}
ro.revision=${svn.LastChangedRev}
ro.buildTime=${ro.buildTime}
ro.buildUser=${user.name}
        </echo>-->
 

    4)apache-roller-src-4.0/apps/weblogger/ 下运行ant build 或者ant dist,应该就编译成功了

 

 

2,解决启动NullPointerException错误

    我在idea8下启动时,发现启动listener出错,有NullPointerException异常。跟踪进去看了下,发现是初始化时试图寻找一个文件“roller-version.properties”,但是没有找到该文件,导致异常。我在项目源代码中没有找到那个文件,粗粗的看了下源码,似乎不一定非要那个文件不可,但是又不能不处理这个异常,所以简单的加了一个Cache,并输出到错误流。具体的步骤如下:

 

    1)修改类“org.apache.roller.weblogger.business.WebloggerImpl ”,如下:

package org.apache.roller.weblogger.business;

import org.apache.roller.weblogger.business.plugins.PluginManagerImpl;
import org.apache.roller.weblogger.business.plugins.PluginManager
//这里去除了过多的import项

/**
 * The abstract version of the Weblogger implementation.
 * 
 * Here we put code that pertains to *all* implementations of the Weblogger
 * interface, regardless of their persistence strategy.
 */
@com.google.inject.Singleton
public abstract class WebloggerImpl implements Weblogger {
    
    private static Log log = LogFactory.getLog(WebloggerImpl.class);
    
    // managers
    private final AutoPingManager      autoPingManager;
    private final BookmarkManager      bookmarkManager;
    private final FileManager          fileManager;
    private final IndexManager         indexManager;
    private final PingQueueManager     pingQueueManager;
    private final PingTargetManager    pingTargetManager;
    private final PluginManager        pluginManager;
    private final PropertiesManager    propertiesManager;
    private final RefererManager       refererManager;
    private final ReferrerQueueManager refererQueueManager;
    private final ThemeManager         themeManager;
    private final ThreadManager        threadManager;
    private final UserManager          userManager;
    private final WeblogManager        weblogManager;
    
    // url strategy
    private final URLStrategy          urlStrategy;
    
    // some simple attributes
    private final String version;
    private final String revision;
    private final String buildTime;
    private final String buildUser;
    
    
    protected WebloggerImpl(
        AutoPingManager      autoPingManager,
        BookmarkManager      bookmarkManager,
        FileManager          fileManager,
        IndexManager         indexManager,
        PingQueueManager     pingQueueManager,
        PingTargetManager    pingTargetManager,
        PluginManager        pluginManager,
        PropertiesManager    propertiesManager,
        RefererManager       refererManager,
        ReferrerQueueManager refererQueueManager, 
        ThemeManager         themeManager,
        ThreadManager        threadManager,
        UserManager          userManager,
        WeblogManager        weblogManager,
        URLStrategy          urlStrategy) throws WebloggerException { 
                
        this.autoPingManager     = autoPingManager;
        this.bookmarkManager     = bookmarkManager;
        this.fileManager         = fileManager;
        this.indexManager        = indexManager;
        this.pingQueueManager    = pingQueueManager;
        this.pingTargetManager   = pingTargetManager;
        this.pluginManager       = pluginManager;
        this.propertiesManager   = propertiesManager;
        this.refererManager      = refererManager;
        this.refererQueueManager = refererQueueManager;
        this.themeManager        = themeManager;
        this.threadManager       = threadManager;
        this.userManager         = userManager;
        this.weblogManager       = weblogManager;
        this.urlStrategy         = urlStrategy;
        
        Properties props = new Properties();
        try {
            props.load(getClass().getResourceAsStream("/roller-version.properties"));
        } catch (IOException e) {
            log.error("roller-version.properties not found", e);
        }

        
        catch(NullPointerException npe){//这里是我加入的代码
            log.error("roller-version.properties not found",npe);
        }
        version = props.getProperty("ro.version", "UNKNOWN");
        revision = props.getProperty("ro.revision", "UNKNOWN");
        buildTime = props.getProperty("ro.buildTime", "UNKNOWN");
        buildUser = props.getProperty("ro.buildUser", "UNKNOWN");
    }
  

    2)修改文件“org.apache.roller.weblogger.business.startup.DatabaseInstaller”,如下:

package org.apache.roller.weblogger.business.startup;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.business.DatabaseProvider;
import org.apache.roller.weblogger.pojos.WeblogPermission;


/**
 * Handles the install/upgrade of the Roller Weblogger database when the user
 * has configured their installation type to 'auto'.
 */
public class DatabaseInstaller {
    
    private static Log log = LogFactory.getLog(DatabaseInstaller.class);
    
    private final DatabaseProvider db;
    private final DatabaseScriptProvider scripts;
    private final String version;
    private List<String> messages = new ArrayList<String>();
    
    // the name of the property which holds the dbversion value
    private static final String DBVERSION_PROP = "roller.database.version";
    
    
    public DatabaseInstaller(DatabaseProvider dbProvider, DatabaseScriptProvider scriptProvider) {
        db = dbProvider;
        scripts = scriptProvider;
        
        Properties props = new Properties();
        try {
            props.load(getClass().getResourceAsStream("/roller-version.properties"));
        } catch (IOException e) {
            log.error("roller-version.properties not found", e);
        }

        
        catch(NullPointerException npe){//这里是我加入的代码
            log.error("no \"roller-version.properties\" ?");
        }
        version = props.getProperty("ro.version", "UNKNOWN");
    }

 

    3)最后,重新用ant build 和dist,生成roller-weblogger.war文件,位置:apache-roller-src-4.0/apps/weblogger/dist/webapp/roller-weblogger.war 。在idea8中选中这个war文件,设置Tomcat6的启动环境即可,这个步骤就不在这里详细说明了。

 

 

大家试试看,是不是还有什么问题,有兴趣的人可以一起讨论下。

 

 

   发表时间:2008-12-06  
roller4做什么用的?
0 请登录后投票
   发表时间:2008-12-06  
pn2008 写道
roller4做什么用的?

Roller: free and open source Java blog software
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics