jsp.java from uses unchecked or unsafe operations.

glassfish里抛出如下错误:

org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSPPWC6199: Generated servlet error:string:///XXXX_jsp.java:169: constant string too longPWC6199: 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 set totrue, generates text strings aschararrays, which improves performance in some cases.

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.

<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 allStringvalues are declared asstatic char[]as follows:

and used as follows:

instead of being used as follows:

This has two clear benefits:

Achar[]has less memory overhead thanString.ThetoCharArray()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’sJasperspecific, the JSP compiler of Apache Tomcat which is also used in under each JBoss AS and Sun Glassfish.

参考网址: ://www.binbert.com/blog/2010/04/glassfish-performance-tunning/

作者: 乐意黎,原创。禁止转载

原文地址:

欲望以提升热忱,毅力以磨平高山。

jsp.java from uses unchecked or unsafe operations.

相关文章:

你感兴趣的文章:

标签云: