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 "Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil> on 2009/06/16 22:41:45 UTC

JavaScript issues?

Hi all,
 
I'm trying to incorporate JavaScript into one of my SVG files and I'm running into trouble.  I'm sure it's something I've done because it's a custom canvas class and I'm directly using Rhino:
 
The SVG:
 
<svg contentScriptType="text/ecmascript" ...>
    <script type="text/ecmascript">
        <![CDATA[ ... ]]>
    </script>
</svg>
 
The canvas:
 
public class CustomCanvas extends JSVGCanvas {
    public CustomCanvas() {
        super();
        this.setDoubleBuffered(true);
        this.setDoubleBufferedRendering(true);
        this.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
    }
}
 
I'm building with Maven so my project has a dependency on Rhino 1.7R1 for the js.jar.
 
When I load the SVG with the canvas, I get a pop-up error:
SVG Error:  Unknown language: text/ecmascript
 
Details:
 
java.lang.Exception: Unknown language: text/ecmascript
 at org.apache.batik.bridge.BridgeContext.getInterpreter(BridgeContext.java:575)
 at org.apache.batik.bridge.BaseScriptingEnvironment.getInterpreter(BaseScriptingEnvironment.java:289)
 at org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts(BaseScriptingEnvironment.java:404)
 at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(UpdateManager.java:238)
 at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(UpdateManager.java:220)
 at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(SVGLoadEventDispatcher.java:100)

 

The document loads without issue in Squiggle, so I know I'm messing something up.  Do I have to use the js.jar that comes with Batik?  Do I have to do something to "register" the js.jar to handle a certain script type?  I took a look through the Squiggle source, but didn't see anything that stood out.

Thanks for any help.

Michael


 

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: JavaScript issues?

Posted by Helder Magalhães <he...@gmail.com>.
Hi Michael,

> Is there something I have to do to "register" the JAR with Batik so it knows it can do JavaScript?  I see that the BridgeContext class tries to find an interpreter in a HashMap, but I don't know how that HashMap is populated.

I'm fairly convinced that, unless you've made serious changes to Batik
source code, you'll only need to have the dependent [1] Jar files in
the classpath. ;-)  If not, could you provide more information on the
currently used classpath, command-line used and maybe a simple test
case?

Hope this helps,
 Helder

[1] http://xmlgraphics.apache.org/batik/install.html#dependencyGraph

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: JavaScript issues?

Posted by th...@kodak.com.
Hi Michael,

"Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil> wrote 
on 06/25/2009 03:23:57 PM:

> If the problem isn't as obvious as I thought it might be, I'll have 
> to (re)construct a test case.

   You could also add some debug code to InterpreterPool and
rebuild the jar files.  This may/may not be easier for you than
building a test case.

> Is it possible this is an issue with the UserAgent?  I see Squiggle 
> has quite a custom UserAgent in its JSVGCanvas.

   The UserAgent has a number of security related methods,
which could in theory prevent some of these actions but the
default UserAgent is fairly permissive.

> My class constructor was:
> 
> public MyCanvas() {
> super(null, true, false);
> }
> 
> Changing it to:
> 
> public MyCanvas() {
> super();
> }
> 
> didn't change anything though.
> 
> Michael
> 
> ________________________________
> 
> From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
> Sent: Fri 6/19/2009 5:53 AM
> To: batik-users@xmlgraphics.apache.org
> Cc: batik-users@xmlgraphics.apache.org
> Subject: RE: JavaScript issues?
> 
> 
> 
> Hi Michael,
> 
> "Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil> 
> wrote on 06/18/2009 10:27:44 AM:
> 
> > Is there something I have to do to "register" the JAR with Batik so 
> > it knows it can do JavaScript?  I see that the BridgeContext class 
> > tries to find an interpreter in a HashMap, but I don't know how that
> > HashMap is populated.
> 
>    If the HashMap doesn't contain it then it askes the interpreter 
> pool to create the interpreter.  The interpreter pool uses a 
> 'services' API to know what interpreters are available.  So my 
> guess is that you are missing the file: 
>         org.apache.batik.script.InterpreterFactory 
> 
>    In the META-INF/services directory of one of your Jar files. 
> 
> > From: Helder Magalhães [mailto:helder.magalhaes@gmail.com]
> > Sent: Wed 6/17/2009 12:57 AM
> > To: batik-users@xmlgraphics.apache.org
> > Subject: Re: JavaScript issues?
> > 
> > 
> > 
> > Hi Michael,
> > 
> > 
> > > I'm trying to incorporate JavaScript into one of my SVG files and 
> > I'm running into trouble.  I'm sure it's something I've done because
> > it's a custom canvas class and I'm directly using Rhino:
> > >
> > > The SVG:
> > >
> > > <svg contentScriptType="text/ecmascript" ...>
> > >    <script type="text/ecmascript">
> > >        <![CDATA[ ... ]]>
> > >    </script>
> > > </svg>
> > 
> > Yeah, this should work fine, assuming that the "xmlns" for SVG is part
> > of the "...", of course. ;-)
> > 
> > 
> > > I'm building with Maven so my project has a dependency on Rhino 1.
> > 7R1 for the js.jar.
> > 
> > This may be the issue: Batik might not be ready for this yet. Please
> > see a relevant post [1] about a Rhino-related issue which ended up
> > with a change [2] in order to support Rhino versions above the
> > currently shipped (1.6R5). Note that using Rhino 1.7R1 and above
> > implies Java 1.5 support (as stated by Cameron [3] and in the Rhino
> > release notes [4]).
> > 
> > 
> > > Do I have to use the js.jar that comes with Batik?
> > 
> > Apparently not, but using any version above 1.6R7 might not work
> > without a bit of hacking (more testing is needed). Of course that, if
> > you manage to make Rhino 1.7R1+ work, even without any (Batik) code
> > changes, please share! ;-)
> > 
> > 
> > > Thanks for any help.
> > > Michael
> > 
> > Hope this helps,
> >  Helder
> > 
> > 
> > [1] http://www.nabble.com/Batik-and-Rhino-1.6R7-ts19434372.html
> > [2] http://svn.apache.org/viewvc?view=rev&revision=701300
> > [3] http://www.nabble.com/Java-version-requirements-and-upgrading-
> > external-libraries-(was-%22Re%3A-Batik-and-Rhino-1.6R7%22)-
> > ts19795908.html#a19812503
> > [4] https://developer.mozilla.org/en/New_in_Rhino_1.7R1
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> > [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

RE: JavaScript issues?

Posted by "Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil>.
Hi Thomas,
 
I'm using the Batik 1.7 distribution and the batik-script.jar contains the META-INF/services/org.apache.batik.script.InterpreterFactory file.  A design change removed the need for JavaScript, but I'm still interested in solving this for the future.
 
If the problem isn't as obvious as I thought it might be, I'll have to (re)construct a test case.
 
Is it possible this is an issue with the UserAgent?  I see Squiggle has quite a custom UserAgent in its JSVGCanvas.
 
My class constructor was:
 
public MyCanvas() {
super(null, true, false);
}
 
Changing it to:
 
public MyCanvas() {
super();
}
 
didn't change anything though.
 
Michael

________________________________

From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com]
Sent: Fri 6/19/2009 5:53 AM
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: JavaScript issues?



Hi Michael,

"Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil> wrote on 06/18/2009 10:27:44 AM:

> Is there something I have to do to "register" the JAR with Batik so 
> it knows it can do JavaScript?  I see that the BridgeContext class 
> tries to find an interpreter in a HashMap, but I don't know how that
> HashMap is populated.

   If the HashMap doesn't contain it then it askes the interpreter 
pool to create the interpreter.  The interpreter pool uses a 
'services' API to know what interpreters are available.  So my 
guess is that you are missing the file: 
        org.apache.batik.script.InterpreterFactory 

   In the META-INF/services directory of one of your Jar files. 

> From: Helder Magalhães [mailto:helder.magalhaes@gmail.com]
> Sent: Wed 6/17/2009 12:57 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: JavaScript issues?
> 
> 
> 
> Hi Michael,
> 
> 
> > I'm trying to incorporate JavaScript into one of my SVG files and 
> I'm running into trouble.  I'm sure it's something I've done because
> it's a custom canvas class and I'm directly using Rhino:
> >
> > The SVG:
> >
> > <svg contentScriptType="text/ecmascript" ...>
> >    <script type="text/ecmascript">
> >        <![CDATA[ ... ]]>
> >    </script>
> > </svg>
> 
> Yeah, this should work fine, assuming that the "xmlns" for SVG is part
> of the "...", of course. ;-)
> 
> 
> > I'm building with Maven so my project has a dependency on Rhino 1.
> 7R1 for the js.jar.
> 
> This may be the issue: Batik might not be ready for this yet. Please
> see a relevant post [1] about a Rhino-related issue which ended up
> with a change [2] in order to support Rhino versions above the
> currently shipped (1.6R5). Note that using Rhino 1.7R1 and above
> implies Java 1.5 support (as stated by Cameron [3] and in the Rhino
> release notes [4]).
> 
> 
> > Do I have to use the js.jar that comes with Batik?
> 
> Apparently not, but using any version above 1.6R7 might not work
> without a bit of hacking (more testing is needed). Of course that, if
> you manage to make Rhino 1.7R1+ work, even without any (Batik) code
> changes, please share! ;-)
> 
> 
> > Thanks for any help.
> > Michael
> 
> Hope this helps,
>  Helder
> 
> 
> [1] http://www.nabble.com/Batik-and-Rhino-1.6R7-ts19434372.html
> [2] http://svn.apache.org/viewvc?view=rev&revision=701300
> [3] http://www.nabble.com/Java-version-requirements-and-upgrading-
> external-libraries-(was-%22Re%3A-Batik-and-Rhino-1.6R7%22)-
> ts19795908.html#a19812503
> [4] https://developer.mozilla.org/en/New_in_Rhino_1.7R1
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

RE: JavaScript issues?

Posted by th...@kodak.com.
Hi Michael,

"Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil> wrote 
on 06/18/2009 10:27:44 AM:

> Is there something I have to do to "register" the JAR with Batik so 
> it knows it can do JavaScript?  I see that the BridgeContext class 
> tries to find an interpreter in a HashMap, but I don't know how that
> HashMap is populated.

   If the HashMap doesn't contain it then it askes the interpreter
pool to create the interpreter.  The interpreter pool uses a
'services' API to know what interpreters are available.  So my
guess is that you are missing the file:
        org.apache.batik.script.InterpreterFactory

   In the META-INF/services directory of one of your Jar files.

> From: Helder Magalhães [mailto:helder.magalhaes@gmail.com]
> Sent: Wed 6/17/2009 12:57 AM
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: JavaScript issues?
> 
> 
> 
> Hi Michael,
> 
> 
> > I'm trying to incorporate JavaScript into one of my SVG files and 
> I'm running into trouble.  I'm sure it's something I've done because
> it's a custom canvas class and I'm directly using Rhino:
> >
> > The SVG:
> >
> > <svg contentScriptType="text/ecmascript" ...>
> >    <script type="text/ecmascript">
> >        <![CDATA[ ... ]]>
> >    </script>
> > </svg>
> 
> Yeah, this should work fine, assuming that the "xmlns" for SVG is part
> of the "...", of course. ;-)
> 
> 
> > I'm building with Maven so my project has a dependency on Rhino 1.
> 7R1 for the js.jar.
> 
> This may be the issue: Batik might not be ready for this yet. Please
> see a relevant post [1] about a Rhino-related issue which ended up
> with a change [2] in order to support Rhino versions above the
> currently shipped (1.6R5). Note that using Rhino 1.7R1 and above
> implies Java 1.5 support (as stated by Cameron [3] and in the Rhino
> release notes [4]).
> 
> 
> > Do I have to use the js.jar that comes with Batik?
> 
> Apparently not, but using any version above 1.6R7 might not work
> without a bit of hacking (more testing is needed). Of course that, if
> you manage to make Rhino 1.7R1+ work, even without any (Batik) code
> changes, please share! ;-)
> 
> 
> > Thanks for any help.
> > Michael
> 
> Hope this helps,
>  Helder
> 
> 
> [1] http://www.nabble.com/Batik-and-Rhino-1.6R7-ts19434372.html
> [2] http://svn.apache.org/viewvc?view=rev&revision=701300
> [3] http://www.nabble.com/Java-version-requirements-and-upgrading-
> external-libraries-(was-%22Re%3A-Batik-and-Rhino-1.6R7%22)-
> ts19795908.html#a19812503
> [4] https://developer.mozilla.org/en/New_in_Rhino_1.7R1
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> [attachment "winmail.dat" deleted by Thomas E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

RE: JavaScript issues?

Posted by "Bishop, Michael W. CTR USJFCOM JFL" <mi...@jfcom.mil>.
Hi Helder,
 
I switched my dependency to 1.6R5 and still have problems.  So I can't make the "right" version of Rhino work, much less the latest one.  I'm using the final 1.7 release, so no SVN builds like John.  My error is still "SVG Error: Unknown language: text/ecmascript".
 
Yes, the xmlns is for the SVG namespace.  The file renders fine; it's just having problems now that I've added some JavaScript to it.
 
Is there something I have to do to "register" the JAR with Batik so it knows it can do JavaScript?  I see that the BridgeContext class tries to find an interpreter in a HashMap, but I don't know how that HashMap is populated.
 
Michael

________________________________

From: Helder Magalhães [mailto:helder.magalhaes@gmail.com]
Sent: Wed 6/17/2009 12:57 AM
To: batik-users@xmlgraphics.apache.org
Subject: Re: JavaScript issues?



Hi Michael,


> I'm trying to incorporate JavaScript into one of my SVG files and I'm running into trouble.  I'm sure it's something I've done because it's a custom canvas class and I'm directly using Rhino:
>
> The SVG:
>
> <svg contentScriptType="text/ecmascript" ...>
>    <script type="text/ecmascript">
>        <![CDATA[ ... ]]>
>    </script>
> </svg>

Yeah, this should work fine, assuming that the "xmlns" for SVG is part
of the "...", of course. ;-)


> I'm building with Maven so my project has a dependency on Rhino 1.7R1 for the js.jar.

This may be the issue: Batik might not be ready for this yet. Please
see a relevant post [1] about a Rhino-related issue which ended up
with a change [2] in order to support Rhino versions above the
currently shipped (1.6R5). Note that using Rhino 1.7R1 and above
implies Java 1.5 support (as stated by Cameron [3] and in the Rhino
release notes [4]).


> Do I have to use the js.jar that comes with Batik?

Apparently not, but using any version above 1.6R7 might not work
without a bit of hacking (more testing is needed). Of course that, if
you manage to make Rhino 1.7R1+ work, even without any (Batik) code
changes, please share! ;-)


> Thanks for any help.
> Michael

Hope this helps,
 Helder


[1] http://www.nabble.com/Batik-and-Rhino-1.6R7-ts19434372.html
[2] http://svn.apache.org/viewvc?view=rev&revision=701300
[3] http://www.nabble.com/Java-version-requirements-and-upgrading-external-libraries-(was-%22Re%3A-Batik-and-Rhino-1.6R7%22)-ts19795908.html#a19812503
[4] https://developer.mozilla.org/en/New_in_Rhino_1.7R1

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org




RE: JavaScript issues?

Posted by "John C. Turnbull" <oz...@ozemail.com.au>.
Hi Helder,

> Apparently not, but using any version above 1.6R7 might not work
> without a bit of hacking (more testing is needed). Of course that, if
> you manage to make Rhino 1.7R1+ work, even without any (Batik) code
> changes, please share! ;-)

I have been using Batik from SVN with Rhino 1.7R2 for a long time without
any issues.  I can't say I have extensively tested the scripting side of
things but what scripts I have tried have worked perfectly.

-John


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: JavaScript issues?

Posted by Helder Magalhães <he...@gmail.com>.
Hi Michael,


> I'm trying to incorporate JavaScript into one of my SVG files and I'm running into trouble.  I'm sure it's something I've done because it's a custom canvas class and I'm directly using Rhino:
>
> The SVG:
>
> <svg contentScriptType="text/ecmascript" ...>
>    <script type="text/ecmascript">
>        <![CDATA[ ... ]]>
>    </script>
> </svg>

Yeah, this should work fine, assuming that the "xmlns" for SVG is part
of the "...", of course. ;-)


> I'm building with Maven so my project has a dependency on Rhino 1.7R1 for the js.jar.

This may be the issue: Batik might not be ready for this yet. Please
see a relevant post [1] about a Rhino-related issue which ended up
with a change [2] in order to support Rhino versions above the
currently shipped (1.6R5). Note that using Rhino 1.7R1 and above
implies Java 1.5 support (as stated by Cameron [3] and in the Rhino
release notes [4]).


> Do I have to use the js.jar that comes with Batik?

Apparently not, but using any version above 1.6R7 might not work
without a bit of hacking (more testing is needed). Of course that, if
you manage to make Rhino 1.7R1+ work, even without any (Batik) code
changes, please share! ;-)


> Thanks for any help.
> Michael

Hope this helps,
 Helder


[1] http://www.nabble.com/Batik-and-Rhino-1.6R7-ts19434372.html
[2] http://svn.apache.org/viewvc?view=rev&revision=701300
[3] http://www.nabble.com/Java-version-requirements-and-upgrading-external-libraries-(was-%22Re%3A-Batik-and-Rhino-1.6R7%22)-ts19795908.html#a19812503
[4] https://developer.mozilla.org/en/New_in_Rhino_1.7R1

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org