java.lang.IllegalArgumentException: PWC2788: setAttribute: Non-serializable attribute with name scopedTarget.org.springframework.security.oauth2.client.cont ext.DefaultOAuth2ClientContext#0

Spring JIRA | Julien Gerlier | 4 years ago
  1. 0

    When a client obtains an OAuth2AccessToken using Spring Security OAuth2 client filter, this token is encapsulated in a OAuth2ClientContext. This interface is implemented by the DefaultOAuth2ClientContext class. However neither the interface nor the class implements Serializable. After obtaining the access token, the client filter persists the oAuth2ClientContext as a session attribute. Therefore it must be serializable, according to the servlet specification. Thus I obtain this stacktrace in Tomcat 6 when stopping then starting the server : Caused by: java.io.NotSerializableException: org.springframework.security.oauth2.client.context.DefaultOAuth2ClientContext at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1585) at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1015) at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:528) at org.apache.catalina.session.StandardManager.unload(StandardManager.java:469) at org.apache.catalina.session.StandardManager.stop(StandardManager.java:678) at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4882) at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:936) at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1359) at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1330) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:326) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098) at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1110) at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:468) at org.apache.catalina.core.StandardService.stop(StandardService.java:604) at org.apache.catalina.core.StandardServer.stop(StandardServer.java:788) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416) This is even more blocking in Glassfish, because an error occurs when setting the OAuth2AccessToken in the session : Exception occured in doFilter() method java.lang.IllegalArgumentException: PWC2788: setAttribute: Non-serializable attribute with name scopedTarget.org.springframework.security.oauth2.client.cont ext.DefaultOAuth2ClientContext#0 at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1695) at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:179) at org.springframework.web.context.request.ServletRequestAttributes.setAttribute(ServletRequestAttributes.java:133) at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:44) at org.springframework.web.context.request.SessionScope.get(SessionScope.java:92) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182) at $Proxy120.getAccessToken(Unknown Source) at org.springframework.security.oauth2.client.OAuth2RestTemplate.getAccessToken(OAuth2RestTemplate.java:165)

    Spring JIRA | 4 years ago | Julien Gerlier
    java.lang.IllegalArgumentException: PWC2788: setAttribute: Non-serializable attribute with name scopedTarget.org.springframework.security.oauth2.client.cont ext.DefaultOAuth2ClientContext#0
  2. 0

    When a client obtains an OAuth2AccessToken using Spring Security OAuth2 client filter, this token is encapsulated in a OAuth2ClientContext. This interface is implemented by the DefaultOAuth2ClientContext class. However neither the interface nor the class implements Serializable. After obtaining the access token, the client filter persists the oAuth2ClientContext as a session attribute. Therefore it must be serializable, according to the servlet specification. Thus I obtain this stacktrace in Tomcat 6 when stopping then starting the server : Caused by: java.io.NotSerializableException: org.springframework.security.oauth2.client.context.DefaultOAuth2ClientContext at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) at java.io.ObjectOutputStream.writeSerialData(Unknown Source) at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.writeObject(Unknown Source) at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1585) at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1015) at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:528) at org.apache.catalina.session.StandardManager.unload(StandardManager.java:469) at org.apache.catalina.session.StandardManager.stop(StandardManager.java:678) at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4882) at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:936) at org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1359) at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1330) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:326) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098) at org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1110) at org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:468) at org.apache.catalina.core.StandardService.stop(StandardService.java:604) at org.apache.catalina.core.StandardServer.stop(StandardServer.java:788) at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:408) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416) This is even more blocking in Glassfish, because an error occurs when setting the OAuth2AccessToken in the session : Exception occured in doFilter() method java.lang.IllegalArgumentException: PWC2788: setAttribute: Non-serializable attribute with name scopedTarget.org.springframework.security.oauth2.client.cont ext.DefaultOAuth2ClientContext#0 at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1695) at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:179) at org.springframework.web.context.request.ServletRequestAttributes.setAttribute(ServletRequestAttributes.java:133) at org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:44) at org.springframework.web.context.request.SessionScope.get(SessionScope.java:92) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182) at $Proxy120.getAccessToken(Unknown Source) at org.springframework.security.oauth2.client.OAuth2RestTemplate.getAccessToken(OAuth2RestTemplate.java:165)

    Spring JIRA | 4 years ago | Julien Gerlier
    java.lang.IllegalArgumentException: PWC2788: setAttribute: Non-serializable attribute with name scopedTarget.org.springframework.security.oauth2.client.cont ext.DefaultOAuth2ClientContext#0
  3. 0

    Pet clinic - Find Ownerss tab - Error setAttribute: Non-serializable attribute with name owner

    GitHub | 2 years ago | tuma80
    java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute with name owner
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute

    Stack Overflow | 8 years ago
    java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
  6. 0

    setAttribute: Non-serializable attribute with name loginMgmtBean

    Stack Overflow | 1 year ago | arienn
    java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute with name loginMgmtBean

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      PWC2788: setAttribute: Non-serializable attribute with name scopedTarget.org.springframework.security.oauth2.client.cont ext.DefaultOAuth2ClientContext#0

      at org.apache.catalina.session.StandardSession.setAttribute()
    2. Glassfish Core
      StandardSessionFacade.setAttribute
      1. org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1695)
      2. org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:179)
      2 frames
    3. Spring
      SessionScope.get
      1. org.springframework.web.context.request.ServletRequestAttributes.setAttribute(ServletRequestAttributes.java:133)
      2. org.springframework.web.context.request.AbstractRequestAttributesScope.get(AbstractRequestAttributesScope.java:44)
      3. org.springframework.web.context.request.SessionScope.get(SessionScope.java:92)
      3 frames
    4. Spring Beans
      AbstractBeanFactory.getBean
      1. org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)
      2. org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      2 frames
    5. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
      2 frames
    6. Unknown
      $Proxy120.getAccessToken
      1. $Proxy120.getAccessToken(Unknown Source)
      1 frame
    7. OAuth2 for Spring Security
      OAuth2RestTemplate.getAccessToken
      1. org.springframework.security.oauth2.client.OAuth2RestTemplate.getAccessToken(OAuth2RestTemplate.java:165)
      1 frame