最近朋友的公司要搭建公司的内部WiKi系统,由于之前一起的用过confluence,所以其对confluence比较中意。不过朋友公司里面懂Linux的不多,所以只能在windows下搭建。不过在启动时发现一闪而过,查看logs目录也未发现有日志输出,本篇就通过catalina.bat文件进行问题定位---confluence的zip包是通过tomcat集成的,所以其处理原理和tomcat问题处理原理一样。

问题一:JAVA环境变量有空格

confluence 的启动文件有三个start.bat、start-confluence.bat、catalina.bat 三个启动文件任一个都可以启动。双击start.bat启动时一闪而过,通过命令行下启动查看,报错内容如下:

1JAVA_HOME "C:\Program Files\Java\jdk1.8.0_60" contains spaces. Please change to
2a location without spaces if this causes problems.
3If you encounter issues starting up Confluence, please see the Installation guid
4e at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide

从上面的报错可以看出JAVA环境变量(Program Files)有空格。该问题可以通过修改环境变量解决,具体环境变量的修改方式可以查看 jDK的安装 。我这里将路径修改为c:\java\jdk1.8.0_60 。修改完成后该报错解决。

问题二:gclog配置错误

直接运行启动文件时一闪而过,通过catalina.bat进行启动时,输出如下 :

 1C:\confluence\bin>catalina.bat run
 2If you encounter issues starting up Confluence, please see the Installation guid
 3e at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide
 4Using CATALINA_BASE:   "C:\confluence"
 5Using CATALINA_HOME:   "C:\confluence"
 6Using CATALINA_TMPDIR: "C:\confluence\temp"
 7Using JRE_HOME:        "C:\Java\jdk1.8.0_60"
 8Using CLASSPATH:       "C:\confluence\bin\bootstrap.jar;C:\confluence\bin\tomcat-juli.jar"
 9Invalid file name for use with -Xloggc: Filename can only contain the characters
10 [A-Z][a-z][0-9]-_.%[p|t] but it has been C:\confluence\bin\..\logs\gc-0星期一.-
110.-3_21.41.02.log
12Note %p or %t can only be used once
13Error: Could not create the Java Virtual Machine.
14Error: A fatal exception has occurred. Program will exit.

具体见下图:

catalina

从上面的报错可以看出某配置文件中包含loggc项设置有错,将源码包放在Linux下通过grep检索发现setenv.bat配置文件中包含该配置,如下:

1set CATALINA_OPTS=-Xloggc:"%atlassian_logsdir%\gc-%atlassian_timestamp%.log" %CATALINA_OPTS%

将该行配置注释掉后,再startup启动后,可以正常启动。

总结:tomcat包中包含catalina.bat(linux下为catalina.sh)文件,通过该文件可以通过catalina.bat run或catalina.bat debug 启动分析,具体如下:

 1Usage:  catalina ( commands ... )
 2commands:
 3  debug             Start Catalina in a debugger
 4  debug -security   Debug Catalina with a security manager
 5  jpda start        Start Catalina under JPDA debugger
 6  run               Start Catalina in the current window
 7  run -security     Start in the current window with security manager
 8  start             Start Catalina in a separate window
 9  start -security   Start in a separate window with security manager
10  stop              Stop Catalina
11  configtest        Run a basic syntax check on server.xml
12  version           What version of tomcat are you running?

通过该工具在没有日志输出一闪而过启动时,可以通过该方法方便的定位问题原因。