java applet won't work - java

this is homework stuff, but the question is not much about coding. the task is to write a java applet to work on an m-grid server. i have the server running on apache. it has a few sample applets in .jar and .class form. the .class versions work; the .jar versions work on appletviewer, but they break if I submit them as a job to the server with this:
load: class examples/pixelcount/PixelCount.class not found.
java.lang.ClassNotFoundException: examples.pixelcount.PixelCount.class
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)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
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)
... 7 more
Exception: java.lang.ClassNotFoundException: examples.pixelcount.PixelCount.class
I'm not really sure where exactly is the problem in here, given that they work on appletviewer. any help would be appreciated..
EDIT:
don't know if I wrote it clearly. by ".class version" i refer to html file with this content:
<applet height="300" width="450" code="examples/pixelcount/PixelCount.class"></applet>
and ".jar" with this content:
<applet height="300" width="450" archive="PixelCount.jar" code="examples.pixelcount.PixelCount.class"></applet>
EDIT2:
the mentioned example jar file can be found here

It can't find the file PixelCount.class, its not in the directory examples/pixlecount that's why this error is happening.

The PixelCount class is not packaged in your jar I think.
And as the error is Caused by: java.net.ConnectException: Connection refused: connect it might be that it tried to obtain that class from the net somewhere, and the location does not match or a proxy is in between.
EDIT
You do have the archive someplace the m-server, whatever that may be, can find it? See the Java Applet Tag ref. docs. You may need something like
CODEBASE = codebaseURL
This OPTIONAL attribute specifies the base URL of the applet--the directory
that contains the applet's code. If this attribute is not specified, then the
document's URL is used.
The CODE is relative to the base URL of the document which holds the applet tag. If you want to override that you might need that CODEBASE parameter.

Don't include the .class extension in the code attribute.
examples.pixelcount.PixelCount is the name of the class.
examples.pixelcount.PixelCount.class is the name of the file that contains the class.
The code attribute should read
code="examples.pixelcount.PixelCount"

Related

Not able to create any portlet on Liferay 6.2 CE GA4 Offline without internet

I have created a fresh Liferay 6.2 CE GA4 using pre-downloaded SDK/Tomcat/LR Source. I have created server in eclipse and when I try to create portlet for the first time it try to download "gradle-2.2.1-bin.zip" from the internet.
I have downloaded same from gradle from "https://downloads.gradle.org/distributions/gradle-2.2.1-bin.zip" and placed it inside "liferay-plugins-sdk-6.2\tools\gradle\gradle\wrapper".
Still it shows the same error as below:
`Downloading https://services.gradle.org/distributions/gradle-2.2.1-bin.zip
Exception in thread "main" java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at org.gradle.wrapper.Download.downloadInternal(Download.java:56)
at org.gradle.wrapper.Download.download(Download.java:42)
at org.gradle.wrapper.Install$1.call(Install.java:57)
at org.gradle.wrapper.Install$1.call(Install.java:44)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:56)
`
Am I placing that zip on wrong directory or missing something else ?
From the error message, I'd say: Yes, it seems you put the file into the wrong directory. Which one is the correct one? I don't know. It'd be easiest to do your first build while connected to the internet. The download will just happen once (also, there might be more dependencies that need to be downloaded) and you can do your builds offline after that.
To resolve your problem, you need to:
1) Delete content on:
D:\Profiles\XXX.gradle\wrapper\dists\gradle-2.2.1-bin\88n1whbyjvxg3s40jzz5ur27
2) Download manually:
https://services.gradle.org/distributions/gradle-2.2.1-bin.zip
3) Put gradle-2.2.1-bin.zip on:
D:\Profiles\XXX.gradle\wrapper\dists\gradle-2.2.1-bin\88n1whbyjvxg3s40jzz5ur27

Eclipse IDE - Classnotfound exception even though path known. Why can Eclipse find the lib in one Project but not in the other?

I am collaborating on a Project and we have a problem integrating some code I produced and that works in my local tesintg implementation of the jAudio library but once we include the library in the project (we all use eclipse) the project doesnt build throuwing the classnotfound exception - even though the IDE (Eclipse) knows the library (I can use autocomplete) and the methods are resolved it keeps insisting that it cannot resolve the classes to a type:
https://www.dropbox.com/s/9tsa0xh1uq1kg8d/Screenshot%202014-01-18%2011.44.58.png "Example of Type not resolved"
What do you think might be the problem behind "I cant see you" problem ?
Stacktrace:
java.lang.ClassNotFoundException: eExtractor.AudioFeatures.AreaPolynomialApproximationConstantQMFCC
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 java.net.FactoryURLClassLoader.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 jAudioFeatureExtractor.ACE.XMLParsers.FeatureListHandler.endElement(FeatureListHandler.java:95)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endNamespaceScope(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at jAudioFeatureExtractor.ACE.XMLParsers.XMLDocumentParser.parseXMLDocument(XMLDocumentParser.java:97)
at jAudioFeatureExtractor.DataModel.<init>(DataModel.java:173)
at org.tuhh.cpmgg.weka.JAudioCommandLine.execute(JAudioCommandLine.java:47)
at org.tuhh.cpmgg.weka.AudioClassifierWithJAudio.privjanalyse(AudioClassifierWithJAudio.java:365)
at org.tuhh.cpmgg.weka.AudioClassifierWithJAudio.classifyAudioFile(AudioClassifierWithJAudio.java:223)
at org.tuhh.cpmgg.weka.AudioClassifierWithJAudio.main(AudioClassifierWithJAudio.java:57)
java.lang.Exception: The src\main\java\org\tuhh\cpmgg\weka\features.xml file must be of type feature_list. <ClassNotFoundException> Class 'eExtractor.AudioFeatures.AreaPolynomialApproximationConstantQMFCC' does not exist in the path.
at jAudioFeatureExtractor.ACE.XMLParsers.XMLDocumentParser.parseXMLDocument(XMLDocumentParser.java:105)
at jAudioFeatureExtractor.DataModel.<init>(DataModel.java:173)
at org.tuhh.cpmgg.weka.JAudioCommandLine.execute(JAudioCommandLine.java:47)
at org.tuhh.cpmgg.weka.AudioClassifierWithJAudio.privjanalyse(AudioClassifierWithJAudio.java:365)
at org.tuhh.cpmgg.weka.AudioClassifierWithJAudio.classifyAudioFile(AudioClassifierWithJAudio.java:223)
at org.tuhh.cpmgg.weka.AudioClassifierWithJAudio.main(AudioClassifierWithJAudio.java:57)
Go to your project and right click ----> Build path ----> configure buildpath and add that jar into your project.
just try this one.
Already you completed the Buildpath, restart the eclipse once. I think your problem will be solved.

Java applet calling WCF Service fails with noclassdef exception at runtime

I have a java applet which uses a proxy service to a WCF Service to display data. The applet compiles and runs perfectly in Eclipse but when I build and export a Jar file then run it in a html page it fails with
java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException.
I have included jaxrpc.jar in my build path and my jar file contains all necessary classes.
The stack trace seems to be complaining about the line where I instantiate the proxy service from within the applet class. Does anyone know if there is an issue calling WCF service from a java applet?
Stack Trace:
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
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.NoClassDefFoundError: javax/xml/rpc/ServiceException
at ListProducts.ListProducts.<init>(ListProducts.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 java.lang.Class.newInstance0(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$200(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.lang.ClassNotFoundException: javax.xml.rpc.ServiceException
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)
... 27 more
This has been troubling me all day.
I think your issue is loading rpc jar, not call to wcf.
This post can be helpfull:
http://www.coderanch.com/t/259357/Applets/java/Applet-Axis-Client-Errors
It recomemds to sign your jar, verify you can access all your jars via browser, ensure you have all dependent.jars.
If all this will not help - i'd try to solve it as "
NoClassDefFoundError from spplet" issue.
Ok. I got this working by doing several things:
First I had to sign several of the jar files I was using:
jaxrpc.jar
axis.jar
commons-discovery-0.2.jar
but not:
javax.wsdl_1.6.2.v201012040545.jar
org.apache.commons.logging_1.0.4.v201101211617.jar
Secondly - all these files had to exist in the same directory as the html page, as I didn't specify a directory in codebase property for the applet tag.
Thirdly, within my main applet (ListProducts.class) I had to use AccessController.doPrivileged() around the code that first calls the proxy service:
EDIT: This step may not be necessary, as it now seems to work when I remove the doPrivileged block.
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
//instantiate proxy service and make rpc's
//do other stuff with results...
} catch (RemoteException e) {
// catch error
}
return null;
}
});
This combination of things got the java applet doing what it should. It was a painful slow process to discover which jar files were missing and then signing the appropriate ones.

Java Error whilst attempting to run a web-client

I'm having some problems while trying to open a web-client for a game that I play. I get this error and I don't know what to do. Help would be appreciated. If you need any more information please let me know and I will do the best I can to get it.
load: class client.class not found.
java.lang.ClassNotFoundException: client.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)
Exception: java.lang.ClassNotFoundException: client.class
It seems you are running your web client like this:
$ java client.class
Try running this instead:
$ java client

.class path api java

I would like to insert an API java into a web page.
Even with such an easy code:
applet code =
'Ejs.Simulations._apps._examples.HVmin'
archive = 'Ejs/Simulations/_apps/_examples/HVmin/hVmin.jar',
width = 300,
height = 300 />
I get this error:
cargar: clase Ejs.Simulations._apps._examples.HVmin not found.
java.lang.ClassNotFoundException: Ejs.Simulations._apps._examples.HVmin
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)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost/blanca/Ejs/Simulations/_apps/_examples/HVmin.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)
... 7 more
Excepción: java.lang.ClassNotFoundException: Ejs.Simulations._apps._examples.HVmin
I don't know where to put HVmin.class, I have tryed in differents paths with the same result.
The file HVmin.class is in this path:
C:\xampp\htdocs\blanca\Ejs\Simulations\_apps\_examples\HVmin
Any help, please?
Thanks in advance
Just put that class in the .jar file with the rest of the applet.

Categories