set TC_INSTALL_DIR=<本地Terracotta安装目录>
set TC_CONFIG_PATH=<本地tc-config.xml的完整文件名>
call %TC_INSTALL_DIR%\bin\dso-env.bat -q
set JAVA_OPTS=%JAVA_OPTS% %TC_JAVA_OPTS%
startup.bat
等Tomcat启动以后,查看Tomcat日志文件,确认Terrocotta已经启动。比如在Mac环境中,使用Terracotta 3.0.1,看到的日志将包括如下内容:
2009-07-17 10:57:39,425 INFO - Terracotta 3.0.1, as of 20090514-130552 (Revision 12704 by cruise@su10mo5 from 3.0)
2009-07-17 10:57:39,828 INFO - Configuration loaded from the file at '/Users/lma/tc-config.xml'.
2009-07-17 10:57:39,975 INFO - Log file: '/Users/lma/apps/tomcat-5.5.27/bin/logs/client-logs/terracotta-client.log'.
2009-07-17 10:57:42,312 INFO - Connection successfully established to server at 192.168.0.102:9510
重新启动Tomcat。再打开前面的页面。
您可能还会遇见TCNonPortableObjectError,不过这次的错误是有关boot jar的:
com.tc.exception.TCNonPortableObjectError:
*******************************************************************************
Attempt to share an instance of a non-portable class referenced by a portable class. This unshareable class must be in the DSO boot jar. It also has superclasses which must be in the DSO boot jar. Please add all of these classes to the boot jar configuration and re-create the DSO boot jar.
只要认真阅读错误信息,按照提示的方法配置tc-config.xml文件,然后执行下面的命令重新生成boot jar文件,再重新启动Tomcat就可以了:
$TERRACOTTA_HOME/bin/make-boot-jar.sh -f $TOMCAT_HOME/tc-config.xml
2. 如果遇见TCNonPortableObjectException异常,说明在Session中共享的类没有包含在tc-config.xml的 instrumented-classes配置中。一般在异常新吸力面Terracotta会包含需要添加到配置文件中的信息,比如:
<instrumented-classes>
<include>
<class-expression>num.NumberGuessBean</class-expression>
</include>
<instrumented-classes>
</instrumented-classes>
只要按照提示把配置信息放到tc-config.xml文件中,然会从新启动Tomcat即可。
附件-tc-config.xml
<tc:tc-config xmlns:tc="http://www.terracotta.org/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-4.xsd">
<servers>
<!-- For more information on working with the Terracotta configuration file, including how to add
more servers, see http://www.terracotta.org/web/display/docs/About+Terracotta+Configuration+Files.
Edit the following server element so that its host attribute contains the value matching the
hostname for the Terracotta server. -->
<!-- Check that the TIM shown in the <module> element's name attribute matches the Tomcat version you
are using. The TIM listed here, "tim-tomcat-5.5" is for Tomcat 5.5. For example, if you are using
Tomcat 6.0, edit the name to "tim-tomcat-6.0". -->
<clients>
<modules>
<module name="tim-tomcat-6.0" version="1.1.0" />
</modules>
</clients>
<!-- Using <web-application> elements, enter the context root of the web application being clustered.
If you are clustering more than one web application, use one <web-application> element per application.
Two example <web-application> elements are shown below. Edit or remove these elements as needed.
To set the value of the <web-application> element to the default web-application context, use the
special value "ROOT" (without quotation marks). -->
<application>
<dso>
<instrumented-classes>
<include>
<class-expression>num.NumberGuessBean</class-expression>
</include>
<include>
<class-expression>cal.*</class-expression>
</include>
</instrumented-classes>
<web-applications>
<web-application>examples</web-application>
</web-applications>
</dso>
</application>
</tc:tc-config>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lima01/archive/2009/07/25/4379572.aspx