Bug 457336

Summary: Trying to invoke rhino yields traceback
Product: [Fedora] Fedora Reporter: Toshio Ernie Kuratomi <a.badger>
Component: rhinoAssignee: Lillian Angel <langel>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 11CC: lmacken, selliott4
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.7-0.6.r2.fc11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-16 02:00:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Spec file patch to include the treetable code
none
spec update
none
Fix a warning in /usr/bin/rhino
none
A patch for the Rhino null pointer exception none

Description Toshio Ernie Kuratomi 2008-07-31 00:09:28 UTC
Description of problem:
I'm trying to invoke rhino in order to run some javascript during package build.
 Instead of getting the script to run or even a shell, I get a traceback.

Version-Release number of selected component (if applicable):
rhino-1.6-0.1.r5.1jpp.2.fc7.noarch
java-1.6.0-openjdk-1.6.0.0-0.16.b09.fc9.i386.rpm
java-1.5.0-gcj-1.5.0.0-21.fc9.i386.rpm

/usr/bin/java points at the openjdk java

How reproducible:
Everytime

Steps to Reproduce:
1. java org.mozilla.javascript.tools.shell.Main

or

1. java -jar /usr/share/java/rhino-1.6.jar
  
Actual results:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/mozilla/javascript/tools/shell/Main
Caused by: java.lang.ClassNotFoundException: org.mozilla.javascript.tools.shell.Main
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:

Expected results:
$ java -jar js.jar
Rhino 1.6 release 5 2006 11 18
js> 


Additional info:

Comment 1 Matt Wringe 2008-07-31 01:54:43 UTC
The current version of rhino we have is old and parts of it had to be removed
due to copyright issues.

The only real solution to this will probably be to update to the lastest version
of rhino.

Comment 2 Toshio Ernie Kuratomi 2008-07-31 17:04:32 UTC
Okay.  Any plans to do that?  Unless there's another way to get it to interpret
a javascript file it seems as though the current version is somewhat useless.

Comment 3 Matt Wringe 2008-07-31 17:11:33 UTC
The current version in there is not so much for using it as a tool but as a
dependency for other projects (who use the class files directly).

I have the newer version building in an rpm but it needs some work to patch out
a few things (like automatic dependency downloading during build).

Comment 4 Michael DeHaan 2008-09-24 21:35:46 UTC
Have we tried to contact upstream to resolve license issues with the new rhino?

If not I'd volunteer to try to explain the problem.

Comment 5 Matt Wringe 2008-09-26 13:49:30 UTC
the new rhino doesn't have the licensing issues, its the older version that we have in fedora that had the issues (and hence why the current version in fedora is a little messed up).

Comment 6 Toshio Ernie Kuratomi 2008-11-15 21:48:16 UTC
Any update on getting the the new rhino tested?  I actually have a second package that needs rhino-1.7 to build so I'm now doubly interested in seeing this :-)

Comment 7 Toshio Ernie Kuratomi 2009-03-20 23:13:30 UTC
rhino 1.7 is now in the repository, can we undisable these portions?

Comment 8 Toshio Ernie Kuratomi 2009-03-21 00:16:07 UTC
Hi langel, thanks for updating rhino!  I owe you next fudcon.

I think there's two related issues going on here.  Unfortunately, I know nothing about java so I'm only going to be able to offer a little bit of help here.

1) The treetable code that was under a bad license in 1.6 is now included in the 1.7 tarball under a BSD-like license but the build.xml in the debugger directory is not picking it up.  I'll attach a patch to the spec file that illustrates this problem and a hacky way to fix it.  I don't know ant but I know that someone who does could fix this more appropriately.

With this fix to the build, I'm now able to use rhino to build dojo's shrinksafe, 1.3.0rc1.  Yay!  This fixes the more serious half of my problems.

2) The original issue reported here is that rhino cannot be invoked as a shell.  Even with the build fix this is still the case (although we've progressed to a NullPointerException instead of NoClassDefFound::

$ java org.mozilla.javascript.tools.shell.Main -e 'print("i")'
Exception in thread "main" java.lang.NullPointerException
	at org.mozilla.javascript.Kit.classOrNull(Kit.java:92)
	at org.mozilla.javascript.tools.shell.ShellLine.getStream(ShellLine.java:65)
	at org.mozilla.javascript.tools.shell.Global.init(Global.java:153)
	at org.mozilla.javascript.tools.shell.Global$1.run(Global.java:108)
	at org.mozilla.javascript.Context.call(Context.java:499)
	at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
	at org.mozilla.javascript.tools.shell.Global.init(Global.java:105)
	at org.mozilla.javascript.tools.shell.Main.processOptions(Main.java:263)
	at org.mozilla.javascript.tools.shell.Main.exec(Main.java:153)
	at org.mozilla.javascript.tools.shell.Main.main(Main.java:140)

Comment 9 Toshio Ernie Kuratomi 2009-03-21 00:37:43 UTC
Created attachment 336137 [details]
Spec file patch to include the treetable code

Here's my hacky change to get the treetable code to build.  Someone who knows ant can fix the build.xml instead of doing the symlink.

This also enables installation of the rhino script but as noted that's throwing an exception.  Fixing build of treetable alone is very worthwhile for me as it allows building shrinksafe.

Comment 10 Toshio Ernie Kuratomi 2009-03-21 00:42:42 UTC
Oh and I built this in koji to test it:
  http://koji.fedoraproject.org/koji/taskinfo?taskID=1251876

Comment 11 Lillian Angel 2009-03-23 16:05:31 UTC
thanks, i will look into it now.

Comment 12 Lillian Angel 2009-03-23 16:37:45 UTC
The treetable code still contains the proprietary Sun license headers. We cannot include these.

Comment 13 Toshio Ernie Kuratomi 2009-03-23 17:15:50 UTC
Where are you seeing the proprietary headers?  I've looked at all four files in this directory::
  rhino1_7R2pre/toolsrc/org/mozilla/javascript/tools/debugger/treetable

They seem to have three clause BSD::
  https://fedoraproject.org/wiki/Licensing/BSD#3ClauseBSD

Comment 14 Lillian Angel 2009-03-23 17:34:04 UTC
from the rhing1_7R2pre sources that the devel build downloads:

$ vi rhino1_7R2pre/toolsrc/org/mozilla/javascript/tools/debugger/treetable/AbstractCellEditor.java :

/*
 * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Sun Microsystems nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.mozilla.javascript.tools.debugger.treetable;

import javax.swing.*;
import javax.swing.event.*;
import java.util.EventObject;

public class AbstractCellEditor implements CellEditor {

....

Comment 15 Toshio Ernie Kuratomi 2009-03-23 19:16:29 UTC
Right. That's three clause BSD.  So it's an approved open source license and fine for us to include.  The old, problematic license was::


/*
 * TreeTableModel.java
 *
 * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
 *
 * This software is the confidential and proprietary information of Sun
 * Microsystems, Inc. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Sun.
 *
 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
 * THIS SOFTWARE OR ITS DERIVATIVES.
 *
 */

Sun relicensed this for use in openoffice and the relicensed files were picked up when creating rhino-1.7.

Comment 16 Lillian Angel 2009-03-23 20:27:45 UTC
ah understood, ok thanks!

Comment 17 Lillian Angel 2009-03-26 15:41:23 UTC
(In reply to comment #8)
> Hi langel, thanks for updating rhino!  I owe you next fudcon.
> 
> I think there's two related issues going on here.  Unfortunately, I know
> nothing about java so I'm only going to be able to offer a little bit of help
> here.
> 
> 1) The treetable code that was under a bad license in 1.6 is now included in
> the 1.7 tarball under a BSD-like license but the build.xml in the debugger
> directory is not picking it up.  I'll attach a patch to the spec file that
> illustrates this problem and a hacky way to fix it.  I don't know ant but I
> know that someone who does could fix this more appropriately.

This is fixed in rawhide, and I am pushing an update into F10.


> 
> With this fix to the build, I'm now able to use rhino to build dojo's
> shrinksafe, 1.3.0rc1.  Yay!  This fixes the more serious half of my problems.
> 
> 2) The original issue reported here is that rhino cannot be invoked as a shell.
>  Even with the build fix this is still the case (although we've progressed to a
> NullPointerException instead of NoClassDefFound::
> 
> $ java org.mozilla.javascript.tools.shell.Main -e 'print("i")'
> Exception in thread "main" java.lang.NullPointerException
>  at org.mozilla.javascript.Kit.classOrNull(Kit.java:92)
>  at org.mozilla.javascript.tools.shell.ShellLine.getStream(ShellLine.java:65)
>  at org.mozilla.javascript.tools.shell.Global.init(Global.java:153)
>  at org.mozilla.javascript.tools.shell.Global$1.run(Global.java:108)
>  at org.mozilla.javascript.Context.call(Context.java:499)
>  at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511)
>  at org.mozilla.javascript.tools.shell.Global.init(Global.java:105)
>  at org.mozilla.javascript.tools.shell.Main.processOptions(Main.java:263)
>  at org.mozilla.javascript.tools.shell.Main.exec(Main.java:153)
>  at org.mozilla.javascript.tools.shell.Main.main(Main.java:140)  

Not fixed yet.

Comment 18 Fedora Update System 2009-03-26 15:43:15 UTC
rhino-1.7-0.3.r2pre.1.1.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/rhino-1.7-0.3.r2pre.1.1.fc10

Comment 19 Fedora Update System 2009-03-27 14:47:27 UTC
rhino-1.7-0.3.r2pre.1.1.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Toshio Ernie Kuratomi 2009-04-24 01:08:42 UTC
Updating rhino to 1.7r2 final gets us a step closer:

ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2.zip

http://koji.fedoraproject.org/koji/taskinfo?taskID=1318102


$ java org.mozilla.javascript.tools.shell.Main -e 'print("hi")'
hi

$ cat echo.js
for (i in arguments) {
    print (arguments[i]);
}
$ rhino echo.js one two three
one
two
three

$ java org.mozilla.javascript.tools.shell.Main
Rhino 1.7 release 0.5.r2.fc10 2009 04 23
Exception in thread "main" java.lang.NullPointerException
	at org.mozilla.javascript.Kit.classOrNull(Kit.java:92)
	at org.mozilla.javascript.tools.shell.ShellLine.getStream(ShellLine.java:65)
	at org.mozilla.javascript.tools.shell.Global.getIn(Global.java:829)
	at org.mozilla.javascript.tools.shell.Main.processSource(Main.java:385)
	at org.mozilla.javascript.tools.shell.Main.processFiles(Main.java:196)
	at org.mozilla.javascript.tools.shell.Main$IProxy.run(Main.java:117)
	at org.mozilla.javascript.Context.call(Context.java:515)
	at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
	at org.mozilla.javascript.tools.shell.Main.exec(Main.java:179)
	at org.mozilla.javascript.tools.shell.Main.main(Main.java:157)

So rhino1_7R2 final runs scripts from the command line.  It's just lacking a shell.   I'll attach my modified spec file and a minor change to the rhino script that fixes a warning whenever /usr/bin/rhino is invoked.

Comment 21 Toshio Ernie Kuratomi 2009-04-24 01:13:21 UTC
Created attachment 341042 [details]
spec update

Simple, just a bumped release

Comment 22 Toshio Ernie Kuratomi 2009-04-24 01:14:58 UTC
Created attachment 341043 [details]
Fix a warning in /usr/bin/rhino

This removes xmlbeans from the jars that we load with rhino.  It's an optional feature and we don't have xmlbeans in Fedora yet.

Comment 23 Steven Elliott 2009-05-31 04:03:20 UTC
Created attachment 345997 [details]
A patch for the Rhino null pointer exception

See my comment added 2009-05-30 11:03 pm CST for details.

Comment 24 Steven Elliott 2009-05-31 04:04:20 UTC
I believe I've fixed the null pointer exception.  I've attached a patch.  Keep reading for the technical details.

I've looked into the null pointer exception quoted above. I believe it's a result of Rhino attempting to dynamically load the jline library.  My understanding is that there are both class specific class loaders and a generic system class loader.  With this fix both will be attempted, if necessary, to dynamically load a jline class.

One interesting aspect of this problem is that it seems to be caused by rhino being included with the JRE.  When the rhino.jar symlink in:
    /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/rhino.jar
is deleted (it points to /usr/share/java/rhino.jar) it becomes possible to run the interactive rhino shell via the "rhino" script (/usr/bin/rhino).  But deleting the symlink breaks some other things (it at least stops Eclipse from seeing the Rhino libraries).  Specifically, "ShellLine.class.getClassLoader()" on ShellLine.java:64 returns null in the case where the rhino interactive shell fails.

I've attached my fix.  It's a bit odd in that it attempts to edit both /usr/bin/rhno and the ShellLine.java.  Delete the /usr/bin/rhino portion before applying if you want, or whatever makes sense in your case.  Note that it adds "jline" to the library path in /usr/bin/rhino.  I think doing so is harmless and it makes the interactive rhino shell more pleasant to use (it's like GNU's readline for Java).

Comment 25 Toshio Ernie Kuratomi 2009-05-31 16:26:06 UTC
Confirmed that this patch and the update to 1.7 final fixes all outstanding issues.  Here's the build I tested:

http://koji.fedoraproject.org/koji/taskinfo?taskID=1385788

langel, mind if I push this out to devel and f11 as a zero-day update?

selliot, did you submit your fix to upstream mozilla.org?  If not I can open a bug there with your patch attached.

Comment 26 Steven Elliott 2009-05-31 19:42:10 UTC
(In reply to comment #25)
> selliot, did you submit your fix to upstream mozilla.org?  If not I can open a
> bug there with your patch attached.  

I have not, but that's a good idea.  I'll open the bug later today if you don't.

Comment 27 Toshio Ernie Kuratomi 2009-06-01 15:59:49 UTC
Bug opened upstream with your fix attached:

https://bugzilla.mozilla.org/show_bug.cgi?id=495785

Comment 28 Lillian Angel 2009-06-01 16:52:26 UTC
(In reply to comment #25)
> Confirmed that this patch and the update to 1.7 final fixes all outstanding
> issues.  Here's the build I tested:
> 
> http://koji.fedoraproject.org/koji/taskinfo?taskID=1385788
> 
> langel, mind if I push this out to devel and f11 as a zero-day update?

Patch looks good. please do.

Thanks!

> 
> selliot, did you submit your fix to upstream mozilla.org?  If not I can open a
> bug there with your patch attached.

Comment 29 Fedora Update System 2009-06-01 18:15:59 UTC
rhino-1.7-0.6.r2.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/rhino-1.7-0.6.r2.fc11

Comment 30 Fedora Update System 2009-06-04 21:22:53 UTC
rhino-1.7-0.6.r2.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update rhino'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-5941

Comment 31 Bug Zapper 2009-06-10 02:18:36 UTC
This message is a reminder that Fedora 9 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 9.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '9'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 9's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 9 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 32 Fedora Update System 2009-06-16 02:00:19 UTC
rhino-1.7-0.6.r2.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.