[ 
https://issues.apache.org/jira/browse/TOMEE-4333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jonathan Gallimore resolved TOMEE-4333.
---------------------------------------
    Resolution: Fixed

> NotSerializableException with @Inject HttpServletRequest
> --------------------------------------------------------
>
>                 Key: TOMEE-4333
>                 URL: https://issues.apache.org/jira/browse/TOMEE-4333
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 10.0.0-M1, 9.1.3
>            Reporter: Jonathan Gallimore
>            Assignee: Jonathan Gallimore
>            Priority: Major
>             Fix For: 10.0.0-M2, 9.1.4
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Given this CDI Bean:
> @SessionScoped
> @Named
> public class MyPageBean implements Serializable {
>  @Inject private HttpServletRequest req;
> ... use the bean somewhere in EL
> }
> This will result in an exception when serializing the Session (For session
> replication or passivation): java.lang.RuntimeException:
> java.lang.RuntimeException: 
> [java.io|http://java.io/].NotSerializableException:
> org.apache.openejb.cdi.Proxys$ThreadLocalHandler
> From: [https://www.mail-archive.com/dev@tomee.apache.org/msg18097.html]
> Looking at the Proxys.java code, it contains a private static class called
> ThreadLocalHandler, that is indeed not Serializable. For fun, I made
> ThreadLocalHandler implement Serializable, but that just resulted in
> another error because ThreadLocalHandler contains a ThreadLocal field which
> is definitely not Serializable.
> ThreadLocalHandler for HttpServletRequest is invoked by
> TomcatWebappBuilder.setComponentsUsedByCDI():
> [https://github.com/apache/tomee/blob/tomee-8.x/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java#L358]
> I'm at a bit of a loss on how to fix this. My assumption is the
> ThreadLocalHandler was designed as a generic proxy object that defers to an
> internal ThreadLocal object. I wonder if marking the ThreadLocal as
> transient is sufficient, but I could use some input.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to