Using GWT-polymer-elements in a GWT project?

0

I'm trying to use the elemetos polymer GWT in a project, but receives an exception. This and the code that calls the polymer element:

public void onModuleLoad () {
try {
RootPanel.get () add (new PaperButton ().);
} Catch (Exception e) {
e.printStackTrace ();
}

This is the exessão:

Caused by: com.google.gwt.dev.shell.HostedModeException: JSNI rewriter found reference to non-existent field in a field reference or Java method tear-off: @ java.util.ArrayList :: array with at / vaadin / polymer /Polymer.java(479)

lib inheritance xml  

 <Inherits name = "com.vaadin.polymer.Elements" />

the jar that was used:

vaadin-gwt-polymer-elements-1.2.3.0.jar

Complete log console:

jul 22, 2016 5:30:52 PM java.util.prefs.WindowsPreferences <init>
ADVERTÊNCIA: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
    at com.google.gwt.dev.js.ast.JsVisitor.translateException(JsVisitor.java:482)
    at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:469)
    at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
    at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
    at com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGenerationVisitor.java:201)
    at com.google.gwt.dev.js.ast.JsBinaryOperation.traverse(JsBinaryOperation.java:81)
    at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
    at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
    at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
    at com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGenerationVisitor.java:436)
    at com.google.gwt.dev.js.ast.JsExprStmt.traverse(JsExprStmt.java:41)
    at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
    at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
    at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
    at com.google.gwt.dev.js.JsToStringGenerationVisitor.printJsBlock(JsToStringGenerationVisitor.java:939)
    at com.google.gwt.dev.js.JsSourceGenerationVisitor.visit(JsSourceGenerationVisitor.java:59)
    at com.google.gwt.dev.js.ast.JsBlock.traverse(JsBlock.java:52)
    at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
    at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:444)
    at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
    at com.google.gwt.dev.shell.Jsni.generateJavaScriptForHostedMode(Jsni.java:249)
    at com.google.gwt.dev.shell.Jsni.getJavaScriptForHostedMode(Jsni.java:237)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.createNativeMethods(ModuleSpaceOOPHM.java:52)
    at com.google.gwt.dev.shell.CompilingClassLoader.injectJsniMethods(CompilingClassLoader.java:1408)
    at com.google.gwt.dev.shell.CompilingClassLoader.findClass(CompilingClassLoader.java:1178)
    at com.google.gwt.dev.shell.CompilingClassLoader.loadClass(CompilingClassLoader.java:1223)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at com.vaadin.polymer.PolymerWidget.<init>(PolymerWidget.java:17)
    at com.vaadin.polymer.paper.widget.PaperButton.<init>(PaperButton.java:105)
    at com.vaadin.polymer.paper.widget.PaperButton.<init>(PaperButton.java:98)
    at br.client.Aprend.onModuleLoad(Aprend.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:423)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:530)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:368)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.google.gwt.dev.shell.HostedModeException: JSNI rewriter found reference to non-existent field in a field reference or java method tear-off: @java.util.ArrayList::array at com/vaadin/polymer/Polymer.java(479)
    at com.google.gwt.dev.shell.Jsni$JsSourceGenWithJsniIdentFixup.visit(Jsni.java:115)
    at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:108)
    at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:467)
    ... 38 more
gwt
polymer
asked on Stack Overflow Jul 22, 2016 by Jeterson Miranda Gomes • edited Jul 23, 2016 by Jeterson Miranda Gomes

1 Answer

1

With the gwt-polymer-elements version you are using (1.2.3.0) you need to use GWT 2.8 Snapshot, due to JsInterop which is used. See this official notice from Vaadin:

NOTICE : We make extensive use of JsInterop a new feature in GWT for easily interacting with JavaScript. It is experimental in GWT-2.7 and will be stable in GWT-2.8.0, but starting from gwt-polymer-elements-1.2.1.0.beta1, we don't support 2.7.0 anymore nor it's legacy JsInterop syntax. If you got Uncaught java.lang.ClassCastException errors in the JavaScript console when running your application, it does mean that you are not using GWT-2.8.0-SNAPSHOT

Moreover your syntax is wrong and

RootPanel.get () add (new PaperButton ().); should be changed to RootPanel.get().add(new PaperButton());

I tested version 1.1.3.0-alpha1 with GWT 2.7 (SuperDevMode) and it is working fine. So please check your GWT version.

One more hint: For cross-browser-support you should add

<script src="your_app_name/bower_components/webcomponentsjs/webcomponents.js"></script>

to the head of your HTML file.

answered on Stack Overflow Jul 24, 2016 by mxlse • edited Jul 24, 2016 by mxlse

User contributions licensed under CC BY-SA 3.0