YuiCompressorTask:“找不到基本名称 org.mozilla.javascript.resources.Messages, locale en_US”

2022-09-04 03:03:58

我在我的项目中使用YuiCompressorTask(最新版本)很长一段时间了,没有任何问题。在OSX上升级到Oracle的Java 1.7软件包后,hwoever,它会中断,并出现以下异常(这是针对javascript文件;它适用于css文件):

[yuiCompress] java.lang.reflect.InvocationTargetException
[yuiCompress]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[yuiCompress]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[yuiCompress]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[yuiCompress]   at java.lang.reflect.Method.invoke(Method.java:601)
[yuiCompress]   at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
[yuiCompress]   at ww.ant.YuiCompressorTask.execute(YuiCompressorTask.java:40)
[yuiCompress]   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[yuiCompress]   at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[yuiCompress]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[yuiCompress]   at java.lang.reflect.Method.invoke(Method.java:601)
[yuiCompress]   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[yuiCompress]   at org.apache.tools.ant.Task.perform(Task.java:348)
[yuiCompress]   at org.apache.tools.ant.Target.execute(Target.java:390)
[yuiCompress]   at org.apache.tools.ant.Target.performTasks(Target.java:411)
[yuiCompress]   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[yuiCompress]   at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[yuiCompress]   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[yuiCompress]   at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[yuiCompress]   at org.apache.tools.ant.Main.runBuild(Main.java:809)
[yuiCompress]   at org.apache.tools.ant.Main.startAnt(Main.java:217)
[yuiCompress]   at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[yuiCompress]   at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[yuiCompress] Caused by: java.util.MissingResourceException: Can't find bundle for base name org.mozilla.javascript.resources.Messages, locale en_US
[yuiCompress]   at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499)
[yuiCompress]   at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322)
[yuiCompress]   at java.util.ResourceBundle.getBundle(ResourceBundle.java:796)
[yuiCompress]   at org.mozilla.javascript.ScriptRuntime.getMessage(ScriptRuntime.java:3316)
[yuiCompress]   at org.mozilla.javascript.ScriptRuntime.getMessage0(ScriptRuntime.java:3273)
[yuiCompress]   at org.mozilla.javascript.Parser.addError(Parser.java:121)
[yuiCompress]   at org.mozilla.javascript.TokenStream.getToken(TokenStream.java:773)
[yuiCompress]   at org.mozilla.javascript.Parser.peekToken(Parser.java:161)
[yuiCompress]   at org.mozilla.javascript.Parser.parse(Parser.java:361)
[yuiCompress]   at org.mozilla.javascript.Parser.parse(Parser.java:337)
[yuiCompress]   at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312)
[yuiCompress]   at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)
[yuiCompress]   at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:131)
[yuiCompress]   ... 22 more

我可以切换回Apple的Java 1.6,它工作正常。我的问题是,有没有办法解决这个问题?我真的不能再继续1.6了。


答案 1

一个有点老的问题,但我今天在同样的错误中运行。

在我的情况下,问题是我的JavaScript中的语法错误,我在剪切和粘贴操作后忘记了}。

我用这个在线工具(http://refresh-sf.com/)压缩了js文件,它返回了一些奇怪的错误,但比java异常堆栈更有用...

希望这有帮助...


答案 2

我决定切换到Google Closure Compiler,放弃了我多年来使用的最后一个YUI组件。我在构建日志中收到大量警告,但它确实有效。叹息


推荐