You need to sign in to do that
Don't have an account?
iceberg4u
Problems with running applets in Visual Force
The applet starts successfully.Its purpose is to upload a pdf file.I have used the Salesforce APIs.And have included them in the JAR that I have prepared.The whole process works fine in HTML locally.The error that I am getting on Visual Force is :->
Exception in thread "AWT-EventQueue-4" java.lang.ClassFormatError: Incompatible magic value 168430090 in class file javax/servlet/ServletConfig
at java.lang.ClassLoader.defineClass1(Native Method)
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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethod(Unknown Source)
at org.apache.commons.discovery.tools.ClassUtils.findPublicStaticMethod(ClassUtils.java:116)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:178)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.access$200(EngineConfigurationFactoryFinder.java:46)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:128)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
at SforceServiceLocator.<init>(SforceServiceLocator.java:8)
at UploadingPDF.login(UploadingPDF.java:78)
at UploadingPDF.actionPerformed(UploadingPDF.java:224)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(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.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(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.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)
What can I do??Do i need to do the login and other such commands in this java file heres the whole java fileI have used this function as well.The error starts immediately after printing"Creating the binding to the web service":->
public boolean login() {
un = ****;
if (un.length() == 0) {
return false;
}
pw = ******;
if (pw.length() == 0) {
return false;
}
// Provide feed back while we create the web service binding
System.out.println("Creating the binding to the web service...");
/*
* There are 2 ways to get the binding, one by passing a url to the
* getSoap() method of the SforceServiceLocator, the other by not
* passing a url. In the second case the binding will use the url
* contained in the wsdl file when the proxy was generated.
*/
try {
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
System.out
.println("The login url is: "
+ binding
._getProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY));
} catch (ServiceException ex) {
System.out
.println("ERROR: creating binding to soap service, error was: \n"
+ ex.getMessage());
System.out.print("Hit return to continue...");
return false;
}
// Time out after a minute
binding.setTimeout(60000);
// Attempt the login giving the user feedback
System.out.println("LOGGING IN NOW....");
try {
loginResult = binding.login(un, pw);
} catch (LoginFault lf) {
System.out.println(lf.getExceptionMessage());
// lf.printStackTrace();
// getUserInput("\nHit return to continue...");
return false;
} catch (UnexpectedErrorFault uef) {
System.out.println(uef.getExceptionMessage());
uef.printStackTrace();
// getUserInput("\nHit return to continue...");
return false;
} catch (RemoteException re) {
System.out.println(re.getMessage());
re.printStackTrace();
// getUserInput("\nHit return to continue...");
return false;
}
System.out
.println("\nThe session id is: " + loginResult.getSessionId());
System.out.println("\nThe new server url is: "
+ loginResult.getServerUrl());
// set the session header for subsequent call authentication
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
// Create a new session header object and set the session id to that
// returned by the login
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName()
.getNamespaceURI(), "SessionHeader", sh);
loggedIn = true;
// call the getServerTimestamp method
getServerTimestampSample();
// call the getUserInfo method
getUserInfoSample();
return true;
}
Exception in thread "AWT-EventQueue-4" java.lang.ClassFormatError: Incompatible magic value 168430090 in class file javax/servlet/ServletConfig
at java.lang.ClassLoader.defineClass1(Native Method)
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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethod(Unknown Source)
at org.apache.commons.discovery.tools.ClassUtils.findPublicStaticMethod(ClassUtils.java:116)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:178)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.access$200(EngineConfigurationFactoryFinder.java:46)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:128)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
at SforceServiceLocator.<init>(SforceServiceLocator.java:8)
at UploadingPDF.login(UploadingPDF.java:78)
at UploadingPDF.actionPerformed(UploadingPDF.java:224)
at javax.swing.JTextField.fireActionPerformed(Unknown Source)
at javax.swing.JTextField.postActionEvent(Unknown Source)
at javax.swing.JTextField$NotifyAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(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.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(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.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)
What can I do??Do i need to do the login and other such commands in this java file heres the whole java fileI have used this function as well.The error starts immediately after printing"Creating the binding to the web service":->
public boolean login() {
un = ****;
if (un.length() == 0) {
return false;
}
pw = ******;
if (pw.length() == 0) {
return false;
}
// Provide feed back while we create the web service binding
System.out.println("Creating the binding to the web service...");
/*
* There are 2 ways to get the binding, one by passing a url to the
* getSoap() method of the SforceServiceLocator, the other by not
* passing a url. In the second case the binding will use the url
* contained in the wsdl file when the proxy was generated.
*/
try {
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
System.out
.println("The login url is: "
+ binding
._getProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY));
} catch (ServiceException ex) {
System.out
.println("ERROR: creating binding to soap service, error was: \n"
+ ex.getMessage());
System.out.print("Hit return to continue...");
return false;
}
// Time out after a minute
binding.setTimeout(60000);
// Attempt the login giving the user feedback
System.out.println("LOGGING IN NOW....");
try {
loginResult = binding.login(un, pw);
} catch (LoginFault lf) {
System.out.println(lf.getExceptionMessage());
// lf.printStackTrace();
// getUserInput("\nHit return to continue...");
return false;
} catch (UnexpectedErrorFault uef) {
System.out.println(uef.getExceptionMessage());
uef.printStackTrace();
// getUserInput("\nHit return to continue...");
return false;
} catch (RemoteException re) {
System.out.println(re.getMessage());
re.printStackTrace();
// getUserInput("\nHit return to continue...");
return false;
}
System.out
.println("\nThe session id is: " + loginResult.getSessionId());
System.out.println("\nThe new server url is: "
+ loginResult.getServerUrl());
// set the session header for subsequent call authentication
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
// Create a new session header object and set the session id to that
// returned by the login
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName()
.getNamespaceURI(), "SessionHeader", sh);
loggedIn = true;
// call the getServerTimestamp method
getServerTimestampSample();
// call the getUserInfo method
getUserInfoSample();
return true;
}
I have had this issue as well. Later I found out that the Magic Number issue is caused when the Jar file is not properly being returned by Server on which it is hosted.
Make sure that you refered to the jar file correctly before you try something else.
One more thing it is ok to compile the Jar file in JRE 1.5 and run it on 1.6 this should not cause any issues.
Make sure the jar is refered in the way shown below.
<applet code="AppLauncherApplet.class" archive="{!$Resource.SignedAppLauncherAppletLauncher}" width="400" height="400">
All Answers
Do you have the problem on the same PC that runs it locally without errors ?
-David
I then tried each of these versions in an HTML file after making a jar file out of my project.It still was working properly and the file was getting uploaded.
Now I have put the jar file as a static resource after zipping it.The application gives the above error when I put it there.
Also after putting in a lots of system.out.prinltn I have found the following things:->
1)My class file that is called ApptoAppl.class is called. in the VF page.
2)When I call a function present in the salesforce class files that i downloaded from wiki I get the error i.e. the class just does not get loaded
This is the call that I have made in main class file.
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
The call does not occur I do not know for what reason,Here is the class that is written
public class SforceServiceLocator extends org.apache.axis.client.Service implements SforceService {
public Soap getSoap() throws javax.xml.rpc.ServiceException {
java.net.URL endpoint;
try {
System.out.println("Hello");
endpoint = new java.net.URL(Soap_address);
}
catch (java.net.MalformedURLException e) {
throw new javax.xml.rpc.ServiceException(e);
}
return getSoap(endpoint);
}
}
Is it because of the jar files axis,axis-ant that I have used??But these jar files work properly when I use it in my html environment.
I have had this issue as well. Later I found out that the Magic Number issue is caused when the Jar file is not properly being returned by Server on which it is hosted.
Make sure that you refered to the jar file correctly before you try something else.
One more thing it is ok to compile the Jar file in JRE 1.5 and run it on 1.6 this should not cause any issues.
Make sure the jar is refered in the way shown below.
<applet code="AppLauncherApplet.class" archive="{!$Resource.SignedAppLauncherAppletLauncher}" width="400" height="400">
I am trying to save the applet in static resource and facing many issues. Can i get a working example of any applet saved in static resource and connecting to salesforce.
Can anyone please provide me with that?