4

I'm deploying a Hybris application, which uses Jawr, to a Tomcat server. At start-up, JawrServlet throws a StackOverflow error.

It's hard to reproduce the error, but it always happens during the processing of CSSServlet. Shortly after this is logged:

[JawrRequestHandler] Initializing jawr config for request handler named CSSServlet

This is how that Servlet is configured in my web.xml:

     <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>

And here's a part of my console's log where the error happens:

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)
Henrique Ordine
  • 3,337
  • 4
  • 44
  • 70

2 Answers2

2

I'm using Jawr 3.3.3 and Bootstrap 3.1.0 and have experienced the same problem. The solution is to make a small "correction" in bootstrap.css ie. change:

a[href]:after {
    content: " (" attr(href) ")";
}
abbr[title]:after {
    content: " (" attr(title) ")";
}

to:

a[href]:after {
    content: " \0028" attr(href) "\0029";
}
abbr[title]:after {
    content: " \0028" attr(title) "\0029";
}

Notice that the only things changed are the opening and closing brackets (with their css code counterparts).

This way semantics remain the same but jawr doesn't fails. :) (I'm quite certain it's a regular expression things that's causing this..)

Josip Maslac
  • 270
  • 3
  • 8
1

In my CSS I had this class definition that might have been causing the problem:

.our-price-indicated-pdp-acessories,
.our-price-indicated-cart-dropdown
{
    color: #6E6E6E;
    font-size: 11px;
    line-height: 15px;
    font-weight: bold;
    text-align: center;
}

So I changed it to:

.our-priceind-pdpa,
.our-priceind-cartdrop{
    color: #6E6E6E;
    font-size: 11px;
    line-height: 15px;
    font-weight: bold;
    text-align: center;
}

And it worked again.

But it's hard to be absolutely sure. When the name of the class is really long, the error doesn't Always happen. The whole problem is a fantastic mind twist if you ask me.

My advice is, have a look in your CSS and see if you have long class names and try to redeploy the application without those CSS classes.

TecBrat
  • 3,643
  • 3
  • 28
  • 45
Henrique Ordine
  • 3,337
  • 4
  • 44
  • 70
  • Thanks for that - I just encountered this after I added bootstrap.css to my project... the long CSS class names appear to also be the cause. FYI, I'm using latest version of JAWR (3.3.3). As its not practical to edit the BS classes I've just had to resort to removing the `jawrCSSController` from my dispatcher servlet for now. – nickdos May 29 '13 at 06:23
  • Welcome, and thanks for the feedback. When I was working with JAWR there was a way though to exclude specific files from being compressed, so you wouldn't have to remove the whole jawrCSSController all together, but just configure it to not compress a certain CSS file. You might want to look into that. – Henrique Ordine May 29 '13 at 08:47
  • Oh yeah, somewhere in the jawrsetup.properties file. – Henrique Ordine May 29 '13 at 08:49