The following applet is compiled and packed into jar which is then signed with a self-signed cert.
import java.applet.Applet;
import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
public class Test extends Applet {
private static final long serialVersionUID = -3127185193501384816L;
private final class DirectoryLister implements PrivilegedAction<File[]> {
private final String attachmentsFolder;
private DirectoryLister(String attachmentsFolder) {
this.attachmentsFolder = attachmentsFolder;
}
public File[] run() {
return new File(attachmentsFolder).listFiles();
}
}
public File[] getFiles() throws PrivilegedActionException {
String attachmentsFolder = getParameter("attachmentsFolder");
if (attachmentsFolder != null) {
return AccessController.doPrivileged(new DirectoryLister(
attachmentsFolder));
}
return null;
}
}
Applet is instantiated as follows:
<applet id="applet"
code="Test"
archive="applet.jar">
<param name="attachmentsFolder"
value="c:/test" />
</applet>
Applet is used as follows:
var files = applet.getFiles();
for (var file in files) {
// Do something to file.
}
The ff. error is encountered:
java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.liveconnect.SecureInvocation$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.liveconnect.SecureInvocation.CallMethod(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
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 sun.plugin.javascript.JSInvoke.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin.liveconnect.PrivilegedCallMethodAction.run(Unknown Source)
... 4 more
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission c:\test read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.list(Unknown Source)
at java.io.File.listFiles(Unknown Source)
at Test$DirectoryLister.run(Test.java:20)
at Test$DirectoryLister.run(Test.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at Test.getFiles(Test.java:28)
... 14 more
Which leads me to ask if I still need to explicitly grant perms in one of the config files in the Java home directory to read c:/test? If so, can anyone point me to a guide on how to do this?
Caching problem apparently. Clearing all caches and re-building/re-deploying solved the problem. I.e., no additional perms set-up needed.
Related
I want to dynamically load JAR Files using a ClassLoader from a ByteArray. It works fine with every executable JAR Files I've tried it with so far, except a Program using WebLaF. I always get the following set of Errors:
javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
at javax.xml.parsers.FactoryFinder.findServiceProvider(Unknown Source)
at javax.xml.parsers.FactoryFinder.find(Unknown Source)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
at com.thoughtworks.xstream.io.xml.DomDriver.<init>(DomDriver.java:64)
at com.thoughtworks.xstream.io.xml.DomDriver.<init>(DomDriver.java:56)
at com.thoughtworks.xstream.io.xml.DomDriver.<init>(DomDriver.java:48)
at com.alee.utils.XmlUtils.initializeXStream(XmlUtils.java:90)
at com.alee.utils.XmlUtils.getXStream(XmlUtils.java:77)
at com.alee.utils.XmlUtils.processAnnotations(XmlUtils.java:141)
at com.alee.laf.WebLookAndFeel$2.propertyChange(WebLookAndFeel.java:855)
at java.beans.PropertyChangeSupport.fire(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.UIManager.setLookAndFeel(Unknown Source)
at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:932)
at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:918)
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 xx.ByteCodeClassLoader.main(ByteCodeClassLoader.java:178)
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
... 24 more
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Error locating configuration files
at java.util.ServiceLoader.fail(Unknown Source)
at java.util.ServiceLoader.access$100(Unknown Source)
at java.util.ServiceLoader$LazyIterator.hasNextService(Unknown Source)
at java.util.ServiceLoader$LazyIterator.hasNext(Unknown Source)
at java.util.ServiceLoader$1.hasNext(Unknown Source)
at javax.xml.parsers.FactoryFinder$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 24 more
Caused by: java.io.IOException: Cannot fetch URL out of res
at xx.ByteCodeClassLoader.findResources(ByteCodeClassLoader.java:72)
at java.lang.ClassLoader.getResources(Unknown Source)
... 29 more
java.lang.NullPointerException
at com.alee.utils.XmlUtils.processAnnotations(XmlUtils.java:141)
at com.alee.laf.WebLookAndFeel$2.propertyChange(WebLookAndFeel.java:855)
at java.beans.PropertyChangeSupport.fire(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.UIManager.setLookAndFeel(Unknown Source)
at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:932)
at com.alee.laf.WebLookAndFeel.install(WebLookAndFeel.java:918)
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 xx.ByteCodeClassLoader.main(ByteCodeClassLoader.java:178)
After this, the JAR runs successfully until it has to load the GUI. Then it crashes with another error:
javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
My Code is the following:
public class ByteCodeClassLoader extends ClassLoader {
final Map<String, byte[]> classes;
final Map<String, byte[]> res;
-snip-
#Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte[] code = classes.get(name);
if (code != null){
return defineClass(name, code, 0, code.length);
}
return super.findClass(name);
}
#Override
public URL getResource(String name) {
URL ur = ByteCodeClassLoader.class.getResource(name);
if (ur != null) {
return ur;
}
try {
return new URL(null, "bytes:///" + name, new BytesHandler());
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
#Override
public InputStream getResourceAsStream(String name) {
return new ByteArrayInputStream(res.get(name));
}
#Override
protected Enumeration<URL> findResources(String name) throws IOException {
throw new IOException("Cannot fetch URL out of res");
}
-snip-
If you know a solution to this issue, it would help me greatly. Even just a lead in the right direction would be awesome. I hope I supplied all the important information.
I'm trying to connect to the Amazon Athena, using jdbc in a maven project, but an exception is being raised. I think that the class is not being found. In Athena's guide it says:
Set the JDBC property, aws_credentials_provider_class, equal to the class name, and include itin your classpath. (1)
Since I'm using eclipse, I thought that the class would be already in the classpath, but apparently not. I tested the code in a simple java project (not maven) and it worked.
AmazonCredentialsProvider.java:
package athena;
import com.amazonaws.auth.AWSCredentials;
public class AmazonCredentials implements AWSCredentials {
#Override public String getAWSAccessKeyId() { return "..."; }
#Override public String getAWSSecretKey() { return "..."; }
}
AmazonCredentialsProvider.java:
package athena;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
public class AmazonCredentialsProvider implements AWSCredentialsProvider {
#Override public AWSCredentials getCredentials() { return new AmazonCredentials(); }
#Override public void refresh() {}
}
The code snippet of the connection :
Class.forName("com.amazonaws.athena.jdbc.AthenaDriver");
Properties properties = new Properties();
properties.setProperty("user", user);
properties.setProperty("password", password);
properties.setProperty("aws_credentials_provider_class", "athena.AmazonCredentialsProvider");
Connection connection = DriverManager.getConnection("jdbc:awsathena://athena." + region + ".amazonaws.com:443", properties);
The exception:
java.sql.SQLException: Failed to load AWS credentials provider class:
athena.AmazonCredentialsProvider at
com.amazonaws.athena.jdbc.AthenaDriverPropertiesFactory.lambda$parseProperties$2(AthenaDriverPropertiesFactory.java:52)
at
com.amazonaws.athena.jdbc.AthenaDriverPropertiesFactory.setClientConfigProperty(AthenaDriverPropertiesFactory.java:159)
at
com.amazonaws.athena.jdbc.AthenaDriverPropertiesFactory.parseProperties(AthenaDriverPropertiesFactory.java:40)
at
com.amazonaws.athena.jdbc.AthenaDriver.connect(AthenaDriver.java:110)
at java.sql.DriverManager.getConnection(Unknown Source) at
java.sql.DriverManager.getConnection(Unknown Source) at
athena.Athena.(Athena.java:94) at
services.GraphService.verify(GraphService.java:194) 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
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
at
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:183)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.lambda$apply$0(ResourceMethodInvoker.java:405)
at
org.glassfish.jersey.server.ServerRuntime$AsyncResponder$2$1.run(ServerRuntime.java:843)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:272) at
org.glassfish.jersey.internal.Errors$1.call(Errors.java:268) at
org.glassfish.jersey.internal.Errors.process(Errors.java:316) at
org.glassfish.jersey.internal.Errors.process(Errors.java:298) at
org.glassfish.jersey.internal.Errors.process(Errors.java:268) at
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
at
org.glassfish.jersey.server.ServerRuntime$AsyncResponder$2.run(ServerRuntime.java:838)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source) at java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
java.lang.Thread.run(Unknown Source) Caused by:
java.lang.ClassNotFoundException: athena.AmazonCredentialsProvider at
java.net.URLClassLoader.findClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
java.lang.ClassLoader.loadClass(Unknown Source) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Unknown Source) at
com.amazonaws.athena.jdbc.AthenaDriverPropertiesFactory.lambda$parseProperties$2(AthenaDriverPropertiesFactory.java:44)
... 31 more
Does anyone know how to solve it?
Are you using the latest version of the JDBC driver?
If yes, try to follow these instructions:
https://docs.aws.amazon.com/redshift/latest/mgmt/configure-jdbc-connection-with-maven.html
I am trying to write an applet that run in html page .
If I run the applet in eclipse with debug as JApplet it runs fine, but if i put it in an html it has an error.
Java console say :
basic: eccezione: java.lang.ExceptionInInitializerError
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at org.restlet.resource.ClientResource.(ClientResource.java:405)
at com.gabrielepiscitelli.JAppletGui.RestClient.Client.listAllThreads(Client.java:39)
at com.gabrielepiscitelli.JAppletGui.Gui.GUIApplet.(GUIApplet.java:191)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.util.logging.config.file" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at org.restlet.engine.Engine.configureLog(Engine.java:194)
at org.restlet.engine.Engine.register(Engine.java:380)
at org.restlet.engine.Engine.register(Engine.java:368)
at org.restlet.engine.Engine.getInstance(Engine.java:252)
at org.restlet.data.Method.(Method.java:334)
at org.restlet.data.Method.(Method.java:393)
at org.restlet.data.Method.(Method.java:358)
at org.restlet.data.Method.(Method.java:57)
... 28 more
the code at Client.java:39 is the line cr = new ClientResource(lURI); in this part of java file:
/**
*
*/
package com.gabrielepiscitelli.JAppletGui.RestClient;
import java.io.IOException;
import org.restlet.data.Status;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiPost;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiThread;
import com.gabrielepiscitelli.JAppletGui.DataGui.DataGuiUser;
import com.gabrielepiscitelli.SystemForum.Utils.ExceptionForum;
import com.google.gson.Gson;
/**
* #author Gabriele
*
*/
public class Client {
/**
*
* #return
* #throws ExceptionForum
*/
public static DataGuiThread[] listAllThreads() throws ExceptionForum{
DataGuiThread[] lRestDataGuiThreads = null;
ClientResource cr = null;
Gson gson = new Gson();
Status status = null;
String json = null;
String lURI = "http://localhost:8182/ListThreadsAll";
cr = new ClientResource(lURI);
try {
json = cr.get().getText();
status = cr.getStatus();
if (status.getCode() != 200) {
// System.out.println(status);
// System.exit(status.getCode());
Status lStatusJson = gson.fromJson(json, Status.class);
throw new ExceptionForum(ExceptionForum.ExType.CLIENT,
"Client error.",
lStatusJson.getDescription() + lStatusJson.getReasonPhrase());
} else {
lRestDataGuiThreads = gson.fromJson(json, DataGuiThread[].class);
}
} catch (ResourceException e) {
// e.printStackTrace();
throw new ExceptionForum(ExceptionForum.ExType.CLIENT,
"Client error.",
e.getMessage());
} catch (IOException e) {
// e.printStackTrace();
throw new ExceptionForum(ExceptionForum.ExType.CLIENT,
"Client error.",
e.getMessage());
}
return lRestDataGuiThreads;
}
Html file is simply :
<html><body>
<p>
<applet code="com.gabrielepiscitelli.JAppletGui.Gui.GUIApplet.class" archive="GUIApplet.jar,miglayout15-swing.jar,org.restlet.jar,gson-2.2.4.jar"
width="800" height="640"></applet>
</p>
Is there someone that can explain me the problem? thanks in advances!
Caused by: java.security.AccessControlException: access denied
("java.util.PropertyPermission" "java.util.logging.config.file" "read")
This applet needs to be trusted. Digitally sign the applet code.
I'm using Rhino 1.7 R4 with envjs 1.2 on Mac OSX with JDK 1.6.0_33
If I run:
java -jar rhino-1.7R4.jar -opt -1
And then:
load('env.rhino-1.2.js')
Then the script is loaded successfully.
When I load the same JS script from Java via RhinoTest.java:
import org.apache.commons.io.IOUtils;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.tools.shell.Main;
import org.mozilla.javascript.tools.shell.ShellContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class RhinoTest {
static final Logger LOGGER = LoggerFactory.getLogger(RhinoTest.class);
static private Scriptable SCRIPTABLE;
static private List<Script> scripts;
public static void main(String[] args) {
ShellContextFactory cxFactory = Main.shellContextFactory;
cxFactory.call(new ContextAction() {
#Override
public Object run(Context cx) {
final Initiator initiator = new Initiator(cx).init();
LOGGER.trace("Run script");
try {
return initiator.execute();
} finally {
}
}
class Initiator {
Initiator(Context context) {
this.cx = context;
}
Initiator init() {
if (SCRIPTABLE == null)
createScriptable();
initContext();
return this;
}
Object execute() {
return null;
}
void createScriptable() {
LOGGER.trace("init standard objects");
SCRIPTABLE = cx.initStandardObjects();
LOGGER.trace("set optimization level to -1");
cx.setOptimizationLevel(-1);// bypass the 64k limit // interpretive mode
attachJs("env.rhino-1.2.js");
LOGGER.trace("set optimization level to 9");
cx.setOptimizationLevel(9);
}
#SuppressWarnings("deprecation")
private void attachJs(String jsFileName) {
InputStream in = null;
InputStreamReader reader = null;
if (LOGGER.isDebugEnabled()) LOGGER.debug("loading " + jsFileName);
try {
in = RhinoTest.class.getResourceAsStream(jsFileName);
if (in == null)
throw new RuntimeException("cannot find js file : " + jsFileName);
reader = new InputStreamReader(in);
if (scripts == null)
scripts = new ArrayList<Script>();
scripts.add(cx.compileReader(SCRIPTABLE, reader, jsFileName, 1, null));
if (LOGGER.isDebugEnabled()) LOGGER.debug("loaded " + jsFileName);
} catch (IOException e) {
throw new RuntimeException("cannot load js file : " + jsFileName, e);
} finally {
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(reader);
}
}
void initContext() {
LOGGER.trace("set optimization level to -1");
cx.setOptimizationLevel(-1);// bypass the 64k limit // interpretive mode
for (Script s : scripts) {
s.exec(cx, SCRIPTABLE);
}
}
private final Context cx;
}
});
}
}
I get:
Exception in thread "main" org.mozilla.javascript.EvaluatorException: missing : after property id (env.rhino-1.2.js#2121)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(Unknown Source)
at org.mozilla.javascript.DefaultErrorReporter.error(Unknown Source)
at org.mozilla.javascript.Parser.addError(Unknown Source)
at org.mozilla.javascript.Parser.reportError(Unknown Source)
at org.mozilla.javascript.Parser.mustMatchToken(Unknown Source)
at org.mozilla.javascript.Parser.primaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.argumentList(Unknown Source)
at org.mozilla.javascript.Parser.memberExprTail(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.expr(Unknown Source)
at org.mozilla.javascript.Parser.statementHelper(Unknown Source)
at org.mozilla.javascript.Parser.statement(Unknown Source)
at org.mozilla.javascript.Parser.parseFunctionBody(Unknown Source)
at org.mozilla.javascript.Parser.function(Unknown Source)
at org.mozilla.javascript.Parser.primaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.expr(Unknown Source)
at org.mozilla.javascript.Parser.primaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.memberExpr(Unknown Source)
at org.mozilla.javascript.Parser.unaryExpr(Unknown Source)
at org.mozilla.javascript.Parser.mulExpr(Unknown Source)
at org.mozilla.javascript.Parser.addExpr(Unknown Source)
at org.mozilla.javascript.Parser.shiftExpr(Unknown Source)
at org.mozilla.javascript.Parser.relExpr(Unknown Source)
at org.mozilla.javascript.Parser.eqExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitAndExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitXorExpr(Unknown Source)
at org.mozilla.javascript.Parser.bitOrExpr(Unknown Source)
at org.mozilla.javascript.Parser.andExpr(Unknown Source)
at org.mozilla.javascript.Parser.orExpr(Unknown Source)
at org.mozilla.javascript.Parser.condExpr(Unknown Source)
at org.mozilla.javascript.Parser.assignExpr(Unknown Source)
at org.mozilla.javascript.Parser.expr(Unknown Source)
at org.mozilla.javascript.Parser.statementHelper(Unknown Source)
at org.mozilla.javascript.Parser.statement(Unknown Source)
at org.mozilla.javascript.Parser.parse(Unknown Source)
at org.mozilla.javascript.Parser.parse(Unknown Source)
at org.mozilla.javascript.Context.compileImpl(Unknown Source)
at org.mozilla.javascript.Context.compileReader(Unknown Source)
at org.mozilla.javascript.Context.compileReader(Unknown Source)
at RhinoTest$1$Initiator.attachJs(RhinoTest.java:85)
at RhinoTest$1$Initiator.createScriptable(RhinoTest.java:63)
at RhinoTest$1$Initiator.init(RhinoTest.java:44)
at RhinoTest$1.run(RhinoTest.java:28)
at org.mozilla.javascript.Context.call(Unknown Source)
at org.mozilla.javascript.ContextFactory.call(Unknown Source)
at RhinoTest.main(RhinoTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Please help
Wladimir,
You were right it was a version thing.
It turns out that the batik libs I imported included another version of rhino.
By excluding batik-js from my project for each batik dependency this issue went away.
I'm trying to build simple echo server as RMI application (step by step as it's described in Sun tutorial).
All source code is shown below, it's very simple:
package test;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface EchoServer extends Remote {
public String sendString (String str) throws RemoteException;
}
package test;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public class EchoServerImpl extends UnicastRemoteObject implements EchoServer {
public EchoServerImpl () throws RemoteException {
super ();
}
public String sendString (String str) throws RemoteException {
return str.toUpperCase();
}
}
package test;
import java.rmi.Naming;
public class RMIServer {
public RMIServer () {
try {
EchoServer eServer = new EchoServerImpl ();
Naming.rebind ("rmi://localhost:1099/EchoService", eServer); // <--exception
} catch (Exception e) {
e.printStackTrace ();
}
}
public static void main(String[] args) {
new RMIServer ();
}
}
I compile code with rmic and I see file EchoServerImpl_Stub.class. After that I run 'rmiregistry' and then I start RMIServer. And at that moment I see ServerException:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: test.EchoServerImpl_Stub
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:359)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at test.RMIServer.(RMIServer.java:10)
at test.RMIServer.main(RMIServer.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: test.EchoServerImpl_Stub
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: test.EchoServerImpl_Stub
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
... 12 more
I think it's a common problem and it's probably connected with wrong deploying. How to fix it?
I think it's your rmiregistry classpath. The test.EchoServer interface needs to be accessible to the rmiregistry itself. Set your CLASSPATH environment variable before you run up the rmiregistry e.g.
C:\>set CLASSPATH="MyBinFolder"
C:\>rmiregistry
Also, rmic is a hangover from before Java 5. It isn't necessary to run it anymore. Just run your server and client as normal and the proxies will be created dynamically.
Regards,
MK