GWT History JavaScript Not Working in Internet Explorer - java

I am having trouble getting the Google Web Toolkit's History class to work in Internet Explorer, even though it works in Chrome, FF.
I created an app using GWT 2.0 about 12 months ago, and noticed it stopped working sometime. I stripped it back to just the very first class and it seems any time I call History.addValueChangeHandler, Internet Explorer crashes.
Here is the code:
package com.js.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.History;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Test implements EntryPoint, ValueChangeHandler<String>
{
/**
* This is the entry point method.
*/
public void onModuleLoad() {
History.addValueChangeHandler(this);
History.fireCurrentHistoryState();
}
public void onValueChange(ValueChangeEvent<String> event) {
Label loading = new Label( "Loading..." );
RootPanel.get().add( loading );
}
}
It's hard to believe this could crash, but here is the error:
18:50:52.407 [ERROR] [test] Unable to load module entry point class com.js.client.Test (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (Error): Access is denied.
description: Access is denied.
number: -2147024891
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.user.client.impl.HistoryImplIE6.getTokenElement(HistoryImplIE6.java)
at com.google.gwt.user.client.impl.HistoryImplIE6.init(HistoryImplIE6.java:80)
at com.google.gwt.user.client.History.<clinit>(History.java:63)
at com.js.client.Test.onModuleLoad(Test.java:24)
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.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Unknown Source)
Any help would be appreciated. Thanks!

Is this IE7? Are you using a JSP/Servlet to render your home page? If yes ensure your servlet generates the history iframe/script code with double quotes and not single quotes.

Related

Error when using jar but not in the library itself

I built a Java library to send message in IBM MQ.
It is working fine when I execute the code on the library project.
However, when I use the .jar into another tool (JMeter), an error occurs.
java.lang.NoSuchMethodError: com.ibm.mq.jmqi.JmqiFactory.getInstance(Lcom/ibm/mq/jmqi/JmqiThreadPoolFactory;Lcom/ibm/mq/jmqi/JmqiPropertyHandler;)Lcom/ibm/mq/jmqi/JmqiEnvironment;
at com.ibm.msg.client.mqlight.MQLightComponent.getImplementationInfo(MQLightComponent.java:220) ~[mq-jms-8.0.0.3.jar:8.0.0.3 - p800-003-150615.2]
at com.ibm.msg.client.commonservices.trace.Trace.getVersion(Trace.java:1692) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.commonservices.trace.Trace.createFFSTString(Trace.java:1650) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.commonservices.trace.Trace.ffstInternal(Trace.java:1536) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.commonservices.trace.Trace.ffst(Trace.java:1444) ~[mq-jms-7.0.1.3.jar:?]
at com.ibm.msg.client.jms.JmsFactoryFactory.getInstance(JmsFactoryFactory.java:209) ~[mq-jms-7.0.1.3.jar:7.0.1.3 - k701-103-100812]
at com.ibm.mq.jms.MQConnectionFactory.initialiseMQConnectionFactory(MQConnectionFactory.java:3325) ~[mq-jms-7.0.1.3.jar:7.0.1.3 - k701-103-100812]
at com.ibm.mq.jms.MQConnectionFactory.<init>(MQConnectionFactory.java:274) ~[mq-jms-7.0.1.3.jar:7.0.1.3 - k701-103-100812]
at my.package.MQ_Manager.createConnection(MQ_Manager.java:36) ~[my-jar.jar:?]
at my.package.MQ_Manager.<init>(MQ_Manager.java:27) ~[my-jar.jar:?]
at my.package.Producer.<init>(Producer.java:18) ~[my-jar.jar:?]
at my.package.Request.sendRequest(Request.java:116) ~[my-jar.jar:?]
at my.package.Request$sendRequest$2.call(Unknown Source) ~[?:?]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) ~[groovy-all-2.4.16.jar:2.4.16]
at Script1.run(Script1.groovy:14) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72) ~[groovy-all-2.4.16.jar:2.4.16]
at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_31]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:223) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:71) ~[ApacheJMeter_java.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486) ~[ApacheJMeter_core.jar:5.1 r1853635]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253) ~[ApacheJMeter_core.jar:5.1 r1853635]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_31]
Corresponding code:
MQConnectionFactory factory = new MQConnectionFactory();
factory.setHostName(properties.getProperty("HOST"));
factory.setPort(Integer.parseInt(properties.getProperty("PORT")));
factory.setChannel(properties.getProperty("CHANNEL"));
factory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
factory.setQueueManager(properties.getProperty("QUEUE_MANAGER"));
factory.setAppName(properties.getProperty("APP_NAME"));
Connection connection = factory.createConnection(properties.getProperty("APP_USER"), properties.getProperty("APP_PASSWORD"));
connection.start();
return connection;
Error occurs at this line MQConnectionFactory factory = new MQConnectionFactory();
Any idea? Thank you.
Update 1
To create the .jar I :
Clicked on Export
Selected Runnable JAR file
Selected Extract required libraries into generated JAR
Update 2
Moreover when I built the Jar, I get this warning. Do you think that is important?
This operation repacks references libraries. Please review the licences associated with libraries you wish ti reference to make sure you are able to repack them using this application. Note also that this operation does not copy signature files from orignal libraies to the generated JAR file.
After disccussing the issue with the OP I went ahead a verified the issue myself.
The result is that its working for me ...
Step 1:
Created a maven project with included the following code
package test;
import javax.jms.JMSException;
import com.ibm.mq.jms.MQConnectionFactory;
public class JmeterTest {
public JmeterTest() {
}
public void test() throws JMSException {
MQConnectionFactory factory = new MQConnectionFactory();
factory.setAppName("myApp");
}
public static void main(String[] args) {
System.out.println("test");
}
}
Step 2:
Exported this from eclipse as runnable jar and copied into JMeter (\lib\ext\).
Note that a export with library handling package required jars into generated jar does not work. Use Extract into generated jar or Copy into subfolder (and then copy the jars from the subfolder into \lib\ext as well).
related dependecies are:
com.ibm.mq.allclient-9.0.4.0.jar
bcokix-jdk15on-1.57.jar
bcprov-jdk15on-1.57.jar
javax.jms-api-2.0.1.jar
Step 3:
Started JMeter and created a ThreadGroup with a JSR223 Sampler.
import test.JmeterTest;
new JmeterTest().test();
Then started the test. No error occurred.
Step 4:
Instead of exporting a library, you could directly (after adding the dependencies) add the required code into the script panel:
import javax.jms.JMSException;
import com.ibm.mq.jms.MQConnectionFactory;
MQConnectionFactory factory = new MQConnectionFactory();
factory.setAppName("myApp");
Worked as well
Conclusion: Interference from other dependencies on the jmeter classpath are the likeliest cause of the issue.

Java 7 update 25 makes our java web start application fail with no logging

Since the java 7 update 25 launched by Oracle our application no longer functions.
Initially we got some warning about codebase & sercurity tags missing in the Manifest file, which we fixed.
The problem we now end up with is that in the Console we only get the following lines:
#### Java Web Start Error:
#### null
We also get an application Error dialog with the message: Unable to launch the application.
The details button gives the following details in the Exception:
java.lang.NullPointerException
at com.sun.jnlp.JNLPClassLoader.getPermissions(Unknown Source)
at java.security.SecureClassLoader.getProtectionDomain(SecureClassLoader.java:206)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at desktop.DesktopProxySelector.<init>(DesktopProxySelector.java:24) <- code smippet below
at desktop.Main.main(Main.java:139) <- code smippet below
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Thread.java:724)
The relevant code parts are:
Desktop.Main.main
/**
* Main method, starts the application
*/
public static void main(String[] args) {
System.setProperty("java.net.useSystemProxies", "true");
//Logger.getLogger("httpclient.wire.header.level").setLevel(Level.FINEST);
//Logger.getLogger("org.apache.commons.httpclient.level").setLevel(Level.FINEST);
java.net.ProxySelector.setDefault(new DesktopProxySelector(java.net.ProxySelector.getDefault()));
(The last line is line number 139)
desktop.DesktopProxySelector:
public class DesktopProxySelector extends ProxySelector {
public DesktopProxySelector(ProxySelector defaultSelector) {
URI httpsUri = new CentralConfigurationService().getCentralLocation();
(The last line is line number 24 where the exception occures)
Can someone give us some clues hints (or better a solution) for this new behaviour of java caused by this 'minor' update.
When we run the application straight from the cli using java -jar Desktop.jar the application wil run file, so the issue has clearly something todo with the changes in java web start.
#trashgod: the error clearly has something to do with the Permissions change in 7u25, since the NullPointerException occurs in com.sun.jnlp.JNLPClassLoader.getPermissions.
Just to explain what I think happens (I am a colleague of Wouter):
desktop.Main instantiates a desktop.DesktopProxySelector (our class),
desktop.DesktopProxySelector instantiates desktop.configuration.CentralConfigurationService
desktop.configuration.CentralConfigurationService instantiates a java.net.URI.
On the first line of the DesktopProxySelector init where the CentralConfigurationService is instantiated the getPermissions method, called by the JNLPClassLoader, throws the NullPointerException. So something is going wrong while loading the CentralConfigurationService class by java webstart with getting the permissions for the class. Could that have anything to do with the fact that a URI class is instantiated, which requires extra permissions (a connection to a remote uri is setup)?
Eventually the problem was solved.
The problem was caused between a mismatch in the included jar files in the main MANIFEST.MF file vs the jar files mentioned in the launch.jnlp.
Apperently it is now required to have all jar files that will be used also be present in the launch.jnlp file.
(In the past it was decided to keep this file manually in sink, which obviously was not always maintained in a propper way. Now this process is automated, so the problem should no longer happen to us.)

Google App Engine Java Can't Run Application HTTP 500

I have a simple servlet which looks like like below. Ite uses the Google's User Service. When I don't use it I don't get any errors. Also I get an entire list of error as below. I turn out that this was an Eclipse Known Issue but I can't find the solution.
import java.io.IOException;
import javax.servlet.http.*;
import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
#SuppressWarnings("serial")
public class GuestbookServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if (user != null) {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, " + user.getNickname());
} else {
resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
}
}
}
These are the first errors:
HTTP ERROR 500
Problem accessing /guestbook. Reason:
Expecting a stackmap frame at branch target 117 in method guestbook.GuestbookServlet.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V at offset 34
Caused by:
java.lang.VerifyError: Expecting a stackmap frame at branch target 117 in method guestbook.GuestbookServlet.doGet(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V at offset 34
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
Is the problem from the Java version? I am running Eclipse Indigo and Java 7. What should I do
This seems to be a known eclipse issue with JDK7. Please check this link for workaround/solution.

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