how to display a JFrame from an applet? - applet

I have this class called PollFrame that extends JFrame in a file called PollFrame.java . PollFrame contains a form. I have an applet, which has a button in it. When the button is clicked, I want the PollFrame to be displayed. I set the ActionPerformed as:
Pollframe poll = new PollFrame(); // This initializes the form
poll.setVisible(true);
However, when I click the button, I get the following error :
Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
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.checkExit(Unknown Source)
at javax.swing.JFrame.setDefaultCloseOperation(Unknown Source)
at com.org.pollFrame.initComponents(pollFrame.java:54)
at com.org.pollFrame.<init>(pollFrame.java:11)
at com.org.EmployeeApplet.requestRoomActionPerformed(EmployeeApplet.java:216)
at com.org.EmployeeApplet.access$300(EmployeeApplet.java:7)
at com.org.EmployeeApplet$4.actionPerformed(EmployeeApplet.java:71)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(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)
I am guessing fromt he above error that calling another class file from an applet is prohibited. Is there any way I can display the PollFrame from the applet?

It seems like you're calling setDefaultCloseOperation() on your JFrame, which raises the security exception
You can definitively call another class from an applet but some operations are restricted, eg. you can't open local files, open connections to other machines...

I have this class called PollFrame that extends JFrame in a file called PollFrame.java . PollFrame contains a form. I have an applet, which has a button in it. When the button is clicked, I want the PollFrame to be displayed.
This is a one liner:
applet.showDocument("PollFrame.jnlp", "_blank");
The frame launched by PollFrame.jnlp will be able to call any default close operation it likes while still sand-boxed, since it will have a separate VM. To be 'always on top' it will need to be trusted (and then fight it out with all the other apps. that aim to be always on top).

Related

Installer hangs with JRE 8

We've recently moved our install4j project to use JRE 8. However the installer hangs at a specific dialog and we see the following in error.log. Would you know what could be causing this?
Exception in thread "AWT-EventQueue-0" java.lang.InternalError: java.io.IOException: Stream closed
at java.text.BreakIterator.createBreakInstance(Unknown Source)
at java.text.BreakIterator.getBreakInstance(Unknown Source)
at java.text.BreakIterator.getLineInstance(Unknown Source)
at javax.swing.text.GlyphView.getBreakSpotUseBreakIterator(Unknown Source)
at javax.swing.text.GlyphView.getBreakSpot(Unknown Source)
at javax.swing.text.GlyphView.getBreakWeight(Unknown Source)
at javax.swing.text.FlowView$LogicalView.getPreferredSpan(Unknown Source)
at javax.swing.text.FlowView.calculateMinorAxisRequirements(Unknown Source)
at javax.swing.text.BoxView.checkRequests(Unknown Source)
at javax.swing.text.BoxView.getMinimumSpan(Unknown Source)
at javax.swing.text.BoxView.calculateMinorAxisRequirements(Unknown Source)
at javax.swing.text.BoxView.checkRequests(Unknown Source)
at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
at javax.swing.text.BoxView.layout(Unknown Source)
at javax.swing.text.BoxView.setSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JEditorPane.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.JViewport.validateView(Unknown Source)
at javax.swing.JViewport.scrollRectToVisible(Unknown Source)
at javax.swing.JComponent.scrollRectToVisible(Unknown Source)
at com.install4j.runtime.beans.screens.InfoScreen.updateText(Unknown Source)
at com.install4j.runtime.beans.screens.InfoScreen.willActivate(Unknown Source)
at com.install4j.runtime.installer.frontend.ScreenEnvelope.activate(Unknown Source)
at com.install4j.runtime.wizard.WizardBase.setScreen(Unknown Source)
at com.install4j.runtime.installer.frontend.WizardScreenExecutor.execute(Unknown Source)
at com.install4j.runtime.installer.controller.Controller$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
thanks
This is a bug in the hot spot compiler in Java 8, see
http://kingsfleet.blogspot.co.il/2014/11/but-thats-impossible-or-finding-out.html
According to the above blog post, a workaround is to add the following VM parameter
-XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot

Compile issue with GWT back end in libgdx

It compiled fine a few days ago but something i did must have caused the issue but so much was done i am not too sure.
Error log here: http://pastebin.com/P1JHqDBD
If anyone needs anything else to solve the issue, let me know!
I tried deleting the unitcache folder in my HTML5 folder. didnt help, same isse. also tried cleaning.
Thanks in advance
EDIT:
Nov 27, 2013 10:31:12 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[ERROR] Failure in unit cache map load.
java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to read from byte cache
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.gwt.dev.javac.PersistentUnitCache.awaitUnitCacheMapLoad(PersistentUnitCache.java:466)
at com.google.gwt.dev.javac.PersistentUnitCache.find(PersistentUnitCache.java:391)
at com.google.gwt.dev.javac.CompilationStateBuilder.addArchive(CompilationStateBuilder.java:365)
at com.google.gwt.dev.ArchivePreloader.preloadArchives(ArchivePreloader.java:65)
at com.google.gwt.dev.DevModeBase$UiBrowserWidgetHostImpl.createModuleSpaceHost(DevModeBase.java:106)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:197)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Unable to read from byte cache
at com.google.gwt.dev.util.DiskCache.transferFromStream(DiskCache.java:171)
at com.google.gwt.dev.util.DiskCacheToken.readObject(DiskCacheToken.java:87)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
at com.google.gwt.dev.javac.CachedCompilationUnit.readObject(CachedCompilationUnit.java:204)
at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.google.gwt.dev.javac.PersistentUnitCache.loadUnitMap(PersistentUnitCache.java:517)
at com.google.gwt.dev.javac.PersistentUnitCache.access$800(PersistentUnitCache.java:96)
at com.google.gwt.dev.javac.PersistentUnitCache$4.run(PersistentUnitCache.java:222)
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)
... 1 more
Caused by: java.io.StreamCorruptedException: unexpected EOF in middle of data block
at java.io.ObjectInputStream$BlockDataInputStream.refill(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.read(Unknown Source)
at java.io.ObjectInputStream.read(Unknown Source)
at java.io.InputStream.read(Unknown Source)
at com.google.gwt.dev.util.DiskCache.transferFromStream(DiskCache.java:159)
... 27 more
I dont know what i did, i tried removing the war folder and put it back and suddenly it worked ....no idea :/

setAssociatedAction() and setAssociatedScreen() not working

I'm developing some custom screens and custom actions and would like to create associations between them in much the same way that adding a "Create program group" screen suggests adding a "Create program group" action.
So I have a screen, and would like to associate an action with it. The action should be placed on the Installation screen. Within the screens bean info class, I've added the following line to the constructor:
setAssociatedAction(MyAction.class.getName(), InstallationScreen.class.getName());
This doesn't seem to do anything. I recompile, and re-add the screen to the installer, but it doesn't prompt me to add the action. I tried adding the same settings to the action's constructor, thinking that perhaps both need to create an association with each other to work:
setAssociatedScreen(MyScreen.class.getName());
setInstallerTargetScreen(InstallationScreen.class.getName());
It didn't help either. I even tried doing the reverse by creating the action to see if it requests that the screen be created as well, but no luck there. Luckily, setting the installer target screen worked as expected.
I've tried the following as well:
Simple and canonical names for the class name.
The bean info classes, just incase.
I'm not sure what I'm doing wrong, if I am doing anything wrong. The documentation doesn't elude to any additional dependencies:
ScreenBeanInfo
ActionBeanInfo
Hopefully this isn't a bug.
Thanks in advance!
EDIT:
I was about to resolve this, but only as an extension to install4j. I used the wrong class when specifying the Bean class in the BeanInfo.
I had:
public MyActionBeanInfo() {
super("Title", "Description", "Category", false, true, null, MyActionBeanInfo.class);
}
Instead of:
public MyActionBeanInfo() {
super("Title", "Description", "Category", false, true, null, MyAction.class);
}
As a small enhancement, would it be possible to throw an exception, perhaps an IllegalArgumentException, from the super constructor if it is not a valid Bean class?
BUT!
I still received a ClassNotFound and NullPointer exception when not used as an extension.
Here's the stack trace:
java.lang.ClassNotFoundException: com.geowareinc.util.installer.actions.MyAction
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 java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.install4j.gui.views.installer.d.g.a(ejt:92)
at com.install4j.gui.views.installer.i.b.a(ejt:41)
at com.install4j.gui.views.installer.i.b.a(ejt:31)
at com.install4j.gui.views.installer.i.b.a(ejt:18)
at com.install4j.gui.views.installer.d.h.a(ejt:34)
at com.install4j.gui.views.installer.d.h.call(ejt:32)
at com.install4j.gui.views.installer.d.ax.a(ejt:1238)
at com.install4j.gui.views.installer.d.g.a(ejt:32)
at com.install4j.gui.views.installer.b.h.a(ejt:388)
at com.install4j.gui.views.installer.d.ax.f(ejt:691)
at com.install4j.gui.views.installer.d.bd.actionPerformed(ejt:540)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(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)
java.lang.NullPointerException
at sun.reflect.misc.ReflectUtil.checkPackageAccess(Unknown Source)
at sun.reflect.misc.ReflectUtil.isPackageAccessible(Unknown Source)
at java.beans.Introspector.getBeanInfo(Unknown Source)
at com.install4j.gui.views.installer.d.g.b(ejt:60)
at com.install4j.gui.views.installer.i.b.a(ejt:73)
at com.install4j.gui.views.installer.i.b.a(ejt:53)
at com.install4j.gui.views.installer.i.b.a(ejt:31)
at com.install4j.gui.views.installer.i.b.a(ejt:18)
at com.install4j.gui.views.installer.d.h.a(ejt:34)
at com.install4j.gui.views.installer.d.h.call(ejt:32)
at com.install4j.gui.views.installer.d.ax.a(ejt:1238)
at com.install4j.gui.views.installer.d.g.a(ejt:32)
at com.install4j.gui.views.installer.b.h.a(ejt:388)
at com.install4j.gui.views.installer.d.ax.f(ejt:691)
at com.install4j.gui.views.installer.d.bd.actionPerformed(ejt:540)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(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)
This is a bug in install4j. Associated screens and actions cannot be loaded if the bean is added on the Installer->Custom code & Resources tab.
This will be fixed in 5.1.7.

Spark with Cassandra: Failed to register spark.kryo.registrator

Currently I encounter some problems when I try to run Spark with Cassandra on standalone mode.
Initially, I run successfully with parameter mater="local[4]" in SparkContext.
Then, I try to move to standalone mode. What I used are:
Ubuntu: 12.04
Cassandra: 1.2.11
Spark: 0.8.0
Scala: 2.9.3
JDK: Oracle 1.6.0_35
Kryo: 2.21
At first, I got "unread block" error. As suggestion in other topic I change to use Kryo serializer and add Twitter Chill. Then, I get the " Failed to register spark.kryo.registrator " in my console and the Exception as below:
13/10/28 12:12:36 INFO cluster.ClusterTaskSetManager: Lost TID 0 (task 0.0:0)
13/10/28 12:12:36 INFO cluster.ClusterTaskSetManager: Loss was due to java.io.EOFException
java.io.EOFException
at org.apache.spark.serializer.KryoDeserializationStream.readObject(KryoSerializer.scala:109)
at org.apache.spark.broadcast.HttpBroadcast$.read(HttpBroadcast.scala:150)
at org.apache.spark.broadcast.HttpBroadcast.readObject(HttpBroadcast.scala:56)
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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at scala.collection.immutable.$colon$colon.readObject(List.scala:435)
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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.apache.spark.serializer.JavaDeserializationStream.readObject(JavaSerializer.scala:39)
at org.apache.spark.scheduler.ResultTask$.deserializeInfo(ResultTask.scala:61)
at org.apache.spark.scheduler.ResultTask.readExternal(ResultTask.scala:129)
at java.io.ObjectInputStream.readExternalData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.apache.spark.serializer.JavaDeserializationStream.readObject(JavaSerializer.scala:39)
at org.apache.spark.serializer.JavaSerializerInstance.deserialize(JavaSerializer.scala:61)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:153)
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)
Someone also encountered the EOFException in spark before, the answer is not register the registrator correctly. I register the Registrator following the Spark guide. Registrator as below:
class MyRegistrator extends KryoRegistrator {
override def registerClasses(kryo: Kryo) {
kryo.register(classOf[org.apache.spark.rdd.RDD[(Map[String, ByteBuffer], Map[String, ByteBuffer])]])
kryo.register(classOf[String], 1)
kryo.register(classOf[Map[String, ByteBuffer]], 2)
}
}
And I also set the property just as the guide does.
System.setProperty("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
System.setProperty("spark.kryo.registrator", "main.scala.MyRegistrator")
Can anyone give me some hints where I did wrong?
Thanks.
Based on my experience, the reasons to get the "EOFException" and the "data unread block" are the same. They lack some libraries when running on the clusters. The most wired thing is that I have add the libraries with "sbt assembly" in spark and the libraries are actually existing in the jars folder. But the spark still cannot find and load them successfully. Then I add the libraries in the spark context, it works. That means I need to transport the libraries to each nodes by specifying in the code.

Weka Class Invalid for Deserialization

I trained a SimpleKMeans clusterer in Weka Explorer and saved the model to my computer. Now I want to use it in my Java code to cluster an instance I create but I get the following error when I try to deserialize it:
java.io.InvalidClassException: weka.core.Instance; weka.core.Instance;
class invalid for deserialization at
java.io.ObjectStreamClass.checkDeserialize(Unknown Source) at
java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at
java.io.ObjectInputStream.readObject0(Unknown Source) at
java.io.ObjectInputStream.readArray(Unknown Source) at
java.io.ObjectInputStream.readObject0(Unknown Source) at
java.io.ObjectInputStream.defaultReadFields(Unknown Source) at
java.io.ObjectInputStream.readSerialData(Unknown Source) at
java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at
java.io.ObjectInputStream.readObject0(Unknown Source) at
java.io.ObjectInputStream.defaultReadFields(Unknown Source) at
java.io.ObjectInputStream.readSerialData(Unknown Source) at
java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at
java.io.ObjectInputStream.readObject0(Unknown Source) at
java.io.ObjectInputStream.defaultReadFields(Unknown Source) at
java.io.ObjectInputStream.readSerialData(Unknown Source) at
java.io.ObjectInputStream.readOrdinaryObject(Unknown Source) at
java.io.ObjectInputStream.readObject0(Unknown Source) at
java.io.ObjectInputStream.readObject(Unknown Source) at
weka.core.SerializationHelper.read(SerializationHelper.java:288) at
weka.core.SerializationHelper.read(SerializationHelper.java:270) at
Test.main(Test.java:32)
where line 32 of my Test class is
Clusterer kmeans_temp = (Clusterer) weka.core.SerializationHelper.read("path/to/model/myclusterermodel.model");
Am I doing it right?
The problem was because I was using two different versions of WEKA to create the model and deserialize the model. I downloaded the source code for the version I used for WEKA explorer and problem solved.