from tomcat to resin,一点体会

下午折腾了很久的服务器配置,写点备忘

起因是信息网那套tag里面的boardList在tomcat下没法用,因为有个pClassCode这样的属性,tomcat里面会报错Unable
to find setter method。google一番查到一个解释如下:
Q. I have a bean with a property whose second letter is capitalized.

Why won ‘t my JSP page that uses this bean compile?

A. This may not happen often, but can be difficult to determine why.

The reason is found in the Java Beans specification, where in section

"8.8 Capitalization of inferred names " it states:

Thus when we extract a property or event name from the middle of an

existing Java name, we normally convert the first character to lower

case. However to support the occasional use of all upper-case names,

we check if the first two characters of the name are both upper case

and if so leave it alone.

This means that if you have a bean with a setter method of "setXLoc ",

then the inferred property is "XLoc ", not "xLoc ". If you used this

bean in a JSP page and you tried to use "xLoc " as the property, it

would not compile. Using "XLoc " as the property would succeed.

If you insist on using "xLoc " on the JSP page, you can make this
possible

by creating a BeanInfo class for the bean. The following is an example

of such a BeanInfo class for a simple bean called Coordinate. It

explicitly defines the properties of the bean to be "xLoc " and "yLoc
".

import java.beans.*;

public class CoordinateBeanInfo extends SimpleBeanInfo

{

private final static Class beanClass = Coordinate.class;

public PropertyDescriptor[] getPropertyDescriptors()

{

try {

PropertyDescriptor xLocDesc new PropertyDescriptor( "xLoc ",beanClass,
"getXLoc ", "setXLoc ");

PropertyDescriptor yLocDesc new PropertyDescriptor( "yLoc ",beanClass,
"getYLoc ", "setYLoc ");

PropertyDescriptor [] pdv = { xLocDesc, yLocDesc };

return pdv;

} catch (IntrospectionException e) {

throw new Error(e.toString());

}

}

}

尝试这里面提到的这个附加类的方法,不知所云。没有tag的源码,不能改属性名。无奈之下改用resin。
一直不用resin的原因主要是intellij默认整合了tomcat,调试起来比较爽。以前找到过一个resinplugin,但是只能用在
intellij4.0上(我现在用的是4.5)。开始google,惊奇的发现那个resinplugin的project已经发布2.9.2版了(我
上次用的还是1.0.2版-_-),下载,不大知道怎么用。翻看intellij的官方Forum,发现一个很奇怪的方法可以work:)
很好很好。大概的思路就是把resin的Jar导入,然后当作一个Application来运行ResinServer类的main方法。写好conf和
各种参数就ok了。原文如下:

I just
set it up as a regular application, like this:

Main class: com.caucho.server.http.ResinServer

VM parameters:
-Dcom.sun.management.jmxremote
-Dresin.home=.
-Dlog4j.configuration=c:/dev/projects/template/webapp/conf/log4j.properties
-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=12345
-Dfile.encoding=UTF-8 -XX:PermSize=64M -XX:MaxPermSize=64M

Program parameters:
-conf resin.xml

Working directory:
C:\dev\projects\template\webapp

Use classpath and JDK of module:
webapp

Then I can "run" it or "debug" it with no problem and it logs directly
to the console in IDEA.


可怜plugin的那个作者在下面无奈的说”I know that the need for a
plugin is not that big…“,哈哈

然后又遇到过一个问题,就是resin说什么找不到jstl的类。。折腾了半天,把代码里的jstl都去掉,remove掉intellij里面的各个地
方加上的jstl的类库,remove掉docbase里面的jstl库,ok了。resin2.x版本都不支持jstl的tld的xml
schema。。所以没法在resin2.x里面用jstl。配一个resin3又太麻烦了。(我现在还没空学这个)

resin爽的地方有两个,一个是特别快,启动和编译页面的速度都好过tomcat不少;二是没有tomcat那个莫名其妙的server
path和context
path混淆的问题,tomcat里面写/开头的路径都会解释成server-dependent的(好像应该叫server-side?),弱智的
bug。。。

嗯,记录完毕

Join the Conversation

1 Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.