myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3581) @EJB injection into a @ViewScoped bean causes CNFE
Date Mon, 23 Jul 2012 15:49:36 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-3581?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420726#comment-13420726
] 

Leonardo Uribe commented on MYFACES-3581:
-----------------------------------------

It could be good to know the exact lines, to keep them as reference. Checking again the stack
trace, I can see that resolveClass() is not called in this case, and instead resolveProxyClass()
is called. Sounds like a not common use case but valid. Anyway, the patch is incomplete, because
it does follow the protocol used in ClassUtils.classForName(), which is try to resolve the
class using the context classloader and then use the class classloader. Still need some work
and a justification about when it happens, but now sounds more reasonable.
                
> @EJB injection into a @ViewScoped bean causes CNFE
> --------------------------------------------------
>
>                 Key: MYFACES-3581
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3581
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.1.8
>         Environment: Oracle JVM 1.7.04, Apache TomEE
>            Reporter: Jonathan S Fisher
>            Assignee: Leonardo Uribe
>         Attachments: MYFACES-3581.patch
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> If you have a ViewScoped ManagedBean, @EJB injection appears to fail when an ajax request
is submitted. This may be because the MyFacesObjectInputStream is not using the context class
loader.
> See original bug report here: http://stackoverflow.com/questions/11371573/jsf2-0-ejb-injection-into-viewscoped-causing-myfaces-to-cfne/11371846#11371846
> @ManagedBean
> @ViewScoped
> public class BlogMB implements Serializable {
>     private static final long serialVersionUID = 1L;
>     @EJB
>     private CategoryService categoryService;
> }
> Here's the view code:
> <h:commandLink value="#{category.name}">
>     <f:setPropertyActionListener
>         target="#{blogMB.selectedCategory}"
>         value="#{category}" />
>     <f:ajax
>         listener="#{blogMB.filterPostsByCategory()}"
>         execute="@this"
>         render=":blogPosts" />
> </h:commandLink>
> This will cause the following exception:
> Jul 06, 2012 8:25:51 PM org.apache.myfaces.renderkit.ServerSideStateCacheImpl deserializeView
> SEVERE: Exiting deserializeView - Could not deserialize state: com.xxx.blog.service.CategoryService
> java.lang.ClassNotFoundException: com.xxx.blog.service.CategoryService
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:264)
>     at java.io.ObjectInputStream.resolveProxyClass(ObjectInputStream.java:694)
>     at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1549)
>     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1511)
>     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
>     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>     at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
>     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
>     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>     at java.util.HashMap.readObject(HashMap.java:1043)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:601)
>     at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
>     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
>     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>     at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1685)
>     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1341)
>     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>     at java.util.HashMap.readObject(HashMap.java:1043)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:601)
>     at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1004)
>     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
>     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
>     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
>     at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1685)
>     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1341)
>     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
>     at org.apache.myfaces.renderkit.ServerSideStateCacheImpl.deserializeView(ServerSideStateCacheImpl.java:497)
>     at org.apache.myfaces.renderkit.ServerSideStateCacheImpl.getSerializedViewFromServletSession(ServerSideStateCacheImpl.java:289)
>     at org.apache.myfaces.renderkit.ServerSideStateCacheImpl.restoreSerializedView(ServerSideStateCacheImpl.java:891)
>     at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getState(HtmlResponseStateManager.java:205)
>     at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.restoreView(DefaultFaceletsStateManagementStrategy.java:207)
>     at org.apache.myfaces.application.StateManagerImpl.restoreView(StateManagerImpl.java:130)
>     at org.apache.myfaces.shared.view.ViewDeclarationLanguageBase.restoreView(ViewDeclarationLanguageBase.java:106)
>     at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.restoreView(FaceletViewDeclarationLanguage.java:2109)
>     at org.apache.myfaces.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:300)
>     at com.ocpsoft.pretty.faces.application.PrettyViewHandler.restoreView(PrettyViewHandler.java:109)
>     at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:83)
>     at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:127)
>     at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
>     at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
>     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>     at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>     at org.omnifaces.filter.GzipResponseFilter.doFilter(GzipResponseFilter.java:147)
>     at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
>     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
>     at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
>     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
>     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
>     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
>     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
>     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
>     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
>     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
>     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
>     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>     at java.lang.Thread.run(Thread.java:722)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message