Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...