Please help(@In attribute requires non-null value)
khosro_question Aug 3, 2008 12:49 PMHello Dear members,
I know this issue has been discussed but i did not understand it and i could not solve my problem,so i post my own issue,with different code,so,please excuse me.
I read a book that was JBoss Seam: Simplicity and Power Beyond Java EE
.I want to run the Hello World example but i got a error.
First i write my code then the error:
ManagerAction.java:
@Stateless @Name("manager") public class ManagerAction implements Manager { @In @Out private Person person; @Out private List <Person> fans; @PersistenceContext private EntityManager em; public String sayHello () { em.persist (person); person = new Person (); fans = em.createQuery("select p from Person p") .getResultList(); return null; } }
Person.java
@Entity @Name("person") public class Person implements Serializable { private long id; private String name; @Id @GeneratedValue public long getId() { return id;} public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
hello.jsp
<h:inputText value="#{person.name}" size="15"/><br/> <h:commandButton type="submit" value="Say Hello" action="#{manager.sayHello}"/>
The application run but when i click button to save the person in database i get the following error:
Please help me ,because i can not go on to learn the Seam.
javax.ejb.EJBTransactionRolledbackException: @In attribute requires non-null value: manager.person org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87) org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130) org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77) org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214) org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184) org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81) $Proxy87.sayHello(Unknown Source) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.jboss.seam.util.Reflections.invoke(Reflections.java:21) org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31) org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76) org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56) org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54) org.javassist.tmp.java.lang.Object_$$_javassist_1.sayHello(Object_$$_javassist_1.java) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.apache.el.parser.AstValue.invoke(AstValue.java:131) org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68) javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77) com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91) javax.faces.component.UICommand.broadcast(UICommand.java:383) javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447) javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752) com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97) com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251) com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117) javax.faces.webapp.FacesServlet.service(FacesServlet.java:244) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
Khosro.