[jboss-user] [JBoss Seam] - Re: Error about ListDataModel?

jasonqzy do-not-reply at jboss.com
Wed May 9 06:25:58 EDT 2007


"jasonqzy" wrote : In the message example,I modify MessageManager.java MessageManagerBean.java message.jsp like following.
  | 
  | 
  | MessageManager.java
  | 
  |   | //$Id: MessageManager.java,v 1.2 2006/05/23 05:30:24 gavin Exp $
  |   | package org.jboss.seam.example.messages;
  |   | 
  |   | import javax.ejb.Local;
  |   | 
  |   | @Local
  |   | public interface MessageManager
  |   | {
  |   |    public String getTitle();
  |   |    public void setTitle(String title);
  |   |    public void findMessages();
  |   |    public void select();
  |   |    public void delete();
  |   |    public void destroy();
  |   | }
  |   | 
  | 
  | MessageManagerBean.java
  | 
  |   | //$Id: MessageManagerBean.java,v 1.7 2006/11/19 21:01:33 gavin Exp $
  |   | package org.jboss.seam.example.messages;
  |   | 
  |   | import static javax.persistence.PersistenceContextType.EXTENDED;
  |   | import static org.jboss.seam.ScopeType.SESSION;
  |   | 
  |   | import java.io.Serializable;
  |   | import java.util.List;
  |   | 
  |   | import javax.ejb.Remove;
  |   | import javax.ejb.Stateful;
  |   | import javax.persistence.EntityManager;
  |   | import javax.persistence.PersistenceContext;
  |   | 
  |   | import org.jboss.seam.annotations.Destroy;
  |   | import org.jboss.seam.annotations.Factory;
  |   | import org.jboss.seam.annotations.Name;
  |   | import org.jboss.seam.annotations.Out;
  |   | import org.jboss.seam.annotations.Scope;
  |   | import org.jboss.seam.annotations.datamodel.DataModel;
  |   | import org.jboss.seam.annotations.datamodel.DataModelSelection;
  |   | 
  |   | @Stateful
  |   | @Scope(SESSION)
  |   | @Name("messageManager")
  |   | public class MessageManagerBean implements Serializable, MessageManager
  |   | {
  |   | 
  |   |    private String title = "Test";
  |   | 
  |   |    @DataModel
  |   |    private List<Message> messageList;
  |   |    
  |   |    @DataModelSelection
  |   |    @Out(required=false)
  |   |    private Message message;
  |   |    
  |   |    @PersistenceContext(type=EXTENDED)
  |   |    private EntityManager em;
  |   |    
  |   |    @Factory("messageList")
  |   |    public void findMessages()
  |   |    {
  |   |       messageList = em.createQuery("select msg from Message msg order by msg.datetime desc").getResultList();
  |   |    }
  |   | 
  |   |    public String getTitle(){
  |   |       return title;
  |   |    }
  |   | 
  |   |    public void setTitle(String title){
  |   |       this.title = title;
  |   |    }
  |   |    
  |   |    public void select()
  |   |    {
  |   |       if (message!=null) message.setRead(true);
  |   |    }
  |   |    
  |   |    public void delete()
  |   |    {
  |   |       if (message!=null)
  |   |       {
  |   |          messageList.remove(message);
  |   |          em.remove(message);
  |   |          message=null;
  |   |       }
  |   |    }
  |   |    
  |   |    @Remove @Destroy
  |   |    public void destroy() {}
  |   | 
  |   | }
  |   | 
  | 
  | message.jsp
  | 
  |   | <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  |   | <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  |   | <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
  |   | <html>
  |   |  <head>
  |   |   <title>Messages</title>
  |   |  </head>
  |   |  <body>
  |   |   <f:view>
  |   |      <h2>Message List</h2>
  |   |      <h:outputText value="messageManager.title" />
  |   |      <h:outputText value="No messages to display" rendered="#{messageList.rowCount==0}"/>
  |   | 	 <h:dataTable var="msg" value="#{messageList}" rendered="#{messageList.rowCount>0}">
  |   |         <h:column>
  |   |            <f:facet name="header">
  |   |               <h:outputText value="Read"/>
  |   |            </f:facet>
  |   |            <h:selectBooleanCheckbox value="#{msg.read}" disabled="true"/>
  |   |         </h:column>
  |   |         <h:column>
  |   |            <f:facet name="header">
  |   |               <h:outputText value="Title"/>
  |   |            </f:facet>
  |   |            <s:link value="#{msg.title}" action="#{messageManager.select}"/>
  |   |         </h:column>
  |   |         <h:column>
  |   |            <f:facet name="header">
  |   |               <h:outputText value="Date/Time"/>
  |   |            </f:facet>
  |   |            <h:outputText value="#{msg.datetime}">
  |   |               <s:convertDateTime type="both" dateStyle="medium" timeStyle="short"/>
  |   |            </h:outputText>
  |   |         </h:column>
  |   |         <h:column>
  |   |            <s:button value="Delete" action="#{messageManager.delete}"/>
  |   |         </h:column>
  |   |      </h:dataTable>
  |   |      <h3><h:outputText value="#{message.title}"/></h3>
  |   |      <div><h:outputText value="#{message.text}"/></div>
  |   |   </f:view>
  |   |  </body>
  |   | </html>
  |   | 
  | 
  | When I delete the last message of the message list,I get the error.
  | 
  |   | 18:16:55,984 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
  |   | javax.faces.el.EvaluationException: Cannot get value for expression '#{messageManager.title}'
  |   | 	at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:402)
  |   | 	at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
  |   | 	at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
  |   | 	at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:69)
  |   | 	at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:57)
  |   | 	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
  |   | 	at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:495)
  |   | 	at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:363)
  |   | 	at org.apache.jsp.messages_jsp._jspx_meth_h_outputText_0(messages_jsp.java:172)
  |   | 	at org.apache.jsp.messages_jsp._jspx_meth_f_view_0(messages_jsp.java:126)
  |   | 	at org.apache.jsp.messages_jsp._jspService(messages_jsp.java:91)
  |   | 	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  |   | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  |   | 	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
  |   | 	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  |   | 	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  |   | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  |   | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |   | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |   | 	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
  |   | 	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
  |   | 	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
  |   | 	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
  |   | 	at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
  |   | 	at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
  |   | 	at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
  |   | 	at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
  |   | 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
  |   | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |   | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |   | 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |   | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |   | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |   | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  |   | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  |   | 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  |   | 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  |   | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |   | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |   | 	at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  |   | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  |   | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  |   | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  |   | 	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  |   | 	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |   | 	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |   | 	at java.lang.Thread.run(Thread.java:619)
  |   | Caused by: javax.faces.el.EvaluationException: Exception getting value of property title of base of type : org.javassist.tmp.java.lang.Object_$$_javassist_1
  |   | 	at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:96)
  |   | 	at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532)
  |   | 	at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
  |   | 	at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
  |   | 	... 46 more
  |   | Caused by: javax.faces.el.EvaluationException: Bean: org.javassist.tmp.java.lang.Object_$$_javassist_1, property: title
  |   | 	at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442)
  |   | 	at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82)
  |   | 	... 49 more
  |   | Caused by: java.lang.reflect.InvocationTargetException
  |   | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |   | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |   | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |   | 	at java.lang.reflect.Method.invoke(Method.java:597)
  |   | 	at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438)
  |   | 	... 50 more
  |   | Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: row is unavailable
  |   | 	at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
  |   | 	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
  |   | 	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
  |   | 	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:203)
  |   | 	at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
  |   | 	at $Proxy94.getTitle(Unknown Source)
  |   | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |   | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |   | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |   | 	at java.lang.reflect.Method.invoke(Method.java:597)
  |   | 	at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
  |   | 	at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
  |   | 	at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
  |   | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
  |   | 	at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
  |   | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |   | 	at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
  |   | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |   | 	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
  |   | 	at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
  |   | 	at org.javassist.tmp.java.lang.Object_$$_javassist_1.getTitle(Object_$$_javassist_1.java)
  |   | 	... 55 more
  |   | Caused by: java.lang.IllegalArgumentException: row is unavailable
  |   | 	at javax.faces.model.ListDataModel.getRowData(ListDataModel.java:63)
  |   | 	at org.jboss.seam.databinding.DataModelBinder.getSelection(DataModelBinder.java:69)
  |   | 	at org.jboss.seam.databinding.DataModelBinder.getSelection(DataModelBinder.java:19)
  |   | 	at org.jboss.seam.Component.injectDataModelSelection(Component.java:1274)
  |   | 	at org.jboss.seam.Component.injectDataModelSelections(Component.java:1254)
  |   | 	at org.jboss.seam.Component.inject(Component.java:1196)
  |   | 	at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
  |   | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |   | 	at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
  |   | 	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
  |   | 	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
  |   | 	at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
  |   | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  |   | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  |   | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  |   | 	at java.lang.reflect.Method.invoke(Method.java:597)
  |   | 	at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
  |   | 	at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:71)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
  |   | 	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |   | 	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
  |   | 	... 86 more
  |   | 
  | 
  | But WhenI delete other message,it's normal. Why?[/url]

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044228#4044228

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044228



More information about the jboss-user mailing list