Putting Java applet onto server - java

My applet that connects JS/Java with LiveConnect worked from localhost but when transferring to server I get this error in java applet console. Do I have to do something before I transfer these files?
java.lang.ClassFormatError: Incompatible magic value 1008821359 in class file PrintJob/Print_Runner 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 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.ClassFormatError: Incompatible magic value 1008821359 in class file PrintJob/Print_Runner

That means the class files didn't transfer properly. If you're using an FTP server make sure you have the binary option enabled.

Related

Applet java.lang.NoClassDefFoundError - JVM Runtime Classes

I am using an applet that will be called by JavaScript in the background to access the clipboard and copy the contents. I am using the below code to load the applet in my JSP file.
var attributes = { id:'applet', code:'com.applet.Applet.class', archive:'/applet/applet.jar', width:1, height:1, style:'display:none' } ;
var parameters = { } ;
deployJava.runApplet(attributes, parameters, '1.4');
The applet is signed, loads and runs fine 99% of the time. But, sporadically I see errors stating that few runtime JAVA classes are not found which I don't use. Its purely runtime classes which is required to load the applet itself. Also, it does not fail for the same class. It fails for different classes. Is there something that I am missing?
Unfortunately, this happens only in higher environments where we don't have much control to enable the trace and logs.
Let me know if any additional information is required.
Example:
java.lang.NoClassDefFoundError: Could not initialize class sun.net.www.http.KeepAliveStream
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source)
at sun.plugin.PluginURLJarFileCallBack.access$000(Unknown Source)
at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.retrieve(Unknown Source)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(Unknown Source)
at sun.net.www.protocol.jar.JarFileFactory.get(Unknown Source)
at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)
at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source)
at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$1000(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.<init>(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(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.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.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

java.lang.NoSuchFieldError: completionKey

When I'm trying to start my Derby Network Server, I'm getting this exception. This has never happened before and I don't now what's the cause of problem. Any ideas?
Exception in thread "main" java.lang.NoSuchFieldError: completionKey
at sun.nio.fs.WindowsNativeDispatcher.initIDs(Native Method)
at sun.nio.fs.WindowsNativeDispatcher.<clinit>(Unknown Source)
at sun.nio.fs.WindowsLinkSupport.getRealPath(Unknown Source)
at sun.nio.fs.WindowsPath.toRealPath(Unknown Source)
at sun.nio.fs.WindowsPath.toRealPath(Unknown Source)
at sun.util.calendar.ZoneInfoFile$1.run(Unknown Source)
at sun.util.calendar.ZoneInfoFile$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.util.calendar.ZoneInfoFile.<clinit>(Unknown Source)
at sun.util.calendar.ZoneInfo.getTimeZone(Unknown Source)
at java.util.TimeZone.getTimeZone(Unknown Source)
at java.util.TimeZone.setDefaultZone(Unknown Source)
at java.util.TimeZone.getDefaultRef(Unknown Source)
at java.util.TimeZone.getDefault(Unknown Source)
at java.text.SimpleDateFormat.initializeCalendar(Unknown Source)
at java.text.SimpleDateFormat.<init>(Unknown Source)
at java.text.DateFormat.get(Unknown Source)
at java.text.DateFormat.getDateInstance(Unknown Source)
at org.apache.derby.iapi.tools.i18n.LocalizedResource.init(Unknown Source)
at org.apache.derby.iapi.tools.i18n.LocalizedResource.<init>(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl.init(Unknown Source)
at org.apache.derby.impl.drda.NetworkServerControlImpl.<init>(Unknown Source)
at org.apache.derby.drda.NetworkServerControl.main(Unknown Source)
This is an Error (!) that is due to running code that was compiled against a class with a field and executing it with another (compiled) version without that field.
Go back and check installed versions, recompile everything, etc. etc-

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 applet works on Oracle JRE 7u5, doesn't work on 7u6

Our team has an applet that is working fine in Oracle JRE 7u5. Upon updating the JRE to 7u6 or 7u7, the applet fails to initialize. An exception is thrown by the class loader during its loading of the log4j classes:
Caused by: java.lang.IllegalStateException: zip file closed
at java.util.zip.ZipFile.ensureOpen(Unknown Source)
at java.util.zip.ZipFile.getEntry(Unknown Source)
at java.util.jar.JarFile.getEntry(Unknown Source)
at java.util.jar.JarFile.getJarEntry(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(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.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.apache.log4j.PropertyConfigurator.class$(PropertyConfigurator.java:572)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:752)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
Has anyone else observed this behavior?
This particular bug has been observed by others and has been filed in Oracle's bug database.

Incompatible magic value 1010792557 for 1 client only

I have one client getting this error whilst the applet is working properly for a number of other users.
java.lang.ClassFormatError: Incompatible magic value 1010792557 in class file %className%
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.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.SecurityException: class "%className%"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
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 java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(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 sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I believe that the magic value represents the start of an xml tag (based on this Incompatible magic value 1010792557 when trying to run applet embedded in Facelets). The security error occurs after the magic value error and I suspect its a byproduct of the first problem.
What I can't fathom is why this is happening to one client only.
All clients are using JRE version 1.6.0_24-b07 and IE 8.0.6001.18702.
On the clients machine I have tried clearing the cache, deleting temporary internet files, and deleting temporary internet files via the java control panel. I have also tried deleting the certificate from the javacpl 'trusted certificates' list and even turning off verification from javacpl>Advanced>Security>Mixed Code.
I'm out of ideas and would love to hear any suggestions on what the problem/solution might be.
Oh, the applet is hosted in a java wicket project running on tomcat 7.0.19 via apache 2.2 (on windows server 2008).

Categories