[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
在JSF中Session共享的DSO配置问题  XML
Forum Index -> Terracotta 中文社区
Author Message
cxh

neo

Joined: 11/29/2009 17:53:15
Messages: 7
Offline

前不久根据lima的博客学习用Terracott3.1.1 + Tomcat6共享session,配置好后用JSP页面测试,session确实共享了,用Apache +Tomcat6做了负载均分,用JSP页面测试页没有问题。
但是该用JSF后,一直遇到TCNonPortableObjectError,按照错误提示往tc-config.xml的<dso>中不断的加东西,打开页面的速度越来越慢,最后问题还是没有解决
com.tc.exception.TCNonPortableObjectError:
*******************************************************************************
Attempt to share an instance of a non-portable class referenced by a portable class. This
unshareable class is a JVM- or host machine-specific resource. Please ensure that instances
of this class don't enter the shared object graph.

For more information on this issue, please visit our Troubleshooting Guide at:
http://terracotta.org/kit/troubleshooting

Referring class : java.util.ArrayList
Thread : http-8088-1
JVM ID : VM(0)
Unshareable class: java.lang.ref.WeakReference

Action to take:

1) Change your application code
* Ensure that no instances of java.lang.ref.WeakReference
are added to any shared object graph

- OR -

2) Mark the offending field as transient (and thus not shared)
* edit your tc-config.xml file
* locate the <dso> element
* add this snippet inside the <dso> element, above the <locks> element

<transient-fields>
<field-name>null</field-name>
</transient-fields>

* if there is already a <transient-fields> element present, simply add
the new field inside it
我的tc-config.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<tc:tc-config xsi:schemaLocation="http://www.terracotta.org/schema/terracotta-5.xsd" xmlns:tc="http://www.terracotta.org/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<servers>
<server host="10.96.18.245" name="server1">
<dso-port>9510</dso-port>
</server>
</servers>

<clients>
<logs>bin/logs/%(webserver.log.name)</logs>
<modules>
<module name="tim-tomcat-6.0" version="2.0.2"/>
<module name="tim-tomcat-5.5" version="2.0.2"/>
<module name="tim-tomcat-common" version="2.0.2"/>
</modules>

</clients>
<application>
<dso>
<instrumented-classes>
<include>
<class-expression>com..*</class-expression>
</include>
<include>
<class-expression>java.util..*</class-expression>
<honor-transient>true</honor-transient>
</include>
<include>
<class-expression>org.operamasks..*</class-expression>
<honor-transient>true</honor-transient>
</include>
<include>
<class-expression>javax.faces.component..*</class-expression>
<honor-transient>true</honor-transient>
</include>
<include>
<class-expression>com.sun.facelets.el.TagMethodExpression</class-expression>
<honor-transient>true</honor-transient>
</include>
<include>
<class-expression>javax.el..*</class-expression>
<honor-transient>true</honor-transient>
</include>
<include>
<class-expression>javax.faces.event.PhaseId</class-expression>
<honor-transient>true</honor-transient>
</include>

</instrumented-classes>

<additional-boot-jar-classes>
<include>java.beans.FeatureDescriptor</include>
<include>java.beans.PropertyDescriptor</include>
<include>java.util.logging.Logger</include>
<include>java.util.logging.LogManager</include>
<include>java.util.logging.LogManager$RootLogger</include>
<include>java.util.Locale</include>
<include>java.util.logging.Level</include>
<include>java.security.BasicPermission</include>
<include>java.security.Permission</include>
<include>java.util.logging.LoggingPermission</include>
<include>java.beans.PropertyChangeSupport</include>
<include>java.util.logging.LogManager$LogNode</include>
<include>java.util.logging.StreamHandler</include>
<include>java.util.logging.Handler</include>
<include>java.util.logging.ConsoleHandler</include>
</additional-boot-jar-classes>

<transient-fields>
<field-name>java.beans.PropertyDescriptor.propertyTypeRef</field-name>
<field-name>java.beans.PropertyDescriptor.readMethodRef</field-name>
<field-name>java.beans.PropertyDescriptor.writeMethodRef</field-name>
<field-name>java.beans.FeatureDescriptor.classRef</field-name>
<field-name>java.util.ArrayList</field-name>
</transient-fields>

<web-applications>
<web-application>test</web-application>
</web-applications>
</dso>
</application>
</tc:tc-config>
本来在<dso>里只有 <include>
<class-expression>com..*</class-expression>
</include>
后面的是按照TCNonPortableObjectError的异常提示加的

疑问:1. 我只是想共享HttpSession,为什么要提示我在<dso>里加这么多的东西
2. 它提示的需要添加的类我都还没放到过session里,现在只是个简单的JSF页面,添加了一些一个开源组织operamasks的javaScriptd的库来美观,为什么要加到<dso>里。
3. 连可能用到的java.uitl里的类都要全加到<dso>里吗?
lima

consul
[Avatar]
Joined: 06/22/2009 10:12:31
Messages: 361
Offline

Session共享实际上就是共享Session的内部实现有关的数据结构,对于Tomcat来说就是一个核心的MAP。然后放到Session里面的数据都是需要Terracotta监管的共享数据。这实际上就是对DSO的一个有针对性的应用而已。所以DSO所需要的加锁、instrumentation等等都不能避免。

由于你用了其他的一些平台,他们肯定是往Session里面方了一些额外的信息,导致你需要把这些信息的类都要放在tc-config.xml里面。

建议你不要一股脑把java.util.*, com..*这样的东西放到配置文件中。他们会导致大量的类被instrument,当然会严重影响效率。

你可以通过dev-console查看当前共享的数据的列表,找出来你不需要共享的数据, 在tc-config里面标成transient,这样能减少很多不必要的麻烦。

最后,我们马上推出新的Session集群Express解决方案,到时候就不会对instrumentation有这么多的要求了。使用起来会更方便。
cxh

neo

Joined: 11/29/2009 17:53:15
Messages: 7
Offline

谢谢lima的回复,您说“放到Session里面的数据都是需要Terracotta监管的共享数据”,我有几个地方不太明白,希望您指教。
1. 我打开的只是个普通的JSF页面,很多javax.faces.component..*或者java.util里的数据我都还没放到过session里,为什么错误提示我需要添加它们?
2. 是否所有页面用到的类都要Terracotta监管,包括JSF自己封装的类?
3. 我看到structs,Spring和Hibinate都有相关的TIM,请问JSF有吗?我好像没有找到。如果自己写个关于JSF的TIM复杂吗?
4参考文档有吗?
 
Forum Index -> Terracotta 中文社区
Go to:   
Powered by JForum 2.1.7 © JForum Team