You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by immutability <de...@bielik.org> on 2009/06/12 12:42:18 UTC

T5.1: Palette causing a NPE upon form submit

I've been trying to figure this out for a few hours.... I've got a strange
issue with the Palette component causing a NullPointerException upon form
submit, but only on form failure involving server-side validator's such as
the email validator (i.e. the form is submitted - onSubmit called but
onSuccess not called due to errors, and <t:errors /> are displayed). I'm
using Tapestry 5.1.0.5

Background: I'm using Palette within a BeanEditForm when editing a User
instance to edit a list of groups (List<Group>) to which the user belongs (a
many-to-many relationship - I'm using Spring + Hibernate). The NPE is only
thrown when submitting form with errors that are not catched by the JS
validators, and are processed on the server, such as the email validator.
Also, the NPE is only thrown if there are some groups on the "selected"
side. Here's the first line from the stack trace:

Render queue error in
org.apache.tapestry5.internal.structure.RenderPhaseEventHandler$1@79a340:
java.lang.NullPointerException

Here's the palette declaration:

<t:palette t:id="groups" selected="user.groups" encoder="selectGroups"
model="selectGroups" />

The user instance is persisted in the page class, and is initially populated
in onActivate:

	@Property
	@Persist
	private User user;

The selectGroups property, which is used for both model and encoder, is
initialized in page's onPrepare with each request. It is a
GenericSelectModel instance.

That said, the palette component works properly almost all the time. When I
edit a user instance, set all fields, select the groups and save, it all
works. It only fails with the NPE when I leave out the email field, causing
the server-side validation to display an error in <t:errors />. I've tried
to add logger statements to the getter for selectGroups, and whenever it is
actually called, both the selectGroups collection and user.groups
collections are non-null and properly populated. So I have no idea what
might be causing the NPE?

Any hints are highly appreciated! Below is a longer snippet from the stack
trace.

Thanks,
Rado




STACK TRACE:

12:35:34,081 ERROR Account:84 - Render queue error in
org.apache.tapestry5.internal.structure.RenderPhaseEventHandler$1@c7014c:
java.lang.NullPointerException
java.lang.NullPointerException
	at
org.apache.tapestry5.internal.util.SelectModelRenderer.option(SelectModelRenderer.java:49)
	at
org.apache.tapestry5.corelib.components.Palette$SelectedRenderer.render(Palette.java:153)
	at
org.apache.tapestry5.internal.structure.RenderPhaseEventHandler$1.render(RenderPhaseEventHandler.java:75)
	at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:74)
	at
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:121)
	at $PageRenderQueue_121d408df33.render($PageRenderQueue_121d408df33.java)
	at $PageRenderQueue_121d408df29.render($PageRenderQueue_121d408df29.java)
	at
org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
	at
org.apache.tapestry5.services.TapestryModule$27.renderMarkup(TapestryModule.java:1748)
	at
$MarkupRenderer_121d408df35.renderMarkup($MarkupRenderer_121d408df35.java)
	at
org.apache.tapestry5.services.TapestryModule$26.renderMarkup(TapestryModule.java:1732)
	at
$MarkupRenderer_121d408df35.renderMarkup($MarkupRenderer_121d408df35.java)
	at
org.apache.tapestry5.services.TapestryModule$25.renderMarkup(TapestryModule.java:1714)
	at
$MarkupRenderer_121d408df35.renderMarkup($MarkupRenderer_121d408df35.java)
	at
org.apache.tapestry5.services.TapestryModule$24.renderMarkup(TapestryModule.java:1700)
	at
$MarkupRenderer_121d408df35.renderMarkup($MarkupRenderer_121d408df35.java)
	at
org.apache.tapestry5.services.TapestryModule$23.renderMarkup(TapestryModule.java:1681)
	at
$MarkupRenderer_121d408df35.renderMarkup($MarkupRenderer_121d408df35.java)
	at
org.apache.tapestry5.services.TapestryModule$22.renderMarkup(TapestryModule.java:1662)
	at
$MarkupRenderer_121d408df35.renderMarkup($MarkupRenderer_121d408df35.java)
	at
$MarkupRenderer_121d408df32.renderMarkup($MarkupRenderer_121d408df32.java)
	at
org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:64)
	at
$PageMarkupRenderer_121d408df2f.renderPageMarkup($PageMarkupRenderer_121d408df2f.java)
	at
org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:61)
	at
$PageResponseRenderer_121d408dea6.renderPageResponse($PageResponseRenderer_121d408dea6.java)
	at
org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:63)
	at
org.apache.tapestry5.services.TapestryModule$33.handle(TapestryModule.java:1943)
	at
$PageRenderRequestHandler_121d408dea7.handle($PageRenderRequestHandler_121d408dea7.java)
	at
$PageRenderRequestHandler_121d408de90.handle($PageRenderRequestHandler_121d408de90.java)
	at
org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handlePageRender(ComponentRequestHandlerTerminator.java:48)
	at
$ComponentRequestHandler_121d408de94.handlePageRender($ComponentRequestHandler_121d408de94.java)
	at
org.apache.tapestry5.internal.services.PageRenderDispatcher.dispatch(PageRenderDispatcher.java:45)
	at $Dispatcher_121d408de96.dispatch($Dispatcher_121d408de96.java)
	at $Dispatcher_121d408de8a.dispatch($Dispatcher_121d408de8a.java)
	at
org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:245)
	...
	...
	...
-- 
View this message in context: http://www.nabble.com/T5.1%3A-Palette-causing-a-NPE-upon-form-submit-tp23996561p23996561.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5.1: Palette causing a NPE upon form submit

Posted by immutability <de...@bielik.org>.
Found the cause of this issue - after a painful search... :) It was my
mistake.

For anyone running into the same issue with NullPointerException and Palette
component, if you want to use the Palette component with objects (e.g. list
of domain objects returned from a database) remember to implement equals and
hashCode properly.

The issue also was not related to the server-side validators in any way. It
simply occurs when the page containing the Palette component needs to render
itself after processing a server-side event. So if such an event (e.g.
onSuccess) returns another page instance (effectively resulting in a
redirect after processing the event) no problems will occur. But if it
returns null, and at the same time some items are on the selected side
within the Palette, the NullPointerException will be thrown.

Rado
-- 
View this message in context: http://www.nabble.com/T5.1%3A-Palette-causing-a-NPE-upon-form-submit-tp23996561p24061989.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org