java - GWT - Error to load entry point -
i'm trying run app in gwt 2.6. project sample of webcam using elemental (library gwt-elemental). source code wich using, found example: https://code.google.com/p/elemental-getusermedia-demo/source/browse/#svn%2ftrunk%2felementalgetusermediademo
when run app, error below show, can't find problem.
message:
08:08:57.756 [error] [elementalgetusermediademo] unable load module entry point class com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo (see associated exception details) java.lang.runtimeexception: deferred binding failed 'com.google.gwt.user.client.impl.domimpl' (did forget inherit required module?) @ com.google.gwt.dev.shell.gwtbridgeimpl.create(gwtbridgeimpl.java:53) @ com.google.gwt.core.shared.gwt.create(gwt.java:72) @ com.google.gwt.core.client.gwt.create(gwt.java:86) @ com.google.gwt.user.client.dom.<clinit>(dom.java:64) @ com.google.gwt.user.client.ui.flowpanel.<init>(flowpanel.java:34) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo$imagesstrip.<init>(elementalgetusermediademo.java:281) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo.onmoduleload(elementalgetusermediademo.java:65) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ com.google.gwt.dev.shell.modulespace.onload(modulespace.java:411) @ com.google.gwt.dev.shell.oophmsessionhandler.loadmodule(oophmsessionhandler.java:200) @ com.google.gwt.dev.shell.browserchannelserver.processconnection(browserchannelserver.java:526) @ com.google.gwt.dev.shell.browserchannelserver.run(browserchannelserver.java:364) @ java.lang.thread.run(thread.java:744) caused by: com.google.gwt.dev.jjs.internalcompilerexception: unexpected error during visit. @ com.google.gwt.dev.js.ast.jsvisitor.translateexception(jsvisitor.java:483) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:470) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.js.jstostringgenerationvisitor.visit(jstostringgenerationvisitor.java:835) @ com.google.gwt.dev.js.ast.jsvars$jsvar.traverse(jsvars.java:61) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.js.jstostringgenerationvisitor.visit(jstostringgenerationvisitor.java:848) @ com.google.gwt.dev.js.ast.jsvars.traverse(jsvars.java:101) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.js.jstostringgenerationvisitor.printjsblock(jstostringgenerationvisitor.java:907) @ com.google.gwt.dev.js.jssourcegenerationvisitor.visit(jssourcegenerationvisitor.java:59) @ com.google.gwt.dev.js.ast.jsblock.traverse(jsblock.java:47) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.shell.jsni.generatejavascriptforhostedmode(jsni.java:253) @ com.google.gwt.dev.shell.jsni.getjavascriptforhostedmode(jsni.java:241) @ com.google.gwt.dev.shell.modulespaceoophm.createnativemethods(modulespaceoophm.java:52) @ com.google.gwt.dev.shell.compilingclassloader.injectjsnimethods(compilingclassloader.java:1379) @ com.google.gwt.dev.shell.compilingclassloader.findclass(compilingclassloader.java:1149) @ com.google.gwt.dev.shell.compilingclassloader.loadclass(compilingclassloader.java:1194) @ java.lang.classloader.loadclass(classloader.java:358) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:270) @ com.google.gwt.dev.shell.modulespace.loadclassfromsourcename(modulespace.java:670) @ com.google.gwt.dev.shell.modulespace.rebindandcreate(modulespace.java:473) @ com.google.gwt.dev.shell.gwtbridgeimpl.create(gwtbridgeimpl.java:49) @ com.google.gwt.core.shared.gwt.create(gwt.java:72) @ com.google.gwt.core.client.gwt.create(gwt.java:86) @ com.google.gwt.user.client.dom.<clinit>(dom.java:64) @ com.google.gwt.user.client.ui.flowpanel.<init>(flowpanel.java:34) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo$imagesstrip.<init>(elementalgetusermediademo.java:281) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo.onmoduleload(elementalgetusermediademo.java:65) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ com.google.gwt.dev.shell.modulespace.onload(modulespace.java:411) @ com.google.gwt.dev.shell.oophmsessionhandler.loadmodule(oophmsessionhandler.java:200) @ com.google.gwt.dev.shell.browserchannelserver.processconnection(browserchannelserver.java:526) @ com.google.gwt.dev.shell.browserchannelserver.run(browserchannelserver.java:364) @ java.lang.thread.run(thread.java:744) caused by: java.lang.indexoutofboundsexception: index: 11, size: 11 @ java.util.arraylist.rangecheck(arraylist.java:635) @ java.util.arraylist.get(arraylist.java:411) @ com.google.gwt.dev.shell.compilingclassloader$dispatchclassinfooracle.getclassinfobydispid(compilingclassloader.java:122) @ com.google.gwt.dev.shell.compilingclassloader.getclassinfobydispid(compilingclassloader.java:1012) @ com.google.gwt.dev.shell.jsni$jssourcegenwithjsniidentfixup.visit(jsni.java:109) @ com.google.gwt.dev.js.ast.jsnameref.traverse(jsnameref.java:117) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.js.jstostringgenerationvisitor.visit(jstostringgenerationvisitor.java:835) @ com.google.gwt.dev.js.ast.jsvars$jsvar.traverse(jsvars.java:61) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.js.jstostringgenerationvisitor.visit(jstostringgenerationvisitor.java:848) @ com.google.gwt.dev.js.ast.jsvars.traverse(jsvars.java:101) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.js.jstostringgenerationvisitor.printjsblock(jstostringgenerationvisitor.java:907) @ com.google.gwt.dev.js.jssourcegenerationvisitor.visit(jssourcegenerationvisitor.java:59) @ com.google.gwt.dev.js.ast.jsblock.traverse(jsblock.java:47) @ com.google.gwt.dev.js.ast.jsvisitor.dotraverse(jsvisitor.java:468) @ com.google.gwt.dev.js.ast.jsvisitor.doaccept(jsvisitor.java:445) @ com.google.gwt.dev.js.ast.jsvisitor.accept(jsvisitor.java:109) @ com.google.gwt.dev.shell.jsni.generatejavascriptforhostedmode(jsni.java:253) @ com.google.gwt.dev.shell.jsni.getjavascriptforhostedmode(jsni.java:241) @ com.google.gwt.dev.shell.modulespaceoophm.createnativemethods(modulespaceoophm.java:52) @ com.google.gwt.dev.shell.compilingclassloader.injectjsnimethods(compilingclassloader.java:1379) @ com.google.gwt.dev.shell.compilingclassloader.findclass(compilingclassloader.java:1149) @ com.google.gwt.dev.shell.compilingclassloader.loadclass(compilingclassloader.java:1194) @ java.lang.classloader.loadclass(classloader.java:358) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:270) @ com.google.gwt.dev.shell.modulespace.loadclassfromsourcename(modulespace.java:670) @ com.google.gwt.dev.shell.modulespace.rebindandcreate(modulespace.java:473) @ com.google.gwt.dev.shell.gwtbridgeimpl.create(gwtbridgeimpl.java:49) @ com.google.gwt.core.shared.gwt.create(gwt.java:72) @ com.google.gwt.core.client.gwt.create(gwt.java:86) @ com.google.gwt.user.client.dom.<clinit>(dom.java:64) @ com.google.gwt.user.client.ui.flowpanel.<init>(flowpanel.java:34) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo$imagesstrip.<init>(elementalgetusermediademo.java:281) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo.onmoduleload(elementalgetusermediademo.java:65) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ com.google.gwt.dev.shell.modulespace.onload(modulespace.java:411) @ com.google.gwt.dev.shell.oophmsessionhandler.loadmodule(oophmsessionhandler.java:200) @ com.google.gwt.dev.shell.browserchannelserver.processconnection(browserchannelserver.java:526) @ com.google.gwt.dev.shell.browserchannelserver.run(browserchannelserver.java:364) @ java.lang.thread.run(thread.java:744)
two errors in class of entry point.
@ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo$imagesstrip.<init>(elementalgetusermediademo.java:281) @ com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo.onmoduleload(elementalgetusermediademo.java:65)
my class entry point:
package com.jooink.experiments.elementalgetusermedia.client; import java.util.arraylist; import com.google.gwt.core.client.entrypoint; import com.google.gwt.event.dom.client.clickevent; import com.google.gwt.event.dom.client.clickhandler; import com.google.gwt.user.client.timer; import com.google.gwt.user.client.window; import com.google.gwt.user.client.ui.anchor; import com.google.gwt.user.client.ui.button; import com.google.gwt.user.client.ui.flowpanel; import com.google.gwt.user.client.ui.html; import com.google.gwt.user.client.ui.hashorizontalalignment; import com.google.gwt.user.client.ui.horizontalpanel; import com.google.gwt.user.client.ui.image; import com.google.gwt.user.client.ui.iswidget; import com.google.gwt.user.client.ui.popuppanel; import com.google.gwt.user.client.ui.rootlayoutpanel; import com.google.gwt.user.client.ui.verticalpanel; import com.google.gwt.user.client.ui.widget; import com.jooink.experiments.elementalgetusermedia.client.elementalutils.usermediacallback; import elemental.client.browser; import elemental.events.event; import elemental.events.eventlistener; import elemental.html.canvaselement; import elemental.html.canvasrenderingcontext2d; import elemental.html.videoelement; /** * trivial sample of video/canvas & getusermedia */ public class elementalgetusermediademo implements entrypoint { //caching canvas private canvaselement canvas = browser.getdocument().createcanvaselement(); private imagesstrip images; private static final int tiles_w = 160; private static final int tiles_h = 120; @override public void onmoduleload() { final usermediaholder usermediaholder = new usermediaholder(); int h = window.getclientheight(); int w = window.getclientwidth(); int nx = w/160; int ny = h/120; images = new imagesstrip(nx*ny, tiles_w + "px", tiles_h + "px"); rootlayoutpanel.get().add(images); button cam = new button("capture cam"); cam.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { if(!usermediaholder.getusermedia(usermediacallback)) window.alert("fail: browser \""+ window.navigator.getuseragent()+"\" not support webrtc's getusermedia :("); }; }); popuppanel pp = new popuppanel(false, true); pp.add(cam); pp.center(); pp.show(); } private string makepicture(videoelement videoelement, canvaselement canvaselement) { canvaselement.setwidth( videoelement.getvideowidth()); canvaselement.setheight( videoelement.getvideoheight()); elemental.html.canvasrenderingcontext2d ctx = (canvasrenderingcontext2d) canvaselement.getcontext("2d"); ctx.drawimage(videoelement, 0, 0); return canvaselement.todataurl("image/png"); } private final usermediacallback usermediacallback = new usermediacallback() { public void onsuccess(string s) { final popuppanel popuppanel = new popuppanel(false,true); final elementalvideowidget video = new elementalvideowidget(); video.getvideoelement().setsrc(s); video.getvideoelement().play(); popuppanel.setwidget(new html("waiting video become available")); popuppanel.center(); popuppanel.show(); //finalize ui when video available video.getvideoelement().addeventlistener("loadedmetadata", new eventlistener() { @override public void handleevent(event evt) { int w = video.getvideoelement().getvideowidth(); int h = video.getvideoelement().getvideoheight(); video.setsize(w+"px", h+"px"); final verticalpanel vp = new verticalpanel(); vp.add(video); final horizontalpanel hp = new horizontalpanel(); anchor click = new anchor("make picture"); click.addclickhandler( new clickhandler() { @override public void onclick(clickevent event) { string data = makepicture(video.getvideoelement(), canvas); anchor done = new anchor("done"); done.getelement().getstyle().setcolor("red"); done.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { popuppanel.hide(); } }); vp.clear(); vp.add(new image(data)); vp.add(hp); hp.clear(); hp.add(done); hp.setcellhorizontalalignment(done, hashorizontalalignment.align_center); } }); anchor close = new anchor("close"); close.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { popuppanel.hide(); } }); anchor timely_circular = new anchor("stream (circular)"); timely_circular.addclickhandler( new clickhandler() { @override public void onclick(clickevent event) { final timer timer = new timer() { @override public void run() { string data = makepicture(video.getvideoelement(),canvas); images.push_circular(data); } }; anchor stop = new anchor("stop"); stop.getelement().getstyle().setcolor("red"); stop.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { timer.cancel(); popuppanel.hide(); } }); hp.clear(); hp.add(stop); hp.setcellhorizontalalignment(stop, hashorizontalalignment.align_center); video.getvideoelement().setwidth(tiles_w); video.getvideoelement().setheight(tiles_h); video.setsize(tiles_w + "px", tiles_h + "px"); popuppanel.center(); string data = makepicture(video.getvideoelement(),canvas); images.push_circular(data); timer.schedulerepeating(250); } }); anchor timely_moving = new anchor("stream (moving)"); timely_moving.addclickhandler( new clickhandler() { @override public void onclick(clickevent event) { final timer timer = new timer() { @override public void run() { string data = makepicture(video.getvideoelement(),canvas); images.push_shift(data); } }; anchor stop = new anchor("stop"); stop.getelement().getstyle().setcolor("red"); stop.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { timer.cancel(); popuppanel.hide(); } }); hp.clear(); hp.add(stop); hp.setcellhorizontalalignment(stop, hashorizontalalignment.align_center); video.getvideoelement().setwidth(tiles_w); video.getvideoelement().setheight(tiles_h); video.setsize(tiles_w + "px", tiles_h + "px"); popuppanel.center(); string data = makepicture(video.getvideoelement(),canvas); images.push_shift(data); timer.schedulerepeating(250); } }); hp.setwidth("100%"); hp.add(click); hp.setcellhorizontalalignment(click, hashorizontalalignment.align_left); hp.setcellwidth(click, "25%"); hp.add(timely_circular); hp.setcellhorizontalalignment(timely_circular, hashorizontalalignment.align_center); hp.setcellwidth(timely_circular, "25%"); hp.add(timely_moving); hp.setcellhorizontalalignment(timely_moving, hashorizontalalignment.align_center); hp.setcellwidth(timely_moving, "25%"); hp.add(close); hp.setcellhorizontalalignment(close, hashorizontalalignment.align_right); hp.setcellwidth(close, "25%"); vp.add(hp); popuppanel.setwidget(vp); popuppanel.center(); } }); } public void onfail() { window.alert("fail: please let me access camera"); } }; public class imagesstrip implements iswidget { private flowpanel panel = new flowpanel(); private arraylist<image> images = new arraylist<image>(); @override public widget aswidget() { return panel; } private int current = 0; private int len; private string width; private string height; public imagesstrip(int len, string w, string h) { this.len = len; this.width = w; this.height = h; } public void push_circular(string url) { int pos = current%len; if(images.size() <= pos) { image img = new image(); img.setsize(width, height); panel.add(img); images.add(img); } images.get(pos).seturl(url); current++; } public void push_shift(string url) { int pos = current%len; if(images.size() <= pos) { image img = new image(); img.setsize(width, height); panel.add(img); images.add(img); } if(current > len) { image img = images.get(pos); panel.remove(img); panel.add(img); } images.get(pos).seturl(url); current++; } } }
lines erros:
private flowpanel panel = new flowpanel();
and
images = new imagesstrip(nx*ny, tiles_w + "px", tiles_h + "px");
my gwt.xml
<?xml version="1.0" encoding="utf-8"?> <!doctype module public "-//google inc.//dtd google web toolkit 2.6.0//en" "http://google-web-toolkit.googlecode.com/svn/tags/2.6.0/distro-source/core/src/gwt-module.dtd"> <module rename-to='elementalgetusermediademo'> <!-- inherit core web toolkit stuff. --> <inherits name='com.google.gwt.user.user'/> <inherits name="elemental.elemental"/> <!-- inherit default gwt style sheet. can change --> <!-- theme of gwt application uncommenting --> <!-- 1 of following lines. --> <inherits name='com.google.gwt.user.theme.clean.clean'/> <!-- <inherits name='com.google.gwt.user.theme.standard.standard'/> --> <!-- <inherits name='com.google.gwt.user.theme.chrome.chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.dark'/> --> <!-- other module inherits --> <!-- specify app entry point class. --> <entry-point class='com.jooink.experiments.elementalgetusermedia.client.elementalgetusermediademo'/> <!-- specify paths translatable code --> <source path='client'/> </module>
my arguments:
-remoteui "${gwt_remote_ui_server_port}:${unique_id}" -startupurl elementalgetusermediademo.html -loglevel info -codeserverport 9997 -port 8888 -war c:\gwtdev\elementalgetusermediademo\war com.jooink.experiments.elementalgetusermedia.elementalgetusermediademo
can help? attention.
the root cause is
caused by: java.lang.indexoutofboundsexception: index: 11, size: 11
you have
private arraylist<image> images = new arraylist<image>();
images.get(11)
result in above error.
check images.get(pos)
calls in code. put size check before calling method shown below.
if(pos >= 0 && pos < images.size()){ images.get(pos); }
Comments
Post a Comment