On 1 сен, 18:18, viktor stolbin <[email protected]> wrote: > On 28 авг, 23:17, Norris Boyd <[email protected]> wrote: > > > > > On Aug 28, 6:47 am, viktor stolbin <[email protected]> wrote: > > > > Hello everybody > > > I'm embedding rhino in my desktop application and faced with problem. > > > In script I use hibernate Restrinctions.eq() and it gets an error when > > > trying to call static "eq()". I wrote a test class and a test script: > > > Test class > > > > 1. public class TestClass { > > > 2. > > > 3. public static String variable = "variable"; > > > 4. > > > 5. public static String test(){ > > > 6. return "test"; > > > 7. } > > > 8. > > > 9. } > > > > Test script > > > > 1. > > > 2. var test1 = java.lang.Math.cos(0); > > > 3. var test2 = > > > org.eclipse.jface.viewers.StructuredSelection.EMPTY; > > > 4. var test3 = ru.griffo.core.ui.utils.TestClass.variable; > > > > It gets error: > > > > org.mozilla.javascript.EcmaError: ReferenceError: "ru" is not > > > defined. (<cmd>#1) > > > Unlike "com", "java", etc., "ru" is not defined by default in Rhino. > > You have to prefix it with "Packages" as you've done below. > > > > Class TestClass is in the same package my script util is. When I > > > changed script to: > > > > 1. > > > 2. hibernate = Packages.org.hibernate.criterion; > > > 3. jface = Packages.org.eclipse.jface.viewers; > > > 4. test = Packages.ru.griffo.core.ui.utils; > > > 5. > > > 6. var test1 = java.lang.Math.cos(0); > > > 7. var test2 = jface.StructuredSelection.EMPTY; > > > 8. var test3 = test.TestClass.variable; > > > 9. var test4 = test.TestClass.test(); > > > > it gets the same error I get with hibernate Restriqtions.eq(): > > > > org.mozilla.javascript.EcmaError: TypeError: Cannot call property > > > test in object [JavaPackage ru.griffo.core.ui.utils.TestClass]. It is > > > not a function, it is "object". (<cmd>#1) > > > The fact that it thinks that ru.griffo.core.ui.utils.TestClass is a > > package rather than a class tells me that there's some kind of > > classpath problem. Is the TestClass in the classpath? Perhaps you're > > using the -jar option to "java" so that it ignores the classpath? > > > > I tried to use Importers and get this error again. > > > > Script util class > > > > 1. private org.mozilla.javascript.Context scriptContext; > > > 2. private Scriptable scriptScope; > > > 3. > > > 4. private void initServices() { > > > 5. scriptContext = org.mozilla.javascript.Context.enter(); > > > 6. scriptScope = new ImporterTopLevel(scriptContext); > > > 7. > > > 8. registerToScriptEngine("out", System.out); > > > 9. registerToScriptEngine("boTool", boTool); > > > 10. registerToScriptEngine("convertTool", convertTool); > > > 11. registerToScriptEngine("entityDAO", entityDAO); > > > 12. } > > > > Please, help me to solve this problem > > Thank you for respond! > I check classpath, to be more exact, build-paths of eclipse projects, > and didn't find out anything unusual: package exports and plugin > dependencies. I have following design: > plugin project "core" (includes and exports js.jar) > plugin project "core.ui" (includes and exports TestClass and > ScroptUtils, depends on "ru.griffo.core") > plugin project "userdomain" (runs scripts, depends on both above) > > Any suggestions will be helpfull.
I addition, I tried to change script and find out more detais of it's executing Script Text: hibernate = Packages.org.hibernate.criterion; jface = Packages.org.eclipse.jface.viewers; test = Packages.ru.griffo.core.ui.utils; var test1 = java.lang.Math.cos(0); out.println(test1); var test2 = jface.StructuredSelection.EMPTY; out.println(test2); var test3 = test.TestClass.variable; out.println(test3); The result was: 1.0 [JavaPackage org.eclipse.jface.viewers.StructuredSelection.EMPTY] [JavaPackage ru.griffo.core.ui.utils.TestClass.variable] Does it mean that rhino hadn't recognize StructuredSelection and TestClass classes? Before using rhino 1.7R2 I used embedded one from Java 6 SE, but it didn't fullfill my expectations about varargs, thought it works perfectly with any thirdparty classes with no extra efforts. _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
