You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Jeffrey Hau <jh...@doc.ic.ac.uk> on 2004/10/28 15:09:04 UTC
problem calling custom java class from ecmascript
Hi all,
I am just starting with batik and try to run a very simple script
within a SVG document. The script is just the function below,
function callJava() {
var cx = Packages.org.mozilla.javascript.Context.enter();
alert(cx);
}
but when i run this within the squiggle browser, i get the following
error
TypeError: [JavaPackage org.mozilla.javascript.Context.enter] is not a
function. (Inline <script> file:/Projects/svg/lines.svg:6; line 3)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
597)
at
org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
557)
at
org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:567)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1182)
(rest of the trace omitted)
the code execute ok within the standalone rhino shell, so i think this
is probably a classpath setting problem.
i try runnning the browser in the batik installation directory by
java -jar batik-squiggle.jar
and also (as a user suggested in an earlier post),
java -cp batik-squiggle.jar:lib/js.jar
org.apache.batik.apps.svgbrowser.Main
but neither works, can anyone help?
thanks very much
Jeff
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: problem calling custom java class from ecmascript
Posted by Thomas DeWeese <Th...@Kodak.com>.
Jeffrey Hau wrote:
> Thanks very much for the quick reply. I pick out that line from Rhino's
> embedding tutorial, now i am using my own class and everything is
> working fine :)
>
> btw, is there any documentation on the list of classes that has
> restricted access from javascript?
Just the source, take a look at:
...batik.script.rhino.RhinoClassShutter
It's pretty clear what it disallows.
> On 28 Oct 2004, at 14:42, Thomas DeWeese wrote:
>
>> Jeffrey Hau wrote:
>>
>>> I am just starting with batik and try to run a very simple script
>>> within a SVG document. The script is just the function below,
>>> function callJava() {
>>> var cx = Packages.org.mozilla.javascript.Context.enter();
>>> alert(cx);
>>> }
>>
>>
>> Hi Jeffrey,
>>
>> We don't allow access to this class from javascript for
>> security reasons. I just noticed that there this is not controlled
>> (as it should be) by the User Agent security settings, so the
>> only way to work around this would be to modify the Batik sources
>> (in particular either modify batik.script.rhino.RhinoClassShutter
>> or RhinoInterpreter so it never registers a class shutter).
>>
>>> but when i run this within the squiggle browser, i get the following
>>> error
>>> TypeError: [JavaPackage org.mozilla.javascript.Context.enter] is not
>>> a function. (Inline <script> file:/Projects/svg/lines.svg:6; line 3)
>>> at
>>> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
>>> 597)
>>> at
>>> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
>>> 557)
>>> at
>>> org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:567)
>>> at
>>> org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1182)
>>> (rest of the trace omitted)
>>> the code execute ok within the standalone rhino shell, so i think
>>> this is probably a classpath setting problem.
>>> i try runnning the browser in the batik installation directory by
>>> java -jar batik-squiggle.jar
>>> and also (as a user suggested in an earlier post),
>>> java -cp batik-squiggle.jar:lib/js.jar
>>> org.apache.batik.apps.svgbrowser.Main
>>> but neither works, can anyone help?
>>> thanks very much
>>> Jeff
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>>> For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>> For additional commands, e-mail: batik-users-help@xml.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: problem calling custom java class from ecmascript
Posted by Jeffrey Hau <jh...@doc.ic.ac.uk>.
Hi Thomas
Thanks very much for the quick reply. I pick out that line from Rhino's
embedding tutorial, now i am using my own class and everything is
working fine :)
btw, is there any documentation on the list of classes that has
restricted access from javascript?
thanks
Jeff
On 28 Oct 2004, at 14:42, Thomas DeWeese wrote:
> Jeffrey Hau wrote:
>
>> I am just starting with batik and try to run a very simple script
>> within a SVG document. The script is just the function below,
>> function callJava() {
>> var cx = Packages.org.mozilla.javascript.Context.enter();
>> alert(cx);
>> }
>
> Hi Jeffrey,
>
> We don't allow access to this class from javascript for
> security reasons. I just noticed that there this is not controlled
> (as it should be) by the User Agent security settings, so the
> only way to work around this would be to modify the Batik sources
> (in particular either modify batik.script.rhino.RhinoClassShutter
> or RhinoInterpreter so it never registers a class shutter).
>
>> but when i run this within the squiggle browser, i get the following
>> error
>> TypeError: [JavaPackage org.mozilla.javascript.Context.enter] is not
>> a function. (Inline <script> file:/Projects/svg/lines.svg:6; line 3)
>> at
>> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
>> 597)
>> at
>> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:
>> 557)
>> at
>> org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:567)
>> at
>> org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1182)
>> (rest of the trace omitted)
>> the code execute ok within the standalone rhino shell, so i think
>> this is probably a classpath setting problem.
>> i try runnning the browser in the batik installation directory by
>> java -jar batik-squiggle.jar
>> and also (as a user suggested in an earlier post),
>> java -cp batik-squiggle.jar:lib/js.jar
>> org.apache.batik.apps.svgbrowser.Main
>> but neither works, can anyone help?
>> thanks very much
>> Jeff
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
>> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: problem calling custom java class from ecmascript
Posted by Thomas DeWeese <Th...@Kodak.com>.
Jeffrey Hau wrote:
> I am just starting with batik and try to run a very simple script
> within a SVG document. The script is just the function below,
>
> function callJava() {
> var cx = Packages.org.mozilla.javascript.Context.enter();
> alert(cx);
> }
Hi Jeffrey,
We don't allow access to this class from javascript for
security reasons. I just noticed that there this is not controlled
(as it should be) by the User Agent security settings, so the
only way to work around this would be to modify the Batik sources
(in particular either modify batik.script.rhino.RhinoClassShutter
or RhinoInterpreter so it never registers a class shutter).
> but when i run this within the squiggle browser, i get the following error
>
> TypeError: [JavaPackage org.mozilla.javascript.Context.enter] is not a
> function. (Inline <script> file:/Projects/svg/lines.svg:6; line 3)
> at
> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java: 597)
> at
> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java: 557)
> at
> org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:567)
> at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1182)
>
> (rest of the trace omitted)
>
> the code execute ok within the standalone rhino shell, so i think this
> is probably a classpath setting problem.
> i try runnning the browser in the batik installation directory by
>
> java -jar batik-squiggle.jar
>
> and also (as a user suggested in an earlier post),
>
> java -cp batik-squiggle.jar:lib/js.jar
> org.apache.batik.apps.svgbrowser.Main
>
> but neither works, can anyone help?
>
> thanks very much
>
> Jeff
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org