you have a thread that is running unsynchronized! and updating the model of the component.
we synchronize on the session for you so the code inside components you write does not have to be threadsafe. your TestModelUpdater breaks that.
so the listview maybe rendering and looping over its model WHILE your thread adds another item to the list! that can cause all sorts of weird things.
long story short, you cannot have a run away thread updating wicket components or their models. its not meant for that.
-Igor
On 3/2/06,
Igor Vaynberg <[EMAIL PROTECTED]> wrote:
here is what i am getting after a minute or so
interesting
-Igor
18:09:06.263 WARN!! Exception for /quickstart/app?wicket:interface=:3:wmc:-1:IUnversionedBehaviorListener&wicket:behaviorId=0&random= 0.46824654938259036
wicket.WicketRuntimeException: Internal Error: Could not render error page class wicket.markup.html.pages.InternalErrorPageat wicket.request.compound.DefaultExceptionResponseStrategy.respond (DefaultExceptionResponseStrategy.java:106)
at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(AbstractCompoundRequestCycleProcessor.java:76)
at wicket.RequestCycle.step(RequestCycle.java :971)
at wicket.RequestCycle.steps(RequestCycle.java:1005)
at wicket.RequestCycle.request(RequestCycle.java:451)at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:209)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:358)
at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch (WebApplicationHandler.java:294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
at org.mortbay.jetty.servlet.WebApplicationContext.handle (WebApplicationContext.java:525)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java :790)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:961)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java :218)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:300)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)Caused by: java.lang.ClassCastException: wicket.ajax.AjaxRequestTarget$EncodingResponse
at wicket.protocol.http.WebRequestCycle.getWebResponse(WebRequestCycle.java:99)
at wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:130)
at wicket.request.target.component.PageRequestTarget.respond (PageRequestTarget.java:60)at wicket.request.compound.DefaultResponseStrategy.respond(DefaultResponseStrategy.java:47)
at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond (AbstractCompoundRequestCycleProcessor.java :66)at wicket.RequestCycle.respond(RequestCycle.java:877)
at wicket.RequestCycle.step(RequestCycle.java:946)
... 18 moreOn 3/2/06, Ramnivas Laddad <[EMAIL PROTECTED]> wrote:Sending again. Sourceforge is rejecting .zip attachment, so please change extension of the attached file to .zip.
-Ramnivas
===
Here it is... (removed lib/*.jar to cut down size).
-Ramnivas
Igor Vaynberg wrote:any chance you can stick those two files into a quickstart project?
-Igor
On 3/2/06, Ramnivas Laddad < [EMAIL PROTECTED]> wrote:Hi,
I now have an AJAXified listview working. However, occasionally (very
frequently on a real application and less frequently on a simplified
application :-() it crashes (program and stack trace at the end of this
email).
I have an updater thread that adds new entries to the model for the
listview.
A few observations:
1. In the onRender() method, size returned by getViewSize() is 1, and
the index of the item to be rendered is 1. This all seems correct, as
the updater thread has just added a new item. However, item returned by
(ListItem)get(Integer.toString(index)) is null.
2. When the crashed view is re-rendered, I do no see the following
snippet in markup produced:
<script language="_javascript_"
type="text/_javascript_"
src=""> </script>
As a result, no AJAX updates take place.
While it seems to be concurrency-related bug, the model itself as I have
written seems thread-safe.
Thanks.
-Ramnivas
Source code:
==========
public class AJAXListHome extends WebPage {
public AJAXListHome() {
TestModel model = new TestModel();
WebMarkupContainer wmc = new WebMarkupContainer("wmc");
add(wmc);
ListView testListView = new TestListView("dates", model);
wmc.add(testListView);
wmc.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)));
new Thread(new TestModelUpdater(model, testListView)).start();
}
}
class TestListView extends ListView {
public TestListView(String id, TestModel model) {
super(id, model);
}
@Override
protected void populateItem(ListItem item) {
String date = (String)item.getModelObject();
item.add(new Label("date", date));
}
}
class TestModel implements IModel {
private List<String> underlying = new ArrayList<String>();
synchronized public Object getObject(Component component) {
return underlying;
}
synchronized public void add(String message) {
underlying.add(message);
}
public IModel getNestedModel() {
return null;
}
public void setObject(Component component, Object object) {
}
public void detach() {
}
}
class TestModelUpdater implements Runnable {
private TestModel model;
private Component view;
static int counter = 0;
public TestModelUpdater(TestModel model, Component view) {
this.model = model;
this.view = view;
}
public void run() {
while(true) {
model.add("string" + counter);
// notifying model doesn't seem to be required; should it
be notified?
// view.modelChanged();
counter++;
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException ignored) {
}
}
}
}
===
Stack trace:
Root cause:
java.lang.NullPointerException
at wicket.markup.html.list.ListView.renderItem(ListView.java:606)
at wicket.markup.html.list.ListView.onRender(ListView.java :567)
at wicket.Component.render(Component.java:1516)
at wicket.MarkupContainer.renderNext(MarkupContainer.java:1206)
at wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:875)
at wicket.MarkupContainer.onComponentTagBody (MarkupContainer.java:795)
at wicket.Component.renderComponent(Component.java:1602)
at wicket.MarkupContainer.onRender(MarkupContainer.java:805)
at wicket.Component.render(Component.java:1516)
at wicket.MarkupContainer.renderNext (MarkupContainer.java:1206)
at wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:875)
at wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:795)
at wicket.Component.renderComponent(Component.java :1602)
at wicket.MarkupContainer.onRender(MarkupContainer.java:805)
at wicket.Component.render(Component.java:1516)
at wicket.MarkupContainer.renderNext(MarkupContainer.java:1206)
at wicket.MarkupContainer.renderAll (MarkupContainer.java:822)
at wicket.Page.onRender(Page.java:846)
at wicket.Component.render(Component.java:1516)
at wicket.Page.doRender(Page.java:390)
at
wicket.request.target.component.BookmarkablePageRequestTarget.respond (BookmarkablePageRequestTarget.java:224)
at
wicket.request.compound.DefaultResponseStrategy.respond(DefaultResponseStrategy.java:47)
at
wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(AbstractCompoundRequestCycleProcessor.java :66)
at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:824)
at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:851)
at wicket.RequestCycle.step(RequestCycle.java:931)
at wicket.RequestCycle.steps (RequestCycle.java:1005)
at wicket.RequestCycle.request(RequestCycle.java:451)
at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:208)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:358)
at
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java :294)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1807)
at
org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java :525)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1757)
at org.mortbay.http.HttpServer.service(HttpServer.java:879)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:790)
at org.mortbay.http.HttpConnection.handleNext (HttpConnection.java:961)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:807)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:218)
at org.mortbay.util.ThreadedServer.handle( ThreadedServer.java:300)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:511)
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user