开发者

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开发者_JAVA技巧. 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!


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.


I solved this problem by repackaging yuicompressor myself to include most of the rhino source. See my reply to Howard M. Lewis Ship.

The repackaged source can be found here : http://viscri.co.uk/labs/tapestry/yuicompressor-rhino-bugfix-5.0.jar. Just add this to your pom:

<dependency>
   <groupId>yuicompressorbugfix</groupId>
   <artifactId>yuicompressor-rhino-bugfix</artifactId>
   <version>5.0</version>
</dependency>

If you don't run your own version of nexus, you'll have to install it on the machine that you want to build on. This is the command you need I think: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

You'll also need to exclude the yuicompressor version that tapestry pulls in:

<dependency>
   <groupId>org.apache.tapestry</groupId>
   <artifactId>tapestry-yuicompressor</artifactId>
   <version>5.3.2</version>
   <exclusions>
       <exclusion>
             <groupId>com.yahoo.platform.yui</groupId>
             <artifactId>yuicompressor</artifactId>
       </exclusion>
   </exclusions>

This should work.


The selected answer's (as of 9/26/2014) jar doesn't exist anymore.

So, I created a fork of yuicompressor where entire rhino package is embedded into the yuicompressor package and namespaced it under yui.

https://github.com/timothykim/yuicompressor

Just clone the repo and run ant to obtain the jar.

Hope this helps anyone else who stumbles unto this problem.


Really, you're having class loader problems in JBoss?

You're going to have to do some kind of exclusion on the competing rhino JAR file. Why is Rhino on the classpath? It may be an optional feature of JBoss you can turn off and avoid the conflict that way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜