Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我最近升级到Spring Security 4.2.3.RELEASE.我也在使用spymemcached v 2.8.4.我遇到了这种情况,由于某些原因,Spring正在尝试序列化服务实现类.我无法弄清楚这是从哪里来的.异常引用的代码行是Set<Session> userSessions = (Set<Session>) memca

我最近升级到Spring Security 4.2.3.RELEASE.我也在使用spymemcached v 2.8.4.我遇到了这种情况,由于某些原因,Spring正在尝试序列化服务实现类.我无法弄清楚这是从哪里来的.异常引用的代码行是

Set

带着神秘的错误(“java.io.NotSerializableException:org.mainco.subco.ecom.service.ContractServiceImpl”被埋在里面)……

09:06:47,771 ERROR [io.undertow.request] (default task-58) UT005023: Exception handling request to /myproject/registration/save: java.lang.IllegalArgumentException: Non-serializable object    at net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(BaseSerializingTranscoder.java:110)    at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:162)    at net.spy.memcached.MemcachedClIEnt.asyncStore(MemcachedClIEnt.java:282)    at net.spy.memcached.MemcachedClIEnt.set(MemcachedClIEnt.java:733)    at net.spy.memcached.MemcachedClIEnt.set(MemcachedClIEnt.java:126)    at org.mainco.subco.session.service.MemcachedSessionService.associateUser(MemcachedSessionService.java:365)    at org.mainco.subco.session.service.MemcachedSessionService.setSessionSecurityContext(MemcachedSessionService.java:288)    at org.mainco.subco.core.security.SubcoSecurityContextRepository.saveContext(subcoSecurityContextRepository.java:116)    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:114)    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)    at org.springframework.web.filter.CharacterEnCodingFilter.doFilterInternal(CharacterEnCodingFilter.java:197)    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)    at io.undertow.servlet.handlers.ServletdispatchingHandler.handleRequest(ServletdispatchingHandler.java:36)    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.servlet.handlers.security.SSLinformationAssociationHandler.handleRequest(SSLinformationAssociationHandler.java:131)    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.security.handlers.AbstractConfIDentialityHandler.handleRequest(AbstractConfIDentialityHandler.java:46)    at io.undertow.servlet.handlers.security.ServletConfIDentialityConstraintHandler.handleRequest(ServletConfIDentialityConstraintHandler.java:64)    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at org.wildfly.extension.undertow.security.jacc.JACCContextIDHandler.handleRequest(JACCContextIDHandler.java:61)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.servlet.handlers.ServletinitialHandler.handleFirstRequest(ServletinitialHandler.java:284)    at io.undertow.servlet.handlers.ServletinitialHandler.dispatchRequest(ServletinitialHandler.java:263)    at io.undertow.servlet.handlers.ServletinitialHandler.accessmemcachedClIEnt.set(userID,userSessions);0(ServletinitialHandler.java:81)    at io.undertow.servlet.handlers.ServletinitialHandler.handleRequest(ServletinitialHandler.java:174)    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:198)    at io.undertow.server.httpServerExchange.run(httpServerExchange.java:784)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)    at java.lang.Thread.run(Thread.java:745)Caused by: java.io.NotSerializableException: org.mainco.subco.ecom.service.ContractServiceImpl    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)    at java.io.ObjectOutputStream.defaultWriteFIElds(ObjectOutputStream.java:1548)    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)    at java.io.ObjectOutputStream.defaultWriteFIElds(ObjectOutputStream.java:1548)    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)

我如何弄清楚memcache正在尝试序列化的对象,从而弄清楚它是如何引用服务类来序列化的?

这个问题的关键不在于我如何使我的服务类可序列化,但为什么我的会话试图首先序列化它.

最佳答案

I’m running into this situation where for some reason Spring is trying to serialize service implementation classes.

spring不要尝试序列化实现.

你做的时候看起来很精简

int count=0;for(Session session: userSessions ){    log....    boolean isSerializable = checkIfSerializable(session);    count=isSerializable ? count+1 : count;    log }private static boolean checkIfSerializable(Object value) throws illegalaccessexception {    try {        ByteArrayOutputStream bf = new ByteArrayOutputStream();        ObjectOutputStream oos = new ObjectOutputStream(bf);        oos.writeObject(value);        oos.close();        ObjectinputStream ois = new ObjectinputStream(new ByteArrayinputStream(bf.toByteArray()));        Object o = ois.readobject();        return true;    } catch (Exception e) {        System.out.println("----->>>> Not exactly Serializable : " + value);    }        return false;}

它期望Serializable对象,但userSessions不是.

Set不可序列化,并键入您获得的类型

(Set) memcachedClIEnt.get(userID);

未序列化为.检查是否可以将memcachedClIEnt.get(userID)强制转换为可序列化的东西,如HashSets或TreeSet ….

最糟糕的是你可以尝试但是你可能会得到CastException

memcachedClIEnt.set(userID,(Serializable)userSessions);

你可以迭代set并做一个简单的检查:

[+++]
总结

以上是内存溢出为你收集整理的spring – 如何确定我的会话尝试序列化的对象?全部内容,希望文章能够帮你解决spring – 如何确定我的会话尝试序列化的对象?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 165, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
spring– 如何确定我的会话尝试序列化的对象?_语言综合_内存溢出

spring– 如何确定我的会话尝试序列化的对象?

spring– 如何确定我的会话尝试序列化的对象?,第1张

概述我最近升级到Spring Security 4.2.3.RELEASE.我也在使用spymemcached v 2.8.4.我遇到了这种情况,由于某些原因,Spring正在尝试序列化服务实现类.我无法弄清楚这是从哪里来的.异常引用的代码行是Set<Session> userSessions = (Set<Session>) memca

我最近升级到Spring Security 4.2.3.RELEASE.我也在使用spymemcached v 2.8.4.我遇到了这种情况,由于某些原因,Spring正在尝试序列化服务实现类.我无法弄清楚这是从哪里来的.异常引用的代码行是

Set

带着神秘的错误(“java.io.NotSerializableException:org.mainco.subco.ecom.service.ContractServiceImpl”被埋在里面)……

09:06:47,771 ERROR [io.undertow.request] (default task-58) UT005023: Exception handling request to /myproject/registration/save: java.lang.IllegalArgumentException: Non-serializable object    at net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(BaseSerializingTranscoder.java:110)    at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:162)    at net.spy.memcached.MemcachedClIEnt.asyncStore(MemcachedClIEnt.java:282)    at net.spy.memcached.MemcachedClIEnt.set(MemcachedClIEnt.java:733)    at net.spy.memcached.MemcachedClIEnt.set(MemcachedClIEnt.java:126)    at org.mainco.subco.session.service.MemcachedSessionService.associateUser(MemcachedSessionService.java:365)    at org.mainco.subco.session.service.MemcachedSessionService.setSessionSecurityContext(MemcachedSessionService.java:288)    at org.mainco.subco.core.security.SubcoSecurityContextRepository.saveContext(subcoSecurityContextRepository.java:116)    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:114)    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)    at org.springframework.web.filter.CharacterEnCodingFilter.doFilterInternal(CharacterEnCodingFilter.java:197)    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)    at io.undertow.servlet.handlers.ServletdispatchingHandler.handleRequest(ServletdispatchingHandler.java:36)    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.servlet.handlers.security.SSLinformationAssociationHandler.handleRequest(SSLinformationAssociationHandler.java:131)    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.security.handlers.AbstractConfIDentialityHandler.handleRequest(AbstractConfIDentialityHandler.java:46)    at io.undertow.servlet.handlers.security.ServletConfIDentialityConstraintHandler.handleRequest(ServletConfIDentialityConstraintHandler.java:64)    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at org.wildfly.extension.undertow.security.jacc.JACCContextIDHandler.handleRequest(JACCContextIDHandler.java:61)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)    at io.undertow.servlet.handlers.ServletinitialHandler.handleFirstRequest(ServletinitialHandler.java:284)    at io.undertow.servlet.handlers.ServletinitialHandler.dispatchRequest(ServletinitialHandler.java:263)    at io.undertow.servlet.handlers.ServletinitialHandler.accessmemcachedClIEnt.set(userID,userSessions);0(ServletinitialHandler.java:81)    at io.undertow.servlet.handlers.ServletinitialHandler.handleRequest(ServletinitialHandler.java:174)    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:198)    at io.undertow.server.httpServerExchange.run(httpServerExchange.java:784)    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)    at java.lang.Thread.run(Thread.java:745)Caused by: java.io.NotSerializableException: org.mainco.subco.ecom.service.ContractServiceImpl    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)    at java.io.ObjectOutputStream.defaultWriteFIElds(ObjectOutputStream.java:1548)    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)    at java.io.ObjectOutputStream.defaultWriteFIElds(ObjectOutputStream.java:1548)    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)

我如何弄清楚memcache正在尝试序列化的对象,从而弄清楚它是如何引用服务类来序列化的?

这个问题的关键不在于我如何使我的服务类可序列化,但为什么我的会话试图首先序列化它.

最佳答案

I’m running into this situation where for some reason Spring is trying to serialize service implementation classes.

spring不要尝试序列化实现.

你做的时候看起来很精简

int count=0;for(Session session: userSessions ){    log....    boolean isSerializable = checkIfSerializable(session);    count=isSerializable ? count+1 : count;    log }private static boolean checkIfSerializable(Object value) throws illegalaccessexception {    try {        ByteArrayOutputStream bf = new ByteArrayOutputStream();        ObjectOutputStream oos = new ObjectOutputStream(bf);        oos.writeObject(value);        oos.close();        ObjectinputStream ois = new ObjectinputStream(new ByteArrayinputStream(bf.toByteArray()));        Object o = ois.readobject();        return true;    } catch (Exception e) {        System.out.println("----->>>> Not exactly Serializable : " + value);    }        return false;}

它期望Serializable对象,但userSessions不是.

Set不可序列化,并键入您获得的类型

(Set) memcachedClIEnt.get(userID);

未序列化为.检查是否可以将memcachedClIEnt.get(userID)强制转换为可序列化的东西,如HashSets或TreeSet ….

最糟糕的是你可以尝试但是你可能会得到CastException

memcachedClIEnt.set(userID,(Serializable)userSessions);

你可以迭代set并做一个简单的检查:

          总结       

以上是内存溢出为你收集整理的spring – 如何确定我的会话尝试序列化的对象?全部内容,希望文章能够帮你解决spring – 如何确定我的会话尝试序列化的对象?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1265917.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)