Bug in Seam 2.0.1 ? Please help.
toni Feb 27, 2008 11:01 AMHi,
I'm trying to move our webapplication to Seam 2.0.1 - without luck. It has been working well under Seam 1.2.1 for abour a year.
To nail down the issue I have written a very small and simple test application. It only consists of a SFSB, an Entity Bean and a JSP page.
Could somebody from the JBoss Team have a look at it? I suspect a bug, because it's a very simple szenario, which should work.
You can download the ready-to-deploy exploded ear from http://213.239.213.83/calc.ear.tgz and extract it straight into your deploy directory.
Then call http://localhost:8080/calc/test.seam
You will get an EJBTransactionRolledbackException, which originates from a NullPointerException in the ManagedEntityIdentityInterceptor
The test application is so simple that I really don't know how to further simplify it. So please, if somebody can have look at it.
I'm running on sarge (kernel 2.6.23.1), suns jdk 1.5.0(14) and JBoss 4.2.2 GA
Here are the sources (the rest can be found in the exploded ear):
Entity Bean
package de.test.calc.model; import org.jboss.seam.annotations.Name; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import java.io.Serializable; @Entity @Name("testEntity") public class TestEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) long id; @Lob String subject; @Lob String body; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getBody() { return body; } public void setBody(String body) { this.body = body; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TestEntity that = (TestEntity) o; if (id != that.id) return false; return true; } public int hashCode() { return (int) (id ^ (id >>> 32)); } }
SFSB
package de.test.calc.workflow; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.faces.model.DataModel; import javax.faces.model.ListDataModel; import javax.persistence.EntityManager; import javax.persistence.Query; import java.util.List; @Stateful @Name("testAction") public class TestAction implements TestActionInterface { @In(create = true) EntityManager entityManager; @Out(required = false) DataModel messages = new ListDataModel(); public String loadData() { runQuery(entityManager.createQuery("SELECT t FROM Test t")); return "test"; } protected void runQuery(Query query) { List list = query.getResultList(); messages.setWrappedData(list); } protected void runQuery(String query) { List list = entityManager.createQuery(query).getResultList(); messages.setWrappedData(list); } @Remove @Destroy public void destroy() { } }
SFSB Interface
package de.test.calc.workflow; import javax.ejb.Local; import java.io.Serializable; @Local public interface TestActionInterface extends Serializable { public String loadData(); public void destroy(); }
test.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %> <f:view> <h:form> <h:dataTable headerClass="main_kopf" value="#{messages}" var="c"> <h:column> <f:facet name="header"> <h:outputText value="Von"/> </f:facet> <h:outputText value="#{c.subject}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="An"/> </f:facet> <h:outputText value="#{c.body}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Subject"/> </f:facet> <h:outputText value="#{c.subject}"/> </h:column> </h:dataTable> </h:form> </f:view>