MyFaces Core
  1. MyFaces Core
  2. MYFACES-3581

@EJB injection into a @ViewScoped bean causes CNFE

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.8
    • Fix Version/s: 2.0.15, 2.1.9
    • Component/s: None
    • Labels:
      None
    • Environment:
      Oracle JVM 1.7.04, Apache TomEE

      Description

      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)

      1. MYFACES-3581.patch
        2 kB
        David Blevins
      2. MYFACES-3581-2.patch
        2 kB
        Leonardo Uribe

        Activity

        Jonathan S Fisher created issue -
        David Blevins made changes -
        Field Original Value New Value
        Attachment MYFACES-3581.patch [ 12535536 ]
        Jonathan S Fisher made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Gerhard Petracek made changes -
        Assignee Leonardo Uribe [ lu4242 ]
        Leonardo Uribe made changes -
        Attachment MYFACES-3581-2.patch [ 12537675 ]
        Leonardo Uribe made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Fix Version/s 2.0.15 [ 12321753 ]
        Fix Version/s 2.1.9 [ 12321755 ]
        Resolution Fixed [ 1 ]
        Leonardo Uribe made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Leonardo Uribe
            Reporter:
            Jonathan S Fisher
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 48h
              48h
              Remaining:
              Remaining Estimate - 48h
              48h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development