[jboss-user] [JBoss Seam] - Bug or not?
LockDog
do-not-reply at jboss.com
Thu Aug 30 07:08:13 EDT 2007
Class
@Name("userHome")
/**
* User entity home class
* Contains user management functions
*/
public class UserHome extends EntityHome {
...
@Restrict("#{s:hasRole('Librarian')}")
public void addUser() {
getInstance().setRole(Role.USER);
persist();
}
Form:
<h:form id="userAddForm">
<rich:panel style="background-color:#faf9cc;">
<f:facet name="header">UserAdd</f:facet>
<s:decorate id="userEmailDecoration" template="/layout/edit.xhtml">
<ui:define name="label">E-mail</ui:define>
<h:inputText id="email" value="#{userHome.instance.email}"/>
</s:decorate>
<s:decorate id="firstNameDecoration" template="/layout/edit.xhtml">
<ui:define name="label">First Name</ui:define>
<h:inputText id="firstname" value="#{userHome.instance.firstName}"/>
</s:decorate>
<s:decorate id="emailDecoration" template="/layout/edit.xhtml">
<ui:define name="label">Last Name</ui:define>
<h:inputText id="lastName" value="#{userHome.instance.lastName}"/>
</s:decorate>
<s:decorate id="passwordDecoration" template="/layout/edit.xhtml">
<ui:define name="label">Password</ui:define>
<h:inputText id="Password" value="#{userHome.instance.password}"/>
</s:decorate>
<h:commandButton id="addUser"
value="Add User"
action="#{userHome.addUser}"/>
</rich:panel>
</h:form>
Test:
public class UserHomeTest extends SeamTest {
@Test
public void addUserTest() throws Exception {
//login
new FacesRequest() {
@Override
protected void updateModelValues() {
assertFalse("Is user logged in", (Boolean) getValue("#{identity.loggedIn}"));
// Some data(from import-test.sql)
//login
setValue("#{identity.username}", "lock_dog2000 at mail.ru");
setValue("#{identity.password}", "Eugene");
}
@Override
protected void invokeApplication() {
invokeMethod("#{identity.login}");
}
}.run();
// Testing add user method
new FacesRequest() {
@Override
protected void updateModelValues() {
//fill new user
setValue("#{userHome.instance.firstName}", "Lida");
setValue("#{userHome.instance.lastName}", "Jarikova");
setValue("#{userHome.instance.email}", "iamstupid at girl.ua");
setValue("#{userHome.instance.password}", "passme");
}
@Override
protected void invokeApplication() {
invokeMethod("#{userHome.addUser}");
}
@Override
protected void renderResponse() {
UserList userList = (UserList) getInstance("userList");
assertNotNull(userList);
assertEquals(4, (long) userList.getResultCount());
}
}.run();
Error:
javax.el.ELException: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at com.sun.el.parser.AstValue.invoke(AstValue.java:178)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
at org.jboss.seam.util.UnifiedELMethodBinding.invoke(UnifiedELMethodBinding.java:36)
at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
at org.jboss.seam.actionparam.ActionParamBindingHelper.invokeTheExpression(ActionParamBindingHelper.java:58)
at org.jboss.seam.actionparam.ActionParamMethodBinding.invoke(ActionParamMethodBinding.java:75)
at org.jboss.seam.mock.SeamTest$Request.invokeMethod(SeamTest.java:401)
at org.teamdev.librarian.UserHomeTest$1.invokeApplication(UserHomeTest.java:35)
at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
at org.teamdev.librarian.UserHomeTest.addUserTest(UserHomeTest.java:17)
Caused by: javax.persistence.TransactionRequiredException: No active JTA transaction on joinTransaction call
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:429)
at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:402)
at org.jboss.seam.persistence.EntityManagerProxy.joinTransaction(EntityManagerProxy.java:113)
at org.jboss.seam.framework.EntityHome.persist(EntityHome.java:47)
at org.teamdev.librarian.user.UserHome.addUser(UserHome.java:42)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
at org.jboss.seam.interceptors.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:47)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.interceptors.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:37)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.interceptors.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:34)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.interceptors.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:63)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.interceptors.TransactionInterceptor$1.work(TransactionInterceptor.java:32)
at org.jboss.seam.util.Work.workInTransaction(Work.java:37)
at org.jboss.seam.interceptors.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:27)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.interceptors.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:37)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:151)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:87)
at org.teamdev.librarian.user.UserHome_$$_javassist_1.addUser(UserHome_$$_javassist_1.java)
at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
... 32 more
... Removed 30 stack frames
-----
It is all right, when you adding user by the form.
But test fall.
Help!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079552#4079552
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079552
More information about the jboss-user
mailing list