14

I have been using YuiCompressorTask (latest version) on my project for a very long time with no issues. After upgrading to Oracle's Java 1.7 package on OSX, hwoever, it breaks with the following exception (this is for a javascript file; it works fine with a css file):

[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

I can switch back to Apple's Java 1.6 and it works fine. My question is, is there a way around this? I really can't continue on 1.6 any longer.

Alice Young
  • 1,742
  • 2
  • 11
  • 19
  • There is a bug filed for this on GitHub: [Can't find bundle for base name org.mozilla.javascript.resources.Messages, locale en_US · Issue #302 · yui/yuicompressor](https://github.com/yui/yuicompressor/issues/302) – Stephen Ostermiller Mar 06 '20 at 19:38
  • 2
    YUICompressor currently only supports ECMAScript 3; there are no current plans to upgrade it to support new ECMAScript constructs due to the engineering work required and the fact that I am the sole maintainer. – TML Mar 10 '20 at 15:18

4 Answers4

8

A bit old question, but I run in the same error today.

In my case the problem was a syntax error in my JavaScript, I forgot a } after a cut&paste operation.

I used this online tool (http://refresh-sf.com/) to compress the js file, and it returned some weird error, but more useful than the java exception stack...

Hope this help...

Andrew
  • 18,680
  • 13
  • 103
  • 118
endorama
  • 498
  • 7
  • 15
4

I decided to switch to the Google Closure Compiler, abandoning the last of the YUI components I've used over the years. I get tons of warnings in the build log, but it does work. sigh

Alice Young
  • 1,742
  • 2
  • 11
  • 19
3

Really old question, but if anyone is still using yui-compress I had the same error and it turned out yui-compress doesn't like trailing comma after arguments in function calls. For example:

foo(a, b, c);

is OK, but

foo(a, b, c,);

is not.

  • See https://stackoverflow.com/questions/11276135/yuicompressortask-cant-find-bundle-for-base-name-org-mozilla-javascript-resou#comment107248606_11276135 – TML Mar 10 '20 at 15:19
0

old question but i had to put a comment with my other finds.

It doesnt support define variables with let.

And a new find today, it doesnt allow to define functions with params with a default value

In my case i had to change

function convertDate(inputFormat,type=1)

to

function convertDate(inputFormat,type) {

if(typeof(type)==="undefined")
type=1;

As tip to find why it fails, the best way is to clone the javascript that you are using, and start a new empty, and add blocks until you find which one produces the error.

Hamboy75
  • 938
  • 1
  • 11
  • 22
  • See https://stackoverflow.com/questions/11276135/yuicompressortask-cant-find-bundle-for-base-name-org-mozilla-javascript-resou#comment107248606_11276135 – TML Mar 10 '20 at 15:19