I am having a problem where the YUI Compressor works fine in my IDE and even when I deploy tomcat using the maven goal tomcat:run
, but throws a StringIndexOutOfBoundsException when I run the application as a WAR file:
java.lang.StringIndexOutOfBoundsException: String index out of range: 412
at java.lang.String.substring(String.java:1934)
at .yahoo.platform.yuipressor.JavaScriptCompressor.printSourceString(JavaScriptCompressor.java:267)
at .yahoo.platform.yuipressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:330)
at .yahoo.platform.yuipressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)
Now, I know a lot of people have been reporting this problem, such as below: Yui pressor StringIndexOutOfBoundsException on jboss
You can find other people mentioning on other places on the web.
It has been suggested that you need to bundle the rhino files with the yui pressor in the same jar to avoid the classpath error.
I looked further, and I realized that Yahoo released version 2.4.7, which does this. So I included this new version into my project and made sure to remove the other jars, and I still get the same error.
How do I fix this?
I am having a problem where the YUI Compressor works fine in my IDE and even when I deploy tomcat using the maven goal tomcat:run
, but throws a StringIndexOutOfBoundsException when I run the application as a WAR file:
java.lang.StringIndexOutOfBoundsException: String index out of range: 412
at java.lang.String.substring(String.java:1934)
at .yahoo.platform.yui.pressor.JavaScriptCompressor.printSourceString(JavaScriptCompressor.java:267)
at .yahoo.platform.yui.pressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:330)
at .yahoo.platform.yui.pressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)
Now, I know a lot of people have been reporting this problem, such as below: Yui pressor StringIndexOutOfBoundsException on jboss
You can find other people mentioning on other places on the web.
It has been suggested that you need to bundle the rhino files with the yui pressor in the same jar to avoid the classpath error.
I looked further, and I realized that Yahoo released version 2.4.7, which does this. So I included this new version into my project and made sure to remove the other jars, and I still get the same error.
How do I fix this?
Share Improve this question edited May 23, 2017 at 11:51 CommunityBot 11 silver badge asked Dec 8, 2011 at 9:55 egervariegervari 22.5k34 gold badges123 silver badges175 bronze badges 1- The above classpath arises as 'org/mozilla/javascript/Parser' class has different implementation in yuipressor than rhino and particularly seen while in webapp build using maven. Issue could be resolved by following this blog link julienlete/blog/2008/10/80 – Sandy Commented Feb 11, 2013 at 18:55
3 Answers
Reset to default 4If you are using maven
build just exclusion rhino or remove js-1.7R2.jar
/ rhino-1.7R4.jar
/ rhino-1.7R3.jar
file from your classpath
,
<dependency>
<groupId>.yahoo.platform.yui</groupId>
<artifactId>yuipressor</artifactId>
<version>2.4.7</version>
<exclusions>
<exclusion>
<artifactId>js</artifactId>
<groupId>rhino</groupId>
</exclusion>
</exclusions>
</dependency>
Hope it will solve your problem.
check your classpath and delete rhino-.jar(backup first),try it again.i solved the same problem after i removed rhino-.jar.
This question should solve your problem, especially if you use maven:
Yui pressor StringIndexOutOfBoundsException on jboss