Hi guys,
i just started playing with JRuby a while ago and so far im loving
it. I began experimenting with JRuby inside an applet and it worked
right from the start and i was happily building.
heres the progress http://stuff.hantl.cz/jrubyeditor/
There is only one problem - some people get the following exception.
It is mostly Opera users and i saw it once too on FF at school. Any
idea whats the the problem? I’m not very Java experinced and googling
didnt help much.
Any help appreciated.
access denied (java.lang.RuntimePermission getClassLoader)
trace:
access denied (java.lang.RuntimePermission getClassLoader)
java.security.AccessControlException: access denied
(java.lang.RuntimePermission getClassLoader)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.Thread.getContextClassLoader(Unknown Source)
at org.jruby.RubyInstanceConfig.<>init>(RubyInstanceConfig.java:135)
at org.jruby.Ruby.newInstance(Ruby.java:160)
at jrubyapplet.MyApplet.resetRuby(MyApplet.java:34)
at jrubyapplet.MyApplet.instance(MyApplet.java:39)
at jrubyapplet.MyApplet.evalRuby(MyApplet.java:20)
at jrubyapplet.MyApplet.evalRubyToJson(MyApplet.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opera.LCInvoke.invoke(LCInvoke.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opera.PrivilegedInvoke.run(LiveConnectPrivilegedActions.java:219)
at java.security.AccessController.doPrivileged(Native Method)
at com.opera.PrivilegedThread.run(LiveConnectPrivilegedActions.java:290)
at java.lang.Thread.run(Unknown Source)
HTML Code:
…
No Java 2 SDK, Standard Edition v 1.4.1 support for APPLET
JAVA Code:
package jrubyapplet;
import java.applet.Applet;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import org.jruby.Ruby;
import org.jruby.RubyObject;
import org.json.simple.JSONObject;
/**
*
-
@author [email protected]
*/
public class MyApplet extends Applet {Ruby instance = null;
public Object evalRuby(String input) {
return instance().evalScriptlet(input);
}public String evalRubyToJson(String input) {
JSONObject json = new JSONObject();
try {
resultToJson(evalRuby(input), json);
} catch (Exception e) {
exceptionToJson(e, json);
}
return json.toJSONString();
}public void resetRuby() {
instance = Ruby.newInstance();
}private Ruby instance() {
if (instance == null) {
resetRuby();
}
return instance;
}public void resultToJson(Object o, JSONObject json) {
RubyObject ro = (RubyObject) o;
json.put(“result”, ro.inspect());
}public void exceptionToJson(Exception e, JSONObject json) {
json.put(“exception”, e.getMessage().toString());
json.put(“trace”, traceToString(e));
}protected String traceToString(Exception e) {
Writer writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
return writer.toString();
}
}
–
S pozdravem, Regards
Michal Hantl
gtalk/jabber: [email protected]
icq: 241813215
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email