Note that there are some explanatory texts on larger screens.

plurals
  1. POJava-Sandbox example throwing java.lang.NoClassDefFoundError
    primarykey
    data
    text
    <p>Anyone with experience using <a href="http://blog.datenwerke.net/p/java-sandbox-03-documentation.html" rel="nofollow">Java-Sandbox</a>, I have implemented one of the basic examples found in the documentation but i cant get it working.</p> <p>Code: SandPlayground.java</p> <pre><code>import java.util.concurrent.TimeUnit; import net.datenwerke.sandbox.*; import net.datenwerke.sandbox.SandboxContext.AccessType; import net.datenwerke.sandbox.SandboxContext.RuntimeMode; import net.datenwerke.sandbox.SandboxedEnvironment; public class SandPlayground { /** * @param args */ public static void main(String[] args) { System.out.println("Running..."); SandboxService sandboxService = SandboxServiceImpl.initLocalSandboxService(); // configure context SandboxContext context = new SandboxContext(); //context.setRunRemote(true); context.setRunInThread(true); context.setMaximumRunTime(2, TimeUnit.SECONDS, RuntimeMode.ABSOLUTE_TIME); context.addClassPermission(AccessType.PERMIT, "java.lang.System"); context.addClassPermission(AccessType.PERMIT, "java.io.PrintStream"); //run code in sandbox SandboxedCallResult&lt;String&gt; result = sandboxService.runSandboxed(MyEnvironment.class, context, "This is some value"); // output result System.out.println(result.get()); } } </code></pre> <p>MyEnvironment.java</p> <pre><code>import net.datenwerke.sandbox.SandboxedEnvironment; public class MyEnvironment implements SandboxedEnvironment&lt;String&gt; { private final String myValue; public MyEnvironment(String myValue){ this.myValue = myValue; } @Override public String execute() throws Exception { /* run untrusted code */ System.out.println(myValue); /* return some value */ return "This is a different value"; } } </code></pre> <p>And I'm getting the error:</p> <p><strong>EDIT</strong>: I've included the dependencies, but I'm still getting some errors:</p> <p>With the code above I get:</p> <pre><code>Exception in thread "main" net.datenwerke.sandbox.exception.SandboxedTaskKilledException: killed task as maxmimum runtime was exceeded at net.datenwerke.sandbox.SandboxMonitorDaemon.testRuntime(SandboxMonitorDaemon.java:82) at net.datenwerke.sandbox.SandboxMonitorDaemon.run(SandboxMonitorDaemon.java:57) at java.lang.Thread.run(Thread.java:724) </code></pre> <p>and when i remove the context.setMaximumRunTime() call, I get:</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/map/IdentityMap ... </code></pre> <p>Any help is much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload