We are trying to extend the UISpec4j testing framework to display the user interface when running tests. So we have a custom toolkit that wraps around the native toolkit for the relevant platform. We managed to get everything working well on windows XP, however when testing our changes on OSX, our extension of createFrame appears to behave oddly:
public FramePeer createFrame(Frame target) {
FramePeer resultc = new UISpecFramePeer(target);
//super.createFrame(target);
return resultc;
}
Essentially with the above, we want to create a UISpecFramePeer as an interception class... So that UISpec4j can interrogate what is happening within the UI. But in our changes, we also want to display the UI. So we attempt this by creating a frame using the native toolkit and wrapping it in the UISpecFramePeer (not shown in the code above).
When we run the above code, the tests run (as we expect) but obviously nothing is displayed. However, when we include super.createFrame(target). We get the following exception:
SEVERE: Application class org.openshapa.OpenSHAPA failed to launch
java.lang.ClassCastException: org.uispec4j.interception.toolkit.UISpecFramePeer
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:236)
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:233)
at apple.awt.ClientPropertyApplicator.attachAndApplyClientProperties(ClientPropertyApplicator.java:24)
at apple.awt.CWindow$1.propertyChange(CWindow.java:190)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:341)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at java.awt.Component.firePropertyChange(Component.java:7277)
at javax.swing.JComponent.addNotify(JComponent.java:4479)
at javax.swing.JRootPane.addNotify(JRootPane.java:680)
at java.awt.Container.addNotify(Container.java:2544)
at java.awt.Window.addNotify(Window.java:467)
at java.awt.Frame.addNotify(Frame.java:501)
at java.awt.Window.pack(Window.java:485)
at org.jdesktop.application.SingleFrameApplication.initRootPaneContainer(SingleFrameApplication.java:216)
at org.jdesktop.application.SingleFrameApplication.show(SingleFrameApplication.java:463)
at org.openshapa.OpenSHAPA.startup(OpenSHAPA.java:444)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-2" java.lang.Error: Application class org.openshapa.OpenSHAPA failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.ClassCastException: org.uispec4j.interception.toolkit.UISpecFramePeer
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:236)
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:233)
at apple.awt.ClientPropertyApplicator.attachAndApplyClientProperties(ClientPropertyApplicator.java:24)
at apple.awt.CWindow$1.propertyChange(CWindow.java:190)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:341)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at java.awt.Component.firePropertyChange(Component.java:7277)
at javax.swing.JComponent.addNotify(JComponent.java:4479)
at javax.swing.JRootPane.addNotify(JRootPane.java:680)
at java.awt.Container.addNotify(Container.java:2544)
at java.awt.Window.addNotify(Window.java:467)
at java.awt.Frame.addNotify(Frame.java:501)
at java.awt.Window.pack(Window.java:485)
at org.jdesktop.application.SingleFrameApplication.initRootPaneContainer(SingleFrameApplication.java:216)
at org.jdesktop.application.SingleFrameApplication.show(SingleFrameApplication.java:463)
at org.openshapa.OpenSHAPA.startup(OpenSHAPA.java:444)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 7 more
Why would simply using the native toolkit to create a frame (but not return it) create an exception, when it would otherwise behaves as normal when the super.createFrame is commented?
I havent worked on OSX, but the same problem would occur on Windows too and the reason would be this:
When you do super.createFrame(), you are essentially creating the native peer which ends up trying to show and hence addNotify methods are called. Now inside there are lot of methods that directly cast the peer to WFramePeer(this is incase of Windows, OSX it may be CWindowPeer or whatever), hence the ClassCastException. In your case, my guess is, the class CWindow is trying to cast your UISpecFramePeer to WFramePeer(or CFramePeer or whatever). Just check the CWindow code by decompiling and check. Please don't forget to post your findings.
Related
I am trying to load with java reflection a bunch of classes. Everything seems working fine (I am handling the exception if the class is not found).
However there is a particular class that is raising another exception that is not thrown by call to the Class.forname() but by an internal method and so I cannot even catch it.
Here is my code:
try {
URL url = Class.forName(qualifiednameOfTheClass);
} catch (ClassNotFoundException ex) {
// ok class not found can be handled
} catch (Exception e){
// catch every other exception just to try to get the strange exception
}
So with this code everything is working, I am using it on lots of classes and it's working (sometimes it finds it sometimes it doesn't).
However there is one case that is not working properly and I cannot understand why. If qualifiednameOfTheClass = sun.security.krb5.SCDynamicStoreConfig my code is raising an exception:
Exception in thread "mythread-1" java.lang.UnsatisfiedLinkError: no
osx in java.library.path at
java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886) at
java.lang.Runtime.loadLibrary0(Runtime.java:849) at
java.lang.System.loadLibrary(System.java:1088) at
sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
at
sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
at java.security.AccessController.doPrivileged(Native Method) at
sun.security.krb5.SCDynamicStoreConfig.(SCDynamicStoreConfig.java:39)
at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:190) at
com.myclass.getJARFromClassForName(JavaId.java:510)
at com.myclass.getJARUrl(Id.java:550) at
com.myclass.collectInformation(Graph.java:366)
at
com.myclass.createNode(Graph.java:166)
at com.myclass.Graph.(Graph.java:143) at
com.myclass2.run(myclass2.java:246)
at java.lang.Thread.run(Thread.java:745)
So as you can see in the error we have this strange exception that cannot be caught even with a generic catch like in my code and I cannot understand why it has been raised and what actually is this osx library (I am on linux)
EDIT: The only thing that I found is this link http://www.straub.as/java/pocketapi/index7.html but is in german and so I read it with google translate and I don't know if I got it right but is saying that the classes listed there cannot be reproduced with Class.forname() itself.
Is it true? Is there a reason why this cannot be loaded with reflection or am I doing something wrong?
"Cannot be caught" because it's an Error, not an Exception. I'd recommend reviewing the object hierarchy in the JDK for Throwable.
Try changing that to Throwable and you'll have better luck catching. I don't know why the error is happening.
This looks like a JNI class that's using native code. I don't know what you're doing, but this looks like a bad idea to me.
This is not how this class expects to be loaded and loading this internal class directly doesn't appear to work. You need to load the class using the standard encryption API so that this class can be loaded as expected, or possibly not loaded at all (it could be code which will only work on OSX)
As you can see in the link you have provided, there are some classes where this method fails.
When calling this method on these objects, Java needs first to load additional stuff, as this is platform specific stuff which is not shipped by default. In your case, it is Kerberos, a security API.
As you can see in its Documentation, it searches for some files in specific paths (java.library.path). As it can not find it there, it throws an error.
Note that the error UnsatisfiedLinkError does not refer to finding the class name for sun.security.krb5.SCDynamicStoreConfig itself. It refers to not finding the native library in the paths provided by java.library.path.
This path itself points, for example on Windows, to C:Windows/system32/.
However, you may catch this error with catch(Error e), note that an Error is not an Exception (Throwable hierarchy).
Be aware that catching an Error in general is no good idead as you can not be sure if the JVM can recover from it.
When calling
Observable.interval(10, TimeUnit.MILLISECONDS)
in my target environment (works great on standard JVM) I'm getting:
java.lang.IncompatibleClassChangeError: Class
rx.internal.util.RxThreadFactory does not implement the requested
interface java.util.concurrent.ThreadFactory at
java.util.concurrent.ThreadPoolExecutor$Worker.(ThreadPoolExecutor.java:610)
at
java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:924)
at
java.util.concurrent.ThreadPoolExecutor.ensurePrestart(ThreadPoolExecutor.java:1590)
at
java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:333)
at
java.util.concurrent.ScheduledThreadPoolExecutor.scheduleWithFixedDelay(ScheduledThreadPoolExecutor.java:594)
at
rx.schedulers.CachedThreadScheduler$CachedWorkerPool.(CachedThreadScheduler.java:62)
at
rx.schedulers.CachedThreadScheduler.start(CachedThreadScheduler.java:150)
at
rx.schedulers.CachedThreadScheduler.(CachedThreadScheduler.java:145)
at rx.schedulers.Schedulers.(Schedulers.java:48) at
rx.schedulers.Schedulers.(Schedulers.java:34) at
rx.Observable.interval(Observable.java:1293)
What does it mean? What can I do about it?
P.S.: I'm using proguard on final jar. Could it be the reason?
From looking at your error in the Java API it's a JVM runtime check thingy that checks if the classes dependable on the current executing method have been changed since last executed.
Just try stopping all processes executing (shut everything down). Save, clear cache and recompile everything and then try running it again so everything is on the same page.
I'm new to neural networks and NLP. I've found this library: DeepLearning4J. I'm trying to get it to work but whenever I execute this instruction:
Collection<String> similar = vec.wordsNearest("word_to_search", 10);
If the word I'm searching is mapped into the network I get the following exception:
java.lang.IllegalArgumentException: XERBLA: Error on argument 6 (LDA) in SGEMV
at org.jblas.NativeBlas.sgemv(Native Method)
at org.nd4j.linalg.jblas.blas.JblasLevel2.sgemv(JblasLevel2.java:25)
at org.nd4j.linalg.api.blas.impl.BaseLevel2.gemv(BaseLevel2.java:53)
at org.nd4j.linalg.api.ndarray.BaseNDArray.mmuli(BaseNDArray.java:2569)
at org.nd4j.linalg.api.ndarray.BaseNDArray.mmul(BaseNDArray.java:2377)
at org.deeplearning4j.models.embeddings.wordvectors.WordVectorsImpl.wordsNearest(WordVectorsImpl.java:290)
at org.deeplearning4j.models.embeddings.wordvectors.WordVectorsImpl.wordsNearest(WordVectorsImpl.java:337)
at word2vec.Word2VecTest.main(Word2VecTest.java:74)
Exception in thread "main" java.lang.NoSuchMethodError: org.nd4j.linalg.api.ndarray.INDArray.mean(I)Lorg/nd4j/linalg/api/ndarray/INDArray;
at org.deeplearning4j.models.embeddings.wordvectors.WordVectorsImpl.wordsNearest(WordVectorsImpl.java:283)
at word2vec.Word2VecTest.main(Word2VecTest.java:89)
I know that the NoSuchMethodError may be due to libraries different versions. In this specific case, this is probably caused by nd4j. I've checked the versions lots of time and this is what I'm importing at the moment:
akka-actor_2.11-2.4-M3.jar
akka-cluster_2.11-2.4-M3.jar
akka-remote_2.11-2.4-M3.jar
akka-slf4j_2.11-2.4-M3.jar
byte-buddy-0.6.15.jar
config-1.3.0.jar
deeplearning4j-core-0.0.3.3.4.alpha2.jar
deeplearning4j-nlp-0.0.3.3.4.alpha2.jar
deeplearning4j-scaleout-akka-0.0.3.3.4.alpha2.jar
deeplearning4j-ui-0.0.3.3.4.alpha2.jar
javassist-3.12.1.GA.jar
jblas-1.2.4.jar
jcublas-6.5.jar
lucene-analyzers-common-4.10.3.jar
lucene-core-4.10.3.jar
nd4j-api-0.4-rc3.4.jar
nd4j-bytebuddy-0.4-rc3.4.jar
nd4j-jblas-0.4-rc3.4.jar
nd4j-jcublas-common-0.4-rc3.4.jar
netty-3.10.4.Final.jar
protobuf-java-2.6.1.jar
reflections-0.9.10.jar
scala-library-2.12.0-M2.jar
selenium-server-standalone-2.47.1.jar
Can someone explain to me the problem?
The error is telling you that DeepLearning4J tried to call the method INDArray INDArray.mean(int value) but this method was not found.
Looking at nd4j 0.4-rc3.4 source code, you can see that the mean method actually takes a vararg int... as input. Since this is not int, the error is thrown.
This change was made by this commit when nd4j bumped version from 0.0.3.5.5.5 to 0.4-rc0.
As a result, you need to downgrade nd4j to version 0.0.3.5.5.5. With this downgrade, you will not have any more incompatibility since this is the actual version that DeepLearning4J is depending on. You can see that in the Maven dependencies of deeplearning4j-core-0.0.3.3.4.alpha2.
we are getting this error at the end of running application. I search in google buti don't know what cause this error and what this means. What to do and how to solve it?
i even don't know what raise this exception...
Exception breakpoint occurred at line 145 of EventDispatchThread.java.
java.lang.NullPointerException:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at oracle.jbo.uicli.jui.JUTableBinding$JUTableModel$2.run(JUTableBinding.java:1209)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Don't know what kind of searches you have performed on Google. I would suggest looking up each error (or rather each class where error occurs). Starting from the beginning as subsequent errors may be a due to error propagation. Two searches for EventDispatchThread and JUTableBinding.java may provide some insight at what went wrong.
http://www.docjar.org/docs/api/java/awt/EventDispatchThread.html
It seems that this class deals with AWT components ("takes events off the EventQueue and dispatches them to the appropriate AWT components")
For the JUTableBinding.java there are quite a few pages that say about NullPointerException
https://forums.oracle.com/forums/thread.jspa?threadID=515213
https://forums.oracle.com/forums/thread.jspa?threadID=2343921
https://kr.forums.oracle.com/forums/thread.jspa?threadID=503593
Some of them say that the problem may be with jdk version (seems 1.6 and above throw errors). I would assume that may be the case. Try to recompile using earlier versions of jdk and check whether error is still there. If it is not this then we will investigate further.
"I've looked into the code and found out that JUTableBinding.JUTableModel calls
mScrollUnit = control.getScrollableUnitIncrement(null,
SwingConstants.VERTICAL, 0);
(Line 947)
This was okay in Java 5, since JTable's getScrollableUnitIncrement just returned the row height."
"I changed the line to:
mScrollUnit = control.getScrollableUnitIncrement(
control.getVisibleRect(), SwingConstants.VERTICAL, 0);
and everything works fine on Java 6..."
Hope it helps.
i have these codes
UserAgentContext uAgent=new SimpleUserAgentContext();
DocumentBuilderImpl docBuild=new DocumentBuilderImpl(uAgent);
docBuild.parse(new InputSourceImpl("http://dic.amdz.com/"));
when i run , it gives me the following error:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface sun.font.FontManager, but class was expected
at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:210)
at org.lobobrowser.util.gui.FontFactory.createFont_Impl(FontFactory.java:180)
at org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:127)
at org.lobobrowser.util.gui.FontFactory.getFont(FontFactory.java:98)
at org.lobobrowser.html.style.StyleSheetRenderState.<clinit>(StyleSheetRenderState.java:43)
at org.lobobrowser.html.domimpl.NodeImpl.<clinit>(NodeImpl.java:39)
at org.lobobrowser.html.parser.DocumentBuilderImpl.createDocument(DocumentBuilderImpl.java:143)
at org.lobobrowser.html.parser.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:97)
at cobratest2.Cobratest2.main(Cobratest2.java:21)
then pointing me to the last line. so the question is, what to do?
The problem is at
org.lobobrowser.util.gui.FontFactory.createFont(FontFactory.java:210)
That class was compiled against an old version of the libraries in whichsun.font.FontManager was a class, but you are trying to run it with newer libraries in which it is now an interface. You will probably have to recompile all of the org.lobobrowser package against current libraries.
And BTW, the link What causes java.lang.IncompatibleClassChangeError? mentioned by e-zinc does contain all the information you need to have figured this out yourself.