Access denied (java.lang.RuntimePermission getClassLoader)

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

I got the security error in the Java console but I also got the
correct output in the lower pane (this is on FF on OSX). BTW, It
looks really cool!

David K.

On May 12, 2009, at 9:59 AM, Michal Hantl wrote:

didnt help much.

Any help appreciated.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

2009/5/12 David K. [email protected]:

I got the security error in the Java console but I also got the correct
output in the lower pane (this is on FF on OSX). Â BTW, It looks really cool!

David K.

Thanks! Heres the new home for the project
http://rubygami.googlecode.com/svn/trunk/index.html
(http://rubygami.googlecode.com/)

I have plans on using github as a storage and for now it needs some
work on the gighlighter:). Its a very fun project.

Btw. I chose google code over github this time because it can serve
html files with the right header so i dont need to upload the files
everytime i commit change.

There is only one problem - some people get the following exception.
 http://xircles.codehaus.org/manage_email


S pozdravem, Regards
Michal Hantl

gtalk/jabber: [email protected]
icq: 241813215


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email