Re: ScriptEngineManager throws an Error but works... why?

197 views
Skip to first unread message

Philippe Lhoste

unread,
Jun 15, 2012, 6:22:24 AM6/15/12
to Google-We...@googlegroups.com
On 12/06/2012 12:26, Jepse wrote:
> I'm using SctriptEngineManager in gwt shared package on client side to evaluate String
> based Conditions (4>2?) or formulas. Every time GWT executes the code, i receive an error
> in the development console... It says:
> */12:13:13.012 [ERROR] [contacts] Line 253: No source code is available for type
> javax.script.ScriptEngineManager; did you forget to inherit a required module?/*
>
> For some other modules it simply doesn't work because the code is not applicable for
> converting into javascript. So far all i need to know - fine.
>
> But ScriptEngineManager throws the same error but works... Not that i don't appreciate
> this behaviour. But i still want to know why it throws this error?
>
> Can anybody point me the reason? Or a better way to evaluate String based conditions or
> formulars?

Duplicate message? I already answered the second message, but since it had less
information, I also answer this one.

You use the ScriptEngineManager to run JS on a browser? Do you know that JavaScript is
already available out of the box in browsers?
GWT allows you to access directly the JS layer, via JSNI. I actually have little
experience in the domain, so I let you explore yourself this feature.

Note: for simple formula evaluation, there are also pure Java solutions.

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

Thomas Broyer

unread,
Jun 15, 2012, 7:48:41 AM6/15/12
to google-we...@googlegroups.com


On Tuesday, June 12, 2012 12:26:52 PM UTC+2, Jepse wrote:
Hi there and hello to this group! (First Post)

First i have to say gwt changed my programmer-life ;) Thanks for that!

My Question:


I'm using SctriptEngineManager in gwt shared package on client side to evaluate String based Conditions (4>2?) or formulas. Every time GWT executes the code, i receive an error in the development console... It says:
12:13:13.012 [ERROR] [contacts] Line 253: No source code is available for type javax.script.ScriptEngineManager; did you forget to inherit a required module?

For some other modules it simply doesn't work because the code is not applicable for converting into javascript. So far all i need to know - fine.

But ScriptEngineManager throws the same error but works... Not that i don't appreciate this behaviour. But i still want to know why it throws this error?

Can anybody point me the reason? Or a better way to evaluate String based conditions or formulars?

My Code:
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");   
        Object result = engine.eval("4>3");
        Boolean boolResult = (Boolean)result;

Because it's referenced from within your "source path" (you have a <source path="shared"/> in your gwt.xml right?), GWT searches for its source code (and here doesn't find it and logs an error; even if you had the JRE's sources, it'll still log an error because there's no module with javax.script in its source path).
But because you don't use it in your client-side code, there's no reason it would fail.

Solution: move it out of your "shared" package, as it's a "server" thing more than a "shared" thing.

Jepse

unread,
Jul 3, 2012, 4:37:53 AM7/3/12
to google-we...@googlegroups.com
Hi there...

Sorry for the double post! My first post didnt show up. So i thought it was recognised as spam. I'll be deleting it.

Actually i'm using JSNI for eval a simple fomular. I haven't familiar with this feature. But now it works. What is the pure Java solution this problem? In my search i dind't find a native soloution for evaluating Stings-Formulars.

The thing what i have been curious about was, that the development mode throwed an error but still works on client side.

Am Dienstag, 12. Juni 2012 12:26:52 UTC+2 schrieb Jepse:
Hi there and hello to this group! (First Post)

First i have to say gwt changed my programmer-life ;) Thanks for that!

My Question:

I'm using SctriptEngineManager in gwt shared package on client side to evaluate String based Conditions (4>2?) or formulas. Every time GWT executes the code, i receive an error in the development console... It says:
12:13:13.012 [ERROR] [contacts] Line 253: No source code is available for type javax.script.ScriptEngineManager; did you forget to inherit a required module?

For some other modules it simply doesn't work because the code is not applicable for converting into javascript. So far all i need to know - fine.

But ScriptEngineManager throws the same error but works... Not that i don't appreciate this behaviour. But i still want to know why it throws this error?

Can anybody point me the reason? Or a better way to evaluate String based conditions or formulars?

My Code:
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");   
        Object result = engine.eval("4>3");
        Boolean boolResult = (Boolean)result;

Am Dienstag, 12. Juni 2012 12:26:52 UTC+2 schrieb Jepse:
Hi there and hello to this group! (First Post)

First i have to say gwt changed my programmer-life ;) Thanks for that!

My Question:

I'm using SctriptEngineManager in gwt shared package on client side to evaluate String based Conditions (4>2?) or formulas. Every time GWT executes the code, i receive an error in the development console... It says:
12:13:13.012 [ERROR] [contacts] Line 253: No source code is available for type javax.script.ScriptEngineManager; did you forget to inherit a required module?

For some other modules it simply doesn't work because the code is not applicable for converting into javascript. So far all i need to know - fine.

But ScriptEngineManager throws the same error but works... Not that i don't appreciate this behaviour. But i still want to know why it throws this error?

Can anybody point me the reason? Or a better way to evaluate String based conditions or formulars?

My Code:
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");   
        Object result = engine.eval("4>3");
        Boolean boolResult = (Boolean)result;

Am Dienstag, 12. Juni 2012 12:26:52 UTC+2 schrieb Jepse:
Hi there and hello to this group! (First Post)

First i have to say gwt changed my programmer-life ;) Thanks for that!

My Question:

I'm using SctriptEngineManager in gwt shared package on client side to evaluate String based Conditions (4>2?) or formulas. Every time GWT executes the code, i receive an error in the development console... It says:
12:13:13.012 [ERROR] [contacts] Line 253: No source code is available for type javax.script.ScriptEngineManager; did you forget to inherit a required module?

For some other modules it simply doesn't work because the code is not applicable for converting into javascript. So far all i need to know - fine.

But ScriptEngineManager throws the same error but works... Not that i don't appreciate this behaviour. But i still want to know why it throws this error?

Can anybody point me the reason? Or a better way to evaluate String based conditions or formulars?

My Code:
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("js");   
        Object result = engine.eval("4>3");
        Boolean boolResult = (Boolean)result;

Reply all
Reply to author
Forward
0 new messages