I am making a GWT application that involves users being able to upload files. My question is…
What is wrong with GWT?? It seems like every time I try to include a jar file in my project, it doesn’t like it. I am using Eclipse. Everything compiles fine, but during runtime, UmbrellaExceptions happen, which get traced back to some ClassNotFoundException eventually (relating to whatever new jarrified class I just tried to use).
I read something about this somewhere else, but I can’t remember exactly what the deal is; for whatever reason GWT just isn’t compatible with some libraries..? Like java.io, for example. Pretty much everything in that package causes this to happen. Like, I can’t even use FileNotFoundException for simple File I/O.
Again, just to clarify: everything imports and compiles fine, but GWT doesn’t want to load certain classes for some reason.
My latest problem is trying to use Apache’s Tika stuff for file validation. Attempting to instantiate any of their classes such as
Metadata metadata = new Metadata();
causes
java.lang.ClassNotFoundException: org.apache.tika.metadata.Metadata
at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1061)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at gwtupload.client.Uploader$10.onSubmit(Uploader.java:454)
at com.google.gwt.user.client.ui.FormPanel$SubmitEvent.dispatch(FormPanel.java:178)
at com.google.gwt.user.client.ui.FormPanel$SubmitEvent.dispatch(FormPanel.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
at com.google.gwt.user.client.ui.FormPanel.fireSubmitEvent(FormPanel.java:618)
at com.google.gwt.user.client.ui.FormPanel.submit(FormPanel.java:556)
at gwtupload.client.Uploader.submit(Uploader.java:1051)
at gwtupload.client.SingleUploader$1.onClick(SingleUploader.java:141)
at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:54)
at com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:129)
at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:116)
at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:177)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1351)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1307)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
GWT compiles your code to Javascript, which runs in the web browser. You cannot use
java.ioto do simple file I/O, because Javascript in the browser is not allowed to do file I/O. Almost any interesting library will access classes that are not emulated by the GWT runtime.Further to this, the GWT runtime will not automatically include a JAR file when compiling to Javascript. You need the source code available, and you need to write the XML descriptor to include the library source in Javascript generation.
See this thread and this tutorial on extending GWT.