Protege-OWL: java.lang.NoClassDefFoundError - java

Im trying to run code use protege-owl. So I added the protege.jar and protege-owl.jar to library to import edu.stanford.smi.protegex.owl.* and edu.stanford.smi.protege.*.
I also added jena jar files to use in next steps.
First i wrote simple code to see how it works :
import java.lang.Object;
import edu.stanford.smi.protege.*;
import edu.stanford.smi.protegex.owl.*;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
JenaOWLModel model=ProtegeOWL.createJenaOWLModel();
OWLNamedClass c= model.createOWLNamedClass("A");
System.out.print(c.getName());
}
}
But it gives me this error :
CONFIG: Protege 3.0 Build 141, JVM 1.6.0_20-b02, memory=259M, Windows 7, encoding=UTF-8, language=fa, country=IR
WARNING: Look and feel not found: com.jgoodies.plaf.plastic.PlasticLookAndFeel -- SystemUtilities.loadLookAndFeel()
WARNING: Plugins directory not found: C:\Users\mona\Documents\NetBeansProjects\JavaApplication3\plugins -- PluginUtilities.getPluginsDir()
WARNING: Exception Caught -- java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at edu.stanford.smi.protege.plugin.PluginUtilities.isLoadableClass(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.checkPlugin(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.checkPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.processManifest(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadPluginsWithClassLoader(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.createClassLoaderAndLoadPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadSystemPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.loadPlugins(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.init(Unknown Source)
at edu.stanford.smi.protege.plugin.PluginUtilities.<clinit>(Unknown Source)
at edu.stanford.smi.protege.util.SystemUtilities.init(Unknown Source)
at edu.stanford.smi.protege.util.SystemUtilities.<clinit>(Unknown Source)
at edu.stanford.smi.protege.model.Project.<clinit>(Unknown Source)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModel(ProtegeOWL.java:32)
at javaapplication3.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: com.toedter.calendar.JDateChooser
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method) . . . .
What can I do ?
Update:
I replace protege.jar with protege-3.5.jar and now it gives :
Exception in thread "main" java.lang.NoSuchMethodError: edu.stanford.smi.protege.model.SystemFrames.replaceFrame(Ledu/stanford/smi/protege/model/Frame;)V
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.createSystemFrames(AbstractOWLModel.java:544)
at edu.stanford.smi.protege.model.DefaultKnowledgeBase.<init>(DefaultKnowledgeBase.java:79)
at edu.stanford.smi.protegex.owl.model.impl.AbstractOWLModel.<init>(AbstractOWLModel.java:318)
at edu.stanford.smi.protegex.owl.jena.JenaOWLModel.<init>(JenaOWLModel.java:62)
at edu.stanford.smi.protegex.owl.jena.JenaKnowledgeBaseFactory.createKnowledgeBase(JenaKnowledgeBaseFactory.java:55)
at edu.stanford.smi.protege.model.Project.createDomainKB(Project.java:429)
at edu.stanford.smi.protege.model.Project.createDomainKnowledgeBase(Project.java:447)
at edu.stanford.smi.protege.model.Project.<init>(Project.java:359)
at edu.stanford.smi.protege.model.Project.<init>(Project.java:341)
at edu.stanford.smi.protege.model.Project.createNewProject(Project.java:545)
at edu.stanford.smi.protegex.owl.ProtegeOWL.createJenaOWLModel(ProtegeOWL.java:32)
at javaapplication3.Main.main(Main.java:24)
Java Result: 1
Where is the problem?

I downloaded protege-owl.jar which is 3.24MB from different link and now it works.

Related

Lambda stack trace missing when using NativeMethodAccessor instead of GeneratedMethodAccessor

A couple days ago, I got a support ticket for this NullPointerException:
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.redacted.SalesResponsePagination com.redacted.StatisticsService.findSalesData(com.redacted.ConfStats) throws com.redacted.AsyncException' threw an unexpected exception: java.lang.NullPointerException
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
at ... (typical GWT + Tomcat stacktrace)
Caused by: java.lang.NullPointerException
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.util.concurrent.ForkJoinTask.getThrowableException(Unknown Source)
at java.util.concurrent.ForkJoinTask.reportException(Unknown Source)
at java.util.concurrent.ForkJoinTask.invoke(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.forEach(Unknown Source)
at com.redacted.StatisticsControllerImpl.replacePrices(StatisticsControllerImpl.java:310)
at com.redacted.StatisticsControllerImpl.findSalesData(StatisticsControllerImpl.java:288)
at com.redacted.StatisticsServiceImpl.findSalesData(StatisticsServiceImpl.java:83)
at sun.reflect.GeneratedMethodAccessor752.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 33 more
Caused by: java.lang.NullPointerException
at com.redacted.StatisticsControllerImpl.lambda$replacePrices$27(StatisticsControllerImpl.java:317)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(Unknown Source)
at ... (typical stream.forEach stacktrace)
Now, this was an easy one because the exact line number for the NPE was in plain sight; all I had to do was go to StatisticsControllerImpl.java:317:
salesResponsePagination.getSalesResponses().parallelStream()
.peek(sr -> /*...*/)
.filter(sr -> /*...*/)
/*310*/ .forEach(sr -> {
final List<CartElement> sentCEs = DaoService.getCartElementDAO().getSentCEs(/*...*/);
if (sentCEs != null && !sentCEs.isEmpty() && sentCEs.get(0) != null) {
final CartElement ce = sentCEs.get(0);
// some more non-NPE lines...
/*317*/ if (sr.getCurrency().equals(ce.getPurchaseCurrency()) && sr.getPrice().equals(ce.getPurchasePrice().intValue()) && !ce.getCurrency().equals(ce.getPurchaseCurrency())) {
// Some currency exchanging
}
// Etcetera (about 12 lines more)
});
And replace the .equals() calls with Object.equals() to avoid the NPE (investigating the reasons why some sales were registered with a NULL price or currency came later). Test, commit, push, send ticket to QA.
However, the next day QA returned the ticket saying that the NPE persisted, and they included a new, almost similar stack trace:
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.redacted.SalesResponsePagination com.redacted.StatisticsService.findSalesData(com.redacted.ConfStats) throws com.redacted.AsyncException' threw an unexpected exception: java.lang.NullPointerException
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579)
at ... (typical GWT + Tomcat stacktrace)
Caused by: java.lang.NullPointerException
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.util.concurrent.ForkJoinTask.getThrowableException(Unknown Source)
at java.util.concurrent.ForkJoinTask.reportException(Unknown Source)
at java.util.concurrent.ForkJoinTask.invoke(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.forEach(Unknown Source)
at com.redacted.StatisticsControllerImpl.replacePrices(StatisticsControllerImpl.java:310)
at com.redacted.StatisticsControllerImpl.findSalesData(StatisticsControllerImpl.java:288)
at com.redacted.StatisticsServiceImpl.findSalesData(StatisticsServiceImpl.java:83)
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.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561)
... 33 more
Caused by: java.lang.NullPointerException
This stack trace was exactly the same as the previous one, except for two things:
This call was using NativeMethodAccessorImpl instead of GeneratedMethodAccessor752. Compare:
at com.redacted.StatisticsServiceImpl.findSalesData(StatisticsServiceImpl.java:83)
at sun.reflect.GeneratedMethodAccessor752.invoke(Unknown Source)
vs
at com.redacted.StatisticsServiceImpl.findSalesData(StatisticsServiceImpl.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
This one was missing the stack trace for the lambda. The line where the NPE happened was missing.
This threw me off initially. Why was the last part of the stack trace missing? I asked QA to re-test and re-attach the stack trace a couple times, until I got a complete one; however, the complete one I got in the end was based on GeneratedMethodAccesor once again.
Now, if I understand correctly, sun.reflect.NativeMethodAccessorImpl is used for the first invocations of a method, until JIT has enough info to generate an optimized accesor for that method in the form of sun.reflect.GeneratedMethodAccessorNNN.
What I don't understand is: if Native is using my code and Generated is using JIT's generated code, shouldn't Native show more info about my code, not less?
So my question is:
Why do lambda runtime exceptions thrown inside sun.reflect.NativeMethodAccessorImpl seem to be missing the lambda's stack trace?
Can this be a bug in JDK's source code? Especially when the very same exception thrown inside sun.reflect.GeneratedMethodAccessor includes the lambda stack trace without problem.
The following code manages to get a stack trace similar to the first one. I can force the use of NativeMethodAccessor or GeneratedMethodAccesor by running it with a sufficiently low or high first parameter, respectively (i.e. java test.Main 1 or java test.Main 30).
However, the lambda part of it is always present, whether using Native or Generated.
package test;
import java.lang.reflect.Method;
import java.util.stream.IntStream;
class MyOtherClass {
public void methodWithLambda(boolean fail) {
IntStream.range(0, 1000).parallel().forEach(k -> {
if (fail && k % 500 == 0)
throw new NullPointerException();
});
}
public String methodProxy(boolean fail) {
methodWithLambda(fail);
return "OK";
}
}
class MyClass {
public String methodReflected(Boolean fail) {
return new MyOtherClass().methodProxy(fail);
}
}
class Main {
public static void main(String[] args) throws Exception {
Class<MyClass> clazz = MyClass.class;
Object instance = clazz.newInstance();
Method method = clazz.getMethod("methodReflected", Boolean.class);
int reps = args.length >= 1 ? Integer.valueOf(args[0]) : 20;
for (; reps --> 0;) {
// Several non-failing calls to force creation of GeneratedMethodAccesor
System.out.println((String) method.invoke(instance, false));
}
// Failing call
System.out.println((String) method.invoke(instance, true));
}
}
Stack trace for the above code when using NativeMethodAccesor:
Exception in thread "main" 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 test.Main.main(Main.java:36)
Caused by: java.lang.NullPointerException
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.util.concurrent.ForkJoinTask.getThrowableException(Unknown Source)
at java.util.concurrent.ForkJoinTask.reportException(Unknown Source)
at java.util.concurrent.ForkJoinTask.invoke(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(Unknown Source)
at java.util.stream.ForEachOps$ForEachOp$OfInt.evaluateParallel(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.IntPipeline.forEach(Unknown Source)
at java.util.stream.IntPipeline$Head.forEach(Unknown Source)
at test.MyOtherClass.methodWithLambda(Main.java:8)
at test.MyOtherClass.methodProxy(Main.java:14)
at test.MyClass.methodReflected(Main.java:21)
... 5 more
Caused by: java.lang.NullPointerException
at test.MyOtherClass.lambda$methodWithLambda$0(Main.java:10)
at java.util.stream.ForEachOps$ForEachOp$OfInt.accept(Unknown Source)
at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Unknown Source)
at java.util.Spliterator$OfInt.forEachRemaining(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.ForEachOps$ForEachTask.compute(Unknown Source)
at java.util.concurrent.CountedCompleter.exec(Unknown Source)
at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
at java.util.concurrent.ForkJoinPool$WorkQueue.execLocalTasks(Unknown Source)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
EDIT: Just to be clear: I am not looking for ways to fix this NPE, nor ways to force the lambda's stack trace to print. What I want to know is the reason why the above happens: different implementations? A bug? Something to do with forEach()?
This might be an issue of JDK-6678999, “Stacktrace missing after null string comparisons”:
After comparing a string to null and catching the exception and repeating the operation, JVM starts throwing "stackless" NullPointerException (it occurs after 9000 loops but this is variable)
The evaluation of the issue is
When the server compiler compiles a method, the stack trace in an exception thrown
by that method may be omitted for performance purposes.
[…] If the user always wants stack traces, use the -XX:-OmitStackTraceInFastThrow option to the VM.
So, the option -XX:-OmitStackTraceInFastThrow may solve the issue.
Note that the bug report was against Java 6, but since it has been closed as “Won't Fix”, it may still be relevant, though you would have to replace “server compiler” with “c2 compiler” in the explanation now.
The use of NativeMethodAccessorImpl or GeneratedMethodAccessor… is not relevant to this issue, except that both have a common cause; a higher number of executions may trigger the optimizations.

"Prohibited package name: java.util" on Class.forName("java.util...") in applet

I have an applet that references 2 signed jars:
myapplet.jar
jackson-all-1.9.9.jar
When starting the applet the second time (first time is without errors), I get this:
Exception in thread "thread applet-main.MyApplet-1"
java.lang.ExceptionInInitializerError
at org.codehaus.jackson.map.deser.StdDeserializerProvider.<init>(StdDeserializerProvider.java:81)
at org.codehaus.jackson.map.ObjectMapper.<init>(ObjectMapper.java:398)
at org.codehaus.jackson.map.ObjectMapper.<init>(ObjectMapper.java:358)
at org.codehaus.jackson.map.ObjectMapper.<init>(ObjectMapper.java:328)
at net.Remote.<init>(Remote.java:50)
at main.Env.init(Env.java:44)
at main.MyApplet.init(MyApplet.java:25)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.SecurityException: Prohibited package name: java.util
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.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 org.codehaus.jackson.map.deser.BasicDeserializerFactory.<clinit>(BasicDeserializerFactory.java:74)
... 9 more
The line in question is the first one in the following try-catch block:
try {
Class<?> key = Class.forName("java.util.ConcurrentNavigableMap");
Class<?> value = Class.forName("java.util.ConcurrentSkipListMap");
#SuppressWarnings("unchecked")
Class<? extends Map<?,?>> mapValue = (Class<? extends Map<?,?>>) value;
_mapFallbacks.put(key.getName(), mapValue);
} catch (ClassNotFoundException cnfe) { // occurs on 1.5
}
A couple of things I do not understand:
Why does my Java7 JVM not take it out of its runtime library? But rather
Why does it try to download /java/util/ConcurrentNavigableMap.class from my server, which obviously fails with a 404?
As that fails, why does it try to re-download myapplet.jar 25 times in rapid succession, each time successfully (200), and each time returning the same jar file?
Update I'm not sure whether the 25 retries are caused by the class loader trying to load the class, it might be some other code trying to load a resource (which would still be odd, but not related to the CurrentNavigableMap issue), so I'll exclude that from my question.
N.B. I guess it does not try to re-download the jackson jar file, as that one is listed in the cache_archive attribute.
Is this?
wrong:
Class.forName("java.util.ConcurrentNavigableMap");
Correct:
http://java.sun.com/javase/ja/6/docs/ja/api/java/util/concurrent/package-tree.html
Class.forName("java.util.concurrent.ConcurrentNavigableMap");

java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64 when trying to create CommonsHttpOAuthConsumer

EDIT:
public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
System.out.println("debug1");
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer("key","secret");
System.out.println("debug2");
...}
hi when i try to run this script i get this response:
debug1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at oauth.signpost.signature.OAuthMessageSigner.<init>(OAuthMessageSigner.java:37)
at oauth.signpost.signature.HmacSha1MessageSigner.<init>(HmacSha1MessageSigner.java:30)
at oauth.signpost.AbstractOAuthConsumer.<init>(AbstractOAuthConsumer.java:65)
at oauth.signpost.commonshttp.CommonsHttpOAuthConsumer.<init>(CommonsHttpOAuthConsumer.java:30)
at mein.tester.main(tester.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
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.ClassLoader.loadClassInternal(Unknown Source)
... 5 more
Line 21 is the line before
System.out.println("debug2");
Well i can easily compile the code in eclipse and i added 2 Signpost librabrys and also common-codec.jar as external library as i read in another post.. however, how do i make it available on runtime?(i did like in the post "add it to WEB-INF/lib " -> i created that folder and added the jar
-i also tryed the defaultoauthconsumer -> same error
Right click on the jar and choose "add to build path"? I don't think the ide will automatically add it to your classpath unless you tell it to.

How to call a sighned Applet which returns a value from GWT on button click

I am trying to call an sighned applet on by GWT button click. I tried going through the gwtai method of creating an interface on client side then writing an Applet which implements the interface.Howevere I get a TargetInvokationException when I call the method on my onClick() event.
Here is the code I wrote :
screenCap.addListener(new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
String filePath = counterApplet.captureScreenShot(); (Throws exception here)
TextField filePathT = new TextField();
My Applet Interface :
import com.google.gwt.gwtai.applet.client.*;
#ImplementingClass(com.jpmorgan.rd.querymanager.applet.imageCaptureAppletImpl.class)
#Height("10")
#Width("10")
#Archive("GwtAI-Client.jar,GwtAI-Demo.jar")
public interface imageCaptureApplet extends Applet {
String captureScreenShot();
}
My applet implementation class :
import java.awt.*;
import javax.swing.JApplet;
public class imageCaptureAppletImpl extends JApplet implements imageCaptureApplet{
private static final long serialVersionUID = -511774647966368672L;
public String captureScreenShot() {
String file;
// do something
return file;
}
And the full stack trace:
load: class com.amol.test.imageCaptureAppletImpl.class not found.
java.lang.ClassNotFoundException: com.jpmorgan.rd.querymanager.server.imageCaptureAppletImpl.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://127.0.0.1:8888/com/amol/test/imageCaptureAppletImpl/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 9 more
Exception: java.lang.ClassNotFoundException: com.amol.test.imageCaptureAppletImpl.class
Any help around this is Appreciated.
I have also created a signed jar of my applet can you please suggest if there is a better way of calling this captureScreenShot() method from my GWT page on button click and getting a result back.
Also is JSNI a better way of doing this. If so can you show a example where a applet which passes a value back is called.
Many thanks in advanced.
PS: I used this page for the basis of my code on gwtai :
http://code.google.com/p/gwtai/wiki/GettingStarted
Thanks,
Amol
GwtAI is using JSNI to communicate with the applet. So whether you are writing the JSNI code yourself or using this library will be the same. Can you post the full stacktrace of your error?

JApplet loading problem

I want to convert an java application to applet, but I an having problems to load it in the browser I presume this is because of the package.
package com.applet;
import java.applet.Applet;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
//import javax.swing.JOptionPane;
#SuppressWarnings("serial")
public class AppletDriver extends Applet {
//Called when this applet is loaded into the browser.
public void init() {
//Execute a job on the event-dispatching thread; creating this applet's GUI.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
CleanerPanel cFrame = new CleanerPanel();
add(cFrame);
}
});
} catch (Exception e) {
System.err.println("createGUI didn't complete successfully");
}
}
}
this is the code I am using to call the applet when I run it in Eclipse it is working.
this is the html code:
<applet archive="app.jar" code="bin/com/applet/AppletDriver.class" width=350 height=200>
</applet>
the app.jar is in the main dir of the eclipse project any suggestions ?
error from browser java console:
java.lang.NoClassDefFoundError: bin/com/applet/AppletDriver (wrong name: com/applet/AppletDriver)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NoClassDefFoundError: bin/com/applet/AppletDriver (wrong name: com/applet/AppletDriver)
Remove the bin\ from the start of the code attribute value, and use / instead of \ (we're not in Washington anymore). If the jar is in a directory named bin then you'll need to use archive="bin/app.jar".
Actually looking at the stack trace, the jar has been constructed incorrectly. The class file should be in a directory com/applet, not bin/com/applet.

Categories