I just wanted to deploy my web application on tomcat and realized that my javascript libraries wouldn’t be minified. Minification failed with strange “StringIndexOutOfBoundsException” Exceptions:
[ERROR] AssetsModule.ResourceMinimizer String index out of range: 142644 java.lang.StringIndexOutOfBoundsException: String index out of range: 142644 at java.lang.String.substring(String.java:1934) at com.yahoo.platform.yui.compressor.JavaScriptCompressor.printSourceString(JavaScriptCompressor.java:267)
There seems to be a bug with yuicompressor and some specially patched rhino classes. See https://github.com/greenlaw110/greenscript/pull/29#issuecomment-4017147 and http://stackoverflow.com/questions/6652550/yui-compressor-stringindexoutofboundsexception-on-jboss.
The solution was to modify the pom.xml as follows:
<dependency> <groupId>org.apache.tapestry</groupId> <artifactId>tapestry-yuicompressor</artifactId> <version>${tapestry-release-version}</version> <exclusions> <exclusion> <artifactId>yuicompressor</artifactId> <groupId>com.yahoo.platform.yui</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.yahoo.platform.yui</groupId> <artifactId>yuicompressor</artifactId> <version>2.4.7</version> <exclusions> <exclusion> <groupId>rhino</groupId> <artifactId>js</artifactId> </exclusion> </exclusions> </dependency>