SEAM PageScope and EntityClosed Exception
idyoshin Nov 21, 2009 10:38 PMgood day.
I'm stuck with the following problem. I'd like to create some CRUD's for mine objects. So I've created a PageScoped EntityHome.
@Name("sprAddressTypeEntityHome")
@Scope(ScopeType.PAGE)
public class SprAddressTypeEntityHome extends CommonEntityHome<SprAddressType>{
}
public class CommonEntityHome<E> extends EntityHome<E>{
@Transactional
public String save() {
if (this.isManaged()) {
return update();
} else {
return persist();
}
}
}and created the view for it:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
template="/layout/template.xhtml"
xmlns:a4j="http://richfaces.org/a4j">
<ui:define name="body">
<h3>Тип адреси</h3>
<a4j:form ajaxSubmit="true">
<h:panelGrid>
<s:decorate template="../common_edit.xhtml">
<ui:param name="instance" value="#{sprAddressTypeEntityHome.instance}"/>
</s:decorate>
<a4j:commandButton action="#{sprAddressTypeEntityHome.save()}" value="Зберегти" />
</h:panelGrid>
</a4j:form>
</ui:define>
</ui:composition>and it loads correctly. But when I try to save mine data I get EntityClosed exception.
Caused by: java.lang.IllegalStateException: EntityManager is closed
at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66)
at org.hibernate.ejb.AbstractEntityManagerImpl.contains(AbstractEntityManagerImpl.java:282)
at org.jboss.seam.persistence.EntityManagerProxy.contains(EntityManagerProxy.java:41)
at org.jboss.seam.framework.EntityHome.isManaged(EntityHome.java:43)
at com.uniqa.session.lib.CommonEntityHome.save(CommonEntityHome.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Any idea? I don't want to use conversations for my cruds (there is no need). And don't want to use Application-scoped controllers for my objects.
By the way, if it's matters: I use SEAM 2.2.0 with EAR packaging on jboss-5.1.0.GA
Cheers.
Ilya Dyoshin