ServerException is being thrown while binding RMI service - java

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

Related

Illegal Access error while mocking a singleton class using powermockito which extends JFrame

I tried to create a mock on a singleton class using powermockito, this singleton class extends JFrame, when I specify the class name in #PrepareForTest it gives an exception.
The Conditon I am trying to test
JComponent context = GVCScreenManager.getInstance().getSelectedComponent();
if( context instanceof GVCSerializable)
{
System.out.println(" third if"); //I need to go inside this if condition
GVCSerializable ser = (GVCSerializable) context;
GVCComponentState state = ser.getComponentState();
//some more method calls
}
Test case
#RunWith(PowerMockRunner.class)
#PrepareForTest({GVCScreenManager.class})//due to this I get illegal access exception as this class extends JFrame
class Myclass
{
#Test
public void testConsumeResult() {
GVCSerializable jc=Mockito.mock(GVCSerializable.class);
GVCScreenManager gvc=Mockito.mock(GVCScreenManager.class);
PowerMockito.mockStatic(GVCScreenManager.class);
Mockito.when(GVCScreenManager.getInstance()).thenReturn(gvc);
Mockito.when(gvc.getSelectedComponent()).thenReturn((JComponent) jc);
ResultHolder result=new AnnotationResultHolder(0);
annotationResultConsumer.consumeResult(result);
}
}
Stack trace
java.lang.IllegalAccessError: class javax.swing.JFrame cannot access its superinterface javax.swing.TransferHandler$HasGetTransferHandler
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:259)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:259)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:180)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(Unknown Source)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Unknown Source)
at sun.reflect.generics.tree.ClassTypeSignature.accept(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseSig(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseClassValue(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseClassArray(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseArray(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)
at java.lang.Class.createAnnotationData(Unknown Source)
at java.lang.Class.annotationData(Unknown Source)
at java.lang.Class.getAnnotation(Unknown Source)
at org.junit.internal.MethodSorter.getDeclaredMethods(MethodSorter.java:52)
at org.junit.internal.runners.TestClass.getAnnotatedMethods(TestClass.java:45)
at org.junit.internal.runners.MethodValidator.validateTestMethods(MethodValidator.java:71)
at org.junit.internal.runners.MethodValidator.validateStaticMethods(MethodValidator.java:44)
at org.junit.internal.runners.MethodValidator.validateMethodsForDefaultRunner(MethodValidator.java:50)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.validate(PowerMockJUnit44RunnerDelegateImpl.java:108)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.<init>(PowerMockJUnit44RunnerDelegateImpl.java:70)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.<init>(PowerMockJUnit47RunnerDelegateImpl.java:42)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.<init>(PowerMockJUnit49RunnerDelegateImpl.java:25)
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 org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:149)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:39)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:218)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:59)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:32)
at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:33)
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 org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Please help me solve this problem.
include #PrepareForTest({TransferHandler.class,GVCScreenManager.class}) so we need to prepare for test of its superInterface Transferhandler

Getting org/apache/poi/UnsupportedFileFormatException

I tried the following code to read the contents of .xlsm file
import java.io.FileInputStream;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class ReadMacroExcel {
public static void main(String[] args) {
try {
FileInputStream f=new FileInputStream("C:\\Users\\user\\Documents\\samplewkbk.xlsm");
org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(f);
System.out.println(workbook);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
I am getting the following expection:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/UnsupportedFileFormatException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
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 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:87)
at wipro.ReadMacroExcel.main(ReadMacroExcel.java:13)
I use the following jar files:
poi-ooxml-3.11.jar
poi-3.9.jar
xmlbeans-2.3.0.jar
poi-ooxml-schemas-3.7-beta1.jar
dom4j-1.6.jar

Webservices: [failed to localize] The endpointInterface class Calculator could not be found()

I created a webservice called calculator, an interface, an implementation class, and annotated it, and I was trying to create the service and the WSDL. Then I get the following Error. Not sure if it's a facet error or an error in the version of JAXWS from WAS 8.0? Tried to resolve it but couldn't find resources on the web as well.
** Here's the CODE**
//Interface:
package com.pp;
import javax.jws.WebMethod;
import javax.jws.WebService;
#WebService
public interface Calculator {
#WebMethod
public int add(int var1, int var2);
}
//Implementation Class:
package com.pp;
import javax.jws.WebService;
#WebService(endpointInterface=" com.pp.Calculator")
public class CalculatorImpl implements Calculator {
#Override
public int add(int var1, int var2) {
// TODO Auto-generated method stub
return var1+var2;
}
}
ERROR:
Errors occurred during wsgen.
Errors occurred during wsgen.
error: compilation failed, errors should have been reported
Note: ap round: 1
Problem encountered during annotation processing;
see stacktrace below for more information.
com.ibm.jtc.jax.tools.ws.processor.modeler.ModelerException: [failed to localize] The endpointInterface class com.pp.Calculator could not be found()
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceAP.onError(Unknown Source)
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceVisitor.getEndpointInterfaceDecl(Unknown Source)
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceVisitor.isLegalImplementation(Unknown Source)
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceVisitor.shouldProcessWebService(Unknown Source)
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(Unknown Source)
at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(Unknown Source)
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceAP.buildModel(Unknown Source)
at com.ibm.jtc.jax.tools.ws.processor.modeler.annotation.WebServiceAP.process(Unknown Source)
at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(Unknown Source)
at com.sun.tools.apt.comp.Apt.main(Unknown Source)
at com.sun.tools.apt.main.JavaCompiler.compile(Unknown Source)
at com.sun.tools.apt.main.Main.compile(Unknown Source)
at com.sun.tools.apt.main.Main.compile(Unknown Source)
at com.sun.tools.apt.Main.processing(Unknown Source)
at com.sun.tools.apt.Main.process(Unknown Source)
at com.sun.tools.apt.Main.process(Unknown Source)
at com.ibm.jtc.jax.tools.ws.wscompile.WsgenTool.buildModel(Unknown Source)
at com.ibm.jtc.jax.tools.ws.wscompile.WsgenTool.run(Unknown Source)
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.ibm.ast.ws.jaxws.emitter.jdk6.jws22.command.WsGenCommand.execute(Unknown Source)
at com.ibm.ast.ws.jaxws.emitter.command.WsGenCommand.execute(Unknown Source)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.runCommand(Unknown Source)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.visitTop(Unknown Source)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.moveForwardToNextStop(Unknown Source)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager$6.run(Unknown Source)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(Unknown Source)
at org.eclipse.jface.operation.ModalContext.run(Unknown Source)
at org.eclipse.jface.wizard.WizardDialog.run(Unknown Source)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager.runForwardToNextStop(Unknown Source)
at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.runForwardToNextStop(Unknown Source)
at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.performFinish(Unknown Source)
at org.eclipse.wst.command.internal.env.ui.widgets.DynamicWizard.performFinish(Unknown Source)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(Unknown Source)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(Unknown Source)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Unknown Source)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.jface.window.Window.runEventLoop(Unknown Source)
at org.eclipse.jface.window.Window.open(Unknown Source)
at org.eclipse.wst.command.internal.env.ui.widgets.popup.DynamicPopupWizard.run(Unknown Source)
at org.eclipse.ui.internal.PluginAction.runWithEvent(Unknown Source)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(Unknown Source)
at org.eclipse.jface.action.ActionContributionItem.access$2(Unknown Source)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source)
at org.eclipse.ui.internal.Workbench.runUI(Unknown Source)
at org.eclipse.ui.internal.Workbench.access$4(Unknown Source)
at org.eclipse.ui.internal.Workbench$7.run(Unknown Source)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Unknown Source)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Unknown Source)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Unknown Source)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(Unknown Source)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Unknown Source)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Unknown Source)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Unknown Source)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(Unknown Source)
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.eclipse.equinox.launcher.Main.invokeFramework(Unknown Source)
at org.eclipse.equinox.launcher.Main.basicRun(Unknown Source)
at org.eclipse.equinox.launcher.Main.run(Unknown Source)

basic: eccezione: java.lang.ExceptionInInitializerError java.lang.RuntimeException: java.lang.ExceptionInInitializerError

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.

Errors with JADE platform

Good evening, I tried to use the JADE platform (official site -> http://jade.tilab.com/)
I followed tutorials that I found on youtube
Here's the code
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.core.Runtime;
import jade.util.ExtendedProperties;
import jade.util.leap.Properties;
import jade.wrapper.AgentContainer;
import jade.wrapper.ControllerException;
public class MainContainer {
public static void main(String[] args) {
try {
Runtime rt = Runtime.instance();
Properties p = new ExtendedProperties();
p.setProperty(Profile.GUI, "true");
ProfileImpl pc = new ProfileImpl(p);
AgentContainer container = rt.createAgentContainer(pc);
container.start();
} catch (ControllerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
But when I run the program I get errors like:
Exception in thread "main" java.lang.NoClassDefFoundError: jade/wrapper/ControllerException
****at java.lang.Class.getDeclaredMethods0(Native Method)
****at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
****at java.lang.Class.getMethod0(Unknown Source)
****at java.lang.Class.getMethod(Unknown Source)
****at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
****at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: jade.wrapper.ControllerException
****at java.net.URLClassLoader$1.run(Unknown Source)
****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 sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
****at java.lang.ClassLoader.loadClass(Unknown Source)
****... 6 more
How To fix it please !
PS: I'm on windows7
You are missing jade's jar from your classpath. You could add it to the -cp parameter of java. E.g.:
java -cp JADE-all-4.3.2.zip MainContainer

Categories

Resources