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 Emmy Alex <ea...@hermes.tietronix.com> on 2007/03/13 15:26:28 UTC

Batik 1.6 svg browser AND Rhino Scripting

Hello All,
I am tring to use a function of user defined class in my SVG ECMAScript and then view it in my Baitk 1.6 SVG Squiggle browser.
However when I do that I get a exception

****************************************************
InterpExcept: org.apache.batik.script.InterpreterException: Function importClass must be called with a class; had "[JavaPackage com.tietronix.common.Utility]" instead. (Inline <script> file:/C:/test_java/5_350_pretzel_14Apr2006.svg:487; line 3)
org.mozilla.javascript.EvaluatorException: Function importClass must be called with a class; had "[JavaPackage com.tietronix.common.Utility]" instead. (Inline <script> file:/C:/test_java/5_350_pretzel_14Apr2006.svg:487; line 3)
	at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:76)
	at org.mozilla.javascript.Context.reportRuntimeError(Context.java:591)
	at org.mozilla.javascript.Context.reportRuntimeError(Context.java:630)
	at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:606)
	at org.mozilla.javascript.ImporterTopLevel.importClass(ImporterTopLevel.java:146)
	at inv2.invoke()
	at org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:498)
	at org.mozilla.javascript.FunctionObject.callVarargs(FunctionObject.java:513)
	at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:378)
	at org.mozilla.javascript.optimizer.OptRuntime.callSimple(OptRuntime.java:275)
	at org.mozilla.javascript.gen.c37.call(Inline <script> file:/C:/test_java/5_350_pretzel_14Apr2006.svg:487:3)
	at org.mozilla.javascript.gen.c37.exec(Inline <script> file:/C:/test_java/5_350_pretzel_14Apr2006.svg:487)
	at org.mozilla.javascript.Context.evaluateReader(Context.java:820)
	at org.apache.batik.script.rhino.RhinoInterpreter.evaluate(RhinoInterpreter.java:237)
	at org.apache.batik.bridge.BaseScriptingEnvironment.loadScripts(BaseScriptingEnvironment.java:467)
	at org.apache.batik.bridge.UpdateManager.dispatchSVGLoadEvent(UpdateManager.java:151)
	at org.apache.batik.swing.svg.SVGLoadEventDispatcher.run(SVGLoadEventDispatcher.java:99)
**********************************************************

My SVG has the ecma script as follows:

<script type="text/ecmascript"><![CDATA[ 
importPackage(Packages.javax.swing);
importClass(Packages.com.tietronix.common.Utility); 
function doit() { 
var util = new Packages.Utility();
var b = util.getActiveState("/PPhase1:Running/Component:Running/TAssociatedDataBuffer", null);
alert(b); 
var frame = new JFrame("My test frame");
      var label = new JLabel("Hello from Java objects created in ECMAScript!");
      label.setHorizontalAlignment(SwingConstants.CENTER);
      frame.getContentPane().add(label);
      frame.setSize(400, 100);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

}

doit();
]]></script> 

The java class com.tietronix.common.Utility is in a SVGApplication.jar file which is in the same location as the SVG is and in the same location where batik-squiggle.jar is. I believe it is an issue of batik-squiggle not finding the class com.tietronix.common.Utility.

Is there anybody who can give me some pointers on how to solve this issue?  
             

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


Re: Batik 1.6 svg browser AND Rhino Scripting

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

"Emmy Alex" <ea...@hermes.tietronix.com> wrote on 03/13/2007 10:26:28 AM:

> InterpExcept: org.apache.batik.script.InterpreterException: Function
> importClass must be called with a class; had "[JavaPackage com.
> tietronix.common.Utility]" instead. (Inline <script> file:/C:

> The java class com.tietronix.common.Utility is in a SVGApplication.
> jar file which is in the same location as the SVG is and in the same
> location where batik-squiggle.jar is. I believe it is an issue of 
> batik-squiggle not finding the class com.tietronix.common.Utility.

   Have you done anything to put your SVGApplication jar on the
classpath for batik-squiggle?  If you haven't then Batik won't go
looking around for random Jar files so it won't find it.

> Is there anybody who can give me some pointers on how to solve this 
issue? 

   I would add your jar to the java command line or edit
the manifest in the jar file to include your jar.


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