jboss 上的 Yui 压缩器 StringIndexOutOfBoundsException [英] Yui compressor StringIndexOutOfBoundsException on jboss

查看:34
本文介绍了jboss 上的 Yui 压缩器 StringIndexOutOfBoundsException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 2.4.6 最小化 yui 时,我遇到了这个问题:

When minimising yui with 2.4.6, I get this problem:

java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:232

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)

它在通过我的 IDE 启动时有效,但在部署到 jboss 时却没有.这个地方:http://yuilibrary.com/forum/viewtopic.php?p=20086有一些同一个问题的讨论.

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.

显然问题在于 org/mozilla/javascript/Parser 位于从我的 maven 配置中提取的两个 jar 中:

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>

有什么办法可以使用 maven 排除等或通过升级我的 YUI 版本来解决这个问题.它只是不起作用而且我不想编写自定义类加载器,这似乎很愚蠢.

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.

请帮忙!

推荐答案

我通过自己重新打包 yuicompressor 以包含大部分 Rhino 源来解决这个问题.请参阅我对 Howard M. Lewis Ship 的回复.

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

重新打包的源代码可以在这里找到:http://viscri.co.uk/labs/tapestry/yuicompressor-rhino-bugfix-5.0.jar.只需将此添加到您的 pom 中:

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>

如果您不运行自己的 nexus 版本,则必须将其安装在您想要构建的机器上.这是我认为您需要的命令:http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

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

您还需要排除挂毯引入的 yuicompressor 版本:

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>

这应该可行.

这篇关于jboss 上的 Yui 压缩器 StringIndexOutOfBoundsException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆