3

This is the ManagedBean

@ManagedBean @ViewScoped public class DetailItem {
    private static final long serialVersionUID = -7647929779133437125L;
    @ManagedProperty(value = "#{itemServiceImpl}")
    private ItemService servItem;

This is the Service

@Service("itemServiceImpl") @Transactional(value = "transactionManagerLocal") public class ItemServiceImpl implements ItemService {
    private static final long serialVersionUID = 1L;
    @Autowired
    @Qualifier("itemDaoImpl")
    private ItemDAO dao;

but when I try to access to the page that used 'DetailItem', I have the following exception:

java.io.NotSerializableException: org.springframework.dao.support.PersistenceExceptionTranslationInterceptor    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)   java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

To fix that I do the servItem transient and obtain it from the applicationContext. But I understand that it is not the correct solution and I dont find any other. Which is the proper way to do that?

I don´t have the exception with sessionscoped or requestscoped.

4

1 回答 1

1

听起来像类似的问题,如ManagedProperty 的序列化

ItemService 是否实现 Serializable 并且 ItemServiceImpl 的所有成员本身都是可序列化的?

于 2012-07-19T10:36:25.433 回答