glassfish里抛出如下错误:
org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP
PWC6199: Generated servlet error:
string:///XXXX_jsp.java:169: constant string too long
PWC6199: Generated servlet error:
Note: string:///XXXX_jsp.java from uses unchecked or unsafe operations.
折腾了好久,始终找不到原因。
最后,经老大指点,并实际测试。终于发现原因是由于glassfish里 把genStrAsCharArray 项设为 true 导致的。
解决办法:
具体为:
把 $GLASSFISH_HOME/domains/domain1/config/default-web.xml 里的
<param-name>genStrAsCharArray</param-name>
<param-value>true</param-value>
修改为:
<param-name>genStrAsCharArray</param-name>
<param-value>false</param-value>
genStrAsCharArray |
false |
If |
The default-web.xml file defines features such as filters and security constraints that apply to all web applications. The parameter, development=true, (the default value for developer profile) enables changes made to JSPTM – code to be instantly visible to the clients. However, there is a cost associated with this. To avoid the cost of checking whether the JSP code has been modified and hence its recompilation, the first parameter, development=false, can be used to set development to false since this scenario is unlikely in a production system. This check affects application scalability when multiple users request the same JSP class. The second parameter, genStrAsCharArray=true, changes the way the JSPs are generated by generating char arrays for every static strings in the JSP class like for example, the HTML tags. By default, the JSPcode writer must call the toCharArray() on every String on every invocation of the JSPclass.
Settings in default-web.xml. ($GLASSFISH_HOME/domains/domain1/config/default-web.xml)
<init-param>
<param-name>development</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>genStrAsCharArray</param-name>
<param-value>true</param-value>#-> 此处上面应该修改为false
</init-param>
The more configuration optimization can be done using the document from SUN you can download it
With this setting all String
values are declared as static char[]
as follows:
static char[] _char_array_1 = "someString".toCharArray();
and used as follows:
out.write(_char_array_1);
instead of being used as follows:
out.write("someString");
This has two clear benefits:
- A
char[]
has less memory overhead thanString
. - The
toCharArray()
doesn't need to be (implicitly) called on everyout.write(string)
anymore.
Sounds like microoptimization, but those little bits counts a lot in a heavily visited website.
This setting is by the way not JBoss AS specific. It's Jasper specific, the JSP compiler of Apache Tomcat which is also used in under each JBoss AS and Sun Glassfish.
参考网址: http://docs.oracle.com/cd/E19879-01/820-4343/abedw/index.htmlhttp://www.binbert.com/blog/2010/04/glassfish-performance-tunning/作者: 乐意黎,原创。禁止转载
原文地址: http://blog.csdn.net/aerchi/article/details/45394231