Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Mozilla Rhino Class Loading Issue w/ BIRT in webapp
Mozilla Rhino Class Loading Issue w/ BIRT in webapp [message #507081] Mon, 11 January 2010 19:50 Go to next message
Russ Tennant is currently offline Russ Tennant
Messages: 12
Registered: July 2009
Junior Member
We are getting an issue with mozilla rhino classes not getting
initialized properly with BIRT. If the Platform is started before any
other code accesses Rhino classes then the problem occurs. If code other
than BIRT accesses Rhino classes first, then the problem does not occur.


Mozilla Rhino Source (1.7R1) For Context.emptyArgs Field:

public static final Object[] emptyArgs = ScriptRuntime.emptyArgs;

My Test Code:

System.out.println("Context.emptyArgs -> " +
org.mozilla.javascript.Context.emptyArgs);


and output follows.


BIRT First To Access Class (broken)
--------------------------

Context.emptyArgs -> null


BIRT Second To Access Class (works)
---------------------------

Context.emptyArgs -> [Ljava.lang.Object;@b778cf



We are using BIRT 2.5.1 in our web app.

Any ideas on why this happens or suggestions on where to go from here?


--
russ
Re: Mozilla Rhino Class Loading Issue w/ BIRT in webapp [message #507253 is a reply to message #507081] Tue, 12 January 2010 11:10 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Russ,

What JVM are you using? Do you have js.jar some other place in the web
app or JRE?

Jason

Russ Tennant wrote:
> We are getting an issue with mozilla rhino classes not getting
> initialized properly with BIRT. If the Platform is started before any
> other code accesses Rhino classes then the problem occurs. If code other
> than BIRT accesses Rhino classes first, then the problem does not occur.
>
>
> Mozilla Rhino Source (1.7R1) For Context.emptyArgs Field:
>
> public static final Object[] emptyArgs = ScriptRuntime.emptyArgs;
>
> My Test Code:
>
> System.out.println("Context.emptyArgs -> " +
> org.mozilla.javascript.Context.emptyArgs);
>
>
> and output follows.
>
>
> BIRT First To Access Class (broken)
> --------------------------
>
> Context.emptyArgs -> null
>
>
> BIRT Second To Access Class (works)
> ---------------------------
>
> Context.emptyArgs -> [Ljava.lang.Object;@b778cf
>
>
>
> We are using BIRT 2.5.1 in our web app.
>
> Any ideas on why this happens or suggestions on where to go from here?
>
>
> --
> russ
>
>
Re: Mozilla Rhino Class Loading Issue w/ BIRT in webapp [message #507283 is a reply to message #507253] Tue, 12 January 2010 13:01 Go to previous messageGo to next message
Russ Tennant is currently offline Russ Tennant
Messages: 12
Registered: July 2009
Junior Member
I'm using the SUN JVM (1.6.14 and 1.6.17) in server mode, also tested in
client made with the same result. I have only one jar of Mozilla Rhino
in the web app. Same version as required by the BIRT libraries I'm
using. This issue exists when running under Jetty as well as Tomcat. I
get the same class information in both cases: BIRT loads rhino classes
first or webapp code loads rhino classes first.

Class Information
-----------------
Class: org.mozilla.javascript.NativeJavaMethod
ClassLoader: sun.misc.Launcher$AppClassLoader@2bbd86
ProtectionDomain: ProtectionDomain
(file:/home/russ/workspace33_domainmodel/mozilla-rhino/mozil la-rhino.jar
<no signer certificates>)
sun.misc.Launcher$AppClassLoader@2bbd86
<no principals>
java.security.Permissions@15be51a (
(java.lang.RuntimePermission exitVM)
(java.io.FilePermission
/home/russ/workspace33_domainmodel/mozilla-rhino/mozilla-rhi no.jar read)

)

I noticed that OSGILauncher loads the classes I'm having problems with
on platform startup. It appears that they are not being initialized as
described in
http://java.sun.com/docs/books/jls/third_edition/html/execut ion.html#44630

I'm not a classloading expert so I'm not sure if this is a VM bug or an
application bug.

If I change the following in OSGILauncher.java:


// Weblogic 8.1SP6 contains old version JS.JAR, we need
// set pref-web-inf to true, if we set it to true, the
// URL classloader still loads the JS in weblogic, so
// load the class explicitly.
try
{
loader.loadClass( "org.mozilla.javascript.Context" );
loader.loadClass( "org.mozilla.javascript.Scriptable" );
loader.loadClass( "org.mozilla.javascript.ScriptableObject" );
// frameworkClassLoader.loadClass(
// "org.mozilla.javascript.Context"
}
catch ( Exception ex )
{
}

TO

try
{
System.err.println("Loading mozilla javascript Context through " + loader);

this.getClass().forName( "org.mozilla.javascript.Context" );
this.getClass().forName( "org.mozilla.javascript.Scriptable" );
this.getClass().forName( "org.mozilla.javascript.ScriptableObject" );

}
catch ( Exception ex )
{
ex.printStackTrace();
}

it works as expected since Class.forName initializes immediately;
whereas, loadClass(String) defers initialization. I tried to create a
simpler test case with only Rhino, but I was unable to do so and still
reproduce the issue. I'm not sure if BIRT has a class loading bug
related to this, or if it's a VM issue, or something else.

Jason Weathersby wrote:
> Russ,
>
> What JVM are you using? Do you have js.jar some other place in the web
> app or JRE?
>
> Jason
>
> Russ Tennant wrote:
>> We are getting an issue with mozilla rhino classes not getting
>> initialized properly with BIRT. If the Platform is started before any
>> other code accesses Rhino classes then the problem occurs. If code other
>> than BIRT accesses Rhino classes first, then the problem does not occur.
>>
>>
>> Mozilla Rhino Source (1.7R1) For Context.emptyArgs Field:
>>
>> public static final Object[] emptyArgs = ScriptRuntime.emptyArgs;
>>
>> My Test Code:
>>
>> System.out.println("Context.emptyArgs -> " +
>> org.mozilla.javascript.Context.emptyArgs);
>>
>>
>> and output follows.
>>
>>
>> BIRT First To Access Class (broken)
>> --------------------------
>>
>> Context.emptyArgs -> null
>>
>>
>> BIRT Second To Access Class (works)
>> ---------------------------
>>
>> Context.emptyArgs -> [Ljava.lang.Object;@b778cf
>>
>>
>>
>> We are using BIRT 2.5.1 in our web app.
>>
>> Any ideas on why this happens or suggestions on where to go from here?
>>
>>
>> --
>> russ
>>
>>
Re: Mozilla Rhino Class Loading Issue w/ BIRT in webapp [message #507314 is a reply to message #507283] Tue, 12 January 2010 17:02 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Russ,

Can you open up a bugzilla entry for this and paste your current findings?

Thanks

Jason

Russ Tennant wrote:
> I'm using the SUN JVM (1.6.14 and 1.6.17) in server mode, also tested in
> client made with the same result. I have only one jar of Mozilla Rhino
> in the web app. Same version as required by the BIRT libraries I'm
> using. This issue exists when running under Jetty as well as Tomcat. I
> get the same class information in both cases: BIRT loads rhino classes
> first or webapp code loads rhino classes first.
>
> Class Information
> -----------------
> Class: org.mozilla.javascript.NativeJavaMethod
> ClassLoader: sun.misc.Launcher$AppClassLoader@2bbd86
> ProtectionDomain: ProtectionDomain
> (file:/home/russ/workspace33_domainmodel/mozilla-rhino/mozil la-rhino.jar
> <no signer certificates>)
> sun.misc.Launcher$AppClassLoader@2bbd86
> <no principals>
> java.security.Permissions@15be51a (
> (java.lang.RuntimePermission exitVM)
> (java.io.FilePermission
> /home/russ/workspace33_domainmodel/mozilla-rhino/mozilla-rhi no.jar read)
>
> )
>
> I noticed that OSGILauncher loads the classes I'm having problems with
> on platform startup. It appears that they are not being initialized as
> described in
> http://java.sun.com/docs/books/jls/third_edition/html/execut ion.html#44630
>
> I'm not a classloading expert so I'm not sure if this is a VM bug or an
> application bug.
>
> If I change the following in OSGILauncher.java:
>
>
> // Weblogic 8.1SP6 contains old version JS.JAR, we need
> // set pref-web-inf to true, if we set it to true, the
> // URL classloader still loads the JS in weblogic, so
> // load the class explicitly.
> try
> {
> loader.loadClass( "org.mozilla.javascript.Context" );
> loader.loadClass( "org.mozilla.javascript.Scriptable" );
> loader.loadClass( "org.mozilla.javascript.ScriptableObject" );
> // frameworkClassLoader.loadClass(
> // "org.mozilla.javascript.Context"
> }
> catch ( Exception ex )
> {
> }
>
> TO
>
> try
> {
> System.err.println("Loading mozilla javascript Context through " + loader);
>
> this.getClass().forName( "org.mozilla.javascript.Context" );
> this.getClass().forName( "org.mozilla.javascript.Scriptable" );
> this.getClass().forName( "org.mozilla.javascript.ScriptableObject" );
>
> }
> catch ( Exception ex )
> {
> ex.printStackTrace();
> }
>
> it works as expected since Class.forName initializes immediately;
> whereas, loadClass(String) defers initialization. I tried to create a
> simpler test case with only Rhino, but I was unable to do so and still
> reproduce the issue. I'm not sure if BIRT has a class loading bug
> related to this, or if it's a VM issue, or something else.
>
> Jason Weathersby wrote:
>> Russ,
>>
>> What JVM are you using? Do you have js.jar some other place in the web
>> app or JRE?
>>
>> Jason
>>
>> Russ Tennant wrote:
>>> We are getting an issue with mozilla rhino classes not getting
>>> initialized properly with BIRT. If the Platform is started before any
>>> other code accesses Rhino classes then the problem occurs. If code other
>>> than BIRT accesses Rhino classes first, then the problem does not occur.
>>>
>>>
>>> Mozilla Rhino Source (1.7R1) For Context.emptyArgs Field:
>>>
>>> public static final Object[] emptyArgs = ScriptRuntime.emptyArgs;
>>>
>>> My Test Code:
>>>
>>> System.out.println("Context.emptyArgs -> " +
>>> org.mozilla.javascript.Context.emptyArgs);
>>>
>>>
>>> and output follows.
>>>
>>>
>>> BIRT First To Access Class (broken)
>>> --------------------------
>>>
>>> Context.emptyArgs -> null
>>>
>>>
>>> BIRT Second To Access Class (works)
>>> ---------------------------
>>>
>>> Context.emptyArgs -> [Ljava.lang.Object;@b778cf
>>>
>>>
>>>
>>> We are using BIRT 2.5.1 in our web app.
>>>
>>> Any ideas on why this happens or suggestions on where to go from here?
>>>
>>>
>>> --
>>> russ
>>>
>>>
Re: Mozilla Rhino Class Loading Issue w/ BIRT in webapp [message #507495 is a reply to message #507314] Wed, 13 January 2010 11:42 Go to previous message
Russ Tennant is currently offline Russ Tennant
Messages: 12
Registered: July 2009
Junior Member
Jason Weathersby wrote:
> Russ,
>
> Can you open up a bugzilla entry for this and paste your current findings?
>
> Thanks
>
> Jason


Issue reported: https://bugs.eclipse.org/bugs/show_bug.cgi?id=299515

--
russ
Previous Topic:xpath express does not support some special character?
Next Topic:Is there a limitation for Birt engine connection pool?
Goto Forum:
  


Current Time: Mon Jul 28 06:31:32 EDT 2014

Powered by FUDForum. Page generated in 0.01862 seconds