2

我使用Spring 3與JSF 2,Tomcat 6 和我用Spring bean替換JSF託管的bean,通過添加豆:java.lang.IllegalStateException:無法反序列化具有ID的BeanFactory org.springframework.web.context.WebApplicationContext

@Component("mybean") 
@Scope("session") 

,並在我的豆我正在自動裝配彈簧服務(這是與註解@Service聲明)

雙方的Spring bean(JSF託管bean /控制器)和我的春季服務實現Serializable。

很好,一切工作正常,但有時,我得到這個異常:

java.lang.IllegalStateException: Cannot deserialize BeanFactory with id org.springframework.web.context.WebApplicationContext:/myapp: no factory registered for this id 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory$SerializedBeanFactoryReference.readResolve(DefaultListableBeanFactory.java:972) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:1061) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1762) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480) 
    at org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor.readObject(AbstractBeanFactoryPointcutAdvisor.java:98) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480) 
    at org.springframework.aop.framework.AdvisedSupport.readObject(AdvisedSupport.java:550) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947) 
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871) 
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753) 
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) 
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) 
    at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1496) 
    at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:998) 
    at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:394) 
    at org.apache.catalina.session.StandardManager.load(StandardManager.java:321) 
    at org.apache.catalina.session.StandardManager.start(StandardManager.java:648) 
    at org.apache.catalina.core.ContainerBase.setManager(ContainerBase.java:446) 
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4631) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) 
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) 
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) 
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) 
    at org.apache.catalina.core.StandardService.start(StandardService.java:525) 
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) 
    at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) 
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 

請告知。

+0

在這裏有什麼幫助? –

回答

0

好了,終於我能使其正常工作如下:

1的服務:

@Service 
@Scope("singleton") 
public class PersonService{ 

} 

2- Spring管理的Bean:

@Component("person") 
    @Scope("session") 
    public class PersonBean implements Serializable{ 

    @Inject 
    private PersonService personService; 

    } 
相關問題