我正在将使用 Jawr 的 Hybris 应用程序部署到 Tomcat 服务器。在启动时,JawrServlet 抛出 StackOverflow 错误。
该错误很难重现,但它总是在处理 CSSServlet 的过程中发生。记录后不久:
[JawrRequestHandler] Initializing jawr config for request handler named CSSServlet
这是在我的 web.xml 中配置 Servlet 的方式:
<servlet>
<servlet-name>CSSServlet</servlet-name>
<servlet-class>net.jawr.web.servlet.JawrServlet</servlet-class>
<!-- Location in classpath of the config file -->
<init-param>
<param-name>configLocation</param-name>
<param-value>/jawrsetup.properties</param-value>
<!--<param-value>/jawrTEST.properties</param-value>-->
</init-param>
<init-param>
<param-name>type</param-name>
<param-value>css</param-value>
</init-param>
<init-param>
<param-name>mapping</param-name>
<param-value>/jawr-css</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
这是发生错误的控制台日志的一部分:
INFO | jvm 1 | main | 2013/01/29 11:20:16.081 | 11:20:16,036 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/pause.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.082 | 11:20:16,036 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/pause-ie.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.082 | 11:20:16,036 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/left-hover.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.087 | 11:20:16,036 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/left-hover-ie.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.087 | 11:20:16,036 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/right-hover.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.087 | 11:20:16,045 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/right-hover-ie.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.092 | 11:20:16,045 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/play-hover.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.092 | 11:20:16,045 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/play-hover-ie.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.092 | 11:20:16,045 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/pause-hover.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.093 | 11:20:16,045 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bk-ruby/pause-hover-ie.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.097 | 11:20:16,045 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url('/images/bg.png')
INFO | jvm 1 | main | 2013/01/29 11:20:16.098 | 11:20:16,046 [WrapperSimpleAppMain] DEBUG [Base64PostProcessorCssImageUrlRewriter] Skip encoding image resource : url("/images/content-bg.png")
INFO | jvm 1 | main | 2013/01/29 11:20:16.098 | 11:20:16,057 [WrapperSimpleAppMain] INFO [Base64ImageEncoderPostProcessor] Base64 Postprocessing done
INFO | jvm 1 | main | 2013/01/29 11:20:16.098 | 11:20:16,058 [WrapperSimpleAppMain] DEBUG [AbstractChainedResourceBundlePostProcessor] postprocessing bundle:/bundles/dmlights.css
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | Jan 29, 2013 11:20:16 AM org.apache.catalina.core.ApplicationContext log
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | SEVERE: StandardWrapper.Throwable
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | java.lang.StackOverflowError
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$LazyLoop.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$GroupTail.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$CharProperty.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$Ques.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$GroupHead.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$LazyLoop.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$GroupTail.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$CharProperty.match(Unknown Source)
INFO | jvm 1 | main | 2013/01/29 11:20:16.198 | at java.util.regex.Pattern$Ques.match(Unknown Source)
最佳答案
我正在使用 Jawr 3.3.3 和 Bootstrap 3.1.0 并且遇到了同样的问题。解决方案是在 bootstrap.css ie 中做一个小的“更正”。改变:
a[href]:after {
content: " (" attr(href) ")";
}
abbr[title]:after {
content: " (" attr(title) ")";
}
至:
a[href]:after {
content: " \0028" attr(href) "\0029";
}
abbr[title]:after {
content: " \0028" attr(title) "\0029";
}
请注意,唯一改变的是左括号和右括号(及其对应的 css 代码)。
这样语义保持不变,但jawr 不会失败。 :)
(我很确定这是导致这种情况的正则表达式的东西..)