[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2836) seam-gen WAR release test throws EntityNotFoundException when creating vehicle

Dan Allen (JIRA) jira-events at lists.jboss.org
Fri Apr 25 19:16:08 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBSEAM-2836?page=comments#action_12410818 ] 
            
Dan Allen commented on JBSEAM-2836:
-----------------------------------

I can now perfectly explain why the exception is being swallowed. Let's step through the logic.

1) why the exception?

In the render response phase, if initInstance() is called (which is called both by getInstance() and isManaged()), it should throw an EntityNotFoundException if isIdDefined() returns true and the EntityManager cannot locate a record for that id.

2) why is is swallowed?

After much research, I have determined that the exception is only swallowed when RichFaces is on the classpath. RichFaces uses a phase listener (DataScrollerViewPhaseListener) that executes logic in beginPhase() method for the RENDER_RESPONSE phase. In this method, it walks the component tree, calling isRendered() on each component. That triggers the exception when it hits a component that uses isManaged() in the rendered attribute.

So we look at JSF and figure out when the phase listeners are called during render response. That is handled by the method UIViewRoot#notifyPhaseListeners(). If you look at this method (line 783), you will see 2 places where an exception is caught and swallowed with the note "// PENDING(edburns): log this". Clearly, edburns has some work to do.

https://mojarra.dev.java.net/source/browse/*checkout*/mojarra/trunk/jsf-api/src/javax/faces/component/UIViewRoot.java?rev=4769

3) why isn't the exception thrown after that?

Once the exception is thrown, Seam's TransactionInterceptor sets the transaction to rollback. Once the transaction is in rollback state, the initInstance() method stops trying to retrieve the instance if it is null. So the editor form renders, but it isn't bound to anything (pressing Save verifies the bad state).

SOLUTION:

First and foremost, we need to eagerly run getInstance() in the wire() method of Home. That saves our ass. But I feel that we need to get Ed Burns to finish the work on the notifyPhaseListeners() method because swallowing an exception like that is dangerous as hell! Shit, don't they run Java lint on that code base?

> seam-gen WAR release test throws EntityNotFoundException when creating vehicle
> ------------------------------------------------------------------------------
>
>                 Key: JBSEAM-2836
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2836
>             Project: Seam
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 2.0.2.CR1
>            Reporter: Jay Balunas
>            Priority: Critical
>             Fix For: 2.0.2.CR2
>
>
> Create a seam-gen WAR based application following the instructions from the release-process.txt.  Including reverse engineering the provided MySQL tables.  Deploy to JBoss 4.2.2.GA.
> Select the Vehicle list link, and click the "create vehicle" button and get the error below in the logs and a JSF error page.  You can create a vehicle through the "add vehicle" option of the users page.  When I ran the same test though JBDS there was no issue.  I double checked the seam-gen version (recreated, and deployed) and had the same issue.
> 10:09:38,675 ERROR [STDERR] Apr 3, 2008 10:09:38 AM com.sun.facelets.FaceletViewHandler handleRenderException
> SEVERE: Error Rendering View[/VehicleEdit.xhtml]
> javax.el.ELException: /VehicleEdit.xhtml: Error reading 'managed' on type org.jboss.seam.release.action.VehicleHome_$$_javassist_6
>         at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:48)
>         at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
>         at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280)
>         at org.richfaces.renderkit.html.PanelRenderer.doEncodeBegin(PanelRenderer.java:168)
>         at org.richfaces.renderkit.html.PanelRenderer.doEncodeBegin(PanelRenderer.java:128)
>         at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:101)
>         at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
>         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
>         at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
>         at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
>         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
>         at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
>         at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
>         at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
>         at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
>         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
>         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
>         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
>         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
>         at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
>         at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
>         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
>         at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
>         at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
>         at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
>         at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
>         at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
>         at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
>         at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
>         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
>         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>         at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
>         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: org.jboss.seam.framework.EntityNotFoundException: entity not found: org.jboss.seam.release.model.Vehicle#org.jboss.seam.release.model.VehicleId at 5ae9
>         at org.jboss.seam.framework.Home.handleNotFound(Home.java:185)
>         at org.jboss.seam.framework.EntityHome.find(EntityHome.java:128)
>         at org.jboss.seam.framework.Home.initInstance(Home.java:155)
>         at org.jboss.seam.framework.Home.getInstance(Home.java:121)
>         at org.jboss.seam.framework.EntityHome.isManaged(EntityHome.java:43)
>         at sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
>         at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
>         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
>         at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
>         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>         at org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
>         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>         at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
>         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>         at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
>         at org.jboss.seam.util.Work.workInTransaction(Work.java:41)
>         at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
>         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>         at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
>         at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
>         at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
>         at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
>         at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
>         at org.jboss.seam.release.action.VehicleHome_$$_javassist_6.isManaged(VehicleHome_$$_javassist_6.java)
>         at sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
>         at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
>         at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
>         at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
>         at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
>         at org.jboss.el.parser.AstChoice.getValue(AstChoice.java:27)
>         at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
>         at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
>         at com.sun.facelets.el.ELText$ELTextComposite.writeText(ELText.java:108)
>         at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
>         ... 55 more

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list