Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yui compressor StringIndexOutOfBoundsException on jboss

When minimising yui with 2.4.6, I get this problem:

java.lang.StringIndexOutOfBoundsException: String index out of range: 232

at java.lang.String.substring(String.java:1934)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.printSourceString(JavaScriptCompressor.java:267)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:330)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)

It works when started through my IDE but when deployed to jboss it doesn't. This place: http://yuilibrary.com/forum/viewtopic.php?p=20086 has some discussion of the same problem.

Apparently the issue is around org/mozilla/javascript/Parser being in the two jars that are pulled in from my maven config:

<dependency>
<groupId>com.yahoo.platform.yui</groupId>
<artifactId>yuicompressor</artifactId>
<version>2.4.6</version>
</dependency>

Is there any way I can solve this using maven exclusions etc. or by upgrading my version of YUI. It seems daft that it just doesn't work and I don't want to have to write a custom classloader.

Please help!

like image 289
lukewm Avatar asked Jul 11 '11 15:07

lukewm


1 Answers

Workaround: For JBoss AS 7.1.1.Final and YUICompressor 2.4.7

Exclude rhino from dependency:

        <dependency>
          <groupId>com.yahoo.platform.yui</groupId>
          <artifactId>yuicompressor</artifactId>
          <version>${yuicompressor.version}</version>
          <exclusions>
            <exclusion>
               <groupId>rhino</groupId>
               <artifactId>js</artifactId>
            </exclusion>
          </exclusions>
        </dependency>

Why? See https://github.com/greenlaw110/greenscript/pull/29#issuecomment-4017147

Note: if you have a rhino in classpath by some other way, so seems like you'll get this error again.

like image 63
Alexander Shagin Avatar answered Nov 07 '22 03:11

Alexander Shagin