Can I mix Session, Entity and regular Java Beans in Seam app
patrickmadden Dec 18, 2006 2:11 PMHello,
I'm very new to Seam. I Have successfully created sites using JSP and Tomcat however.
I have seam CR2 deployed with 4.0.5GA using eclipse. I would like to be able to have a standard java beans created that is used as temporary object in my application to initialize some entity beans and then commit to the database. Take for example a very simple UserName and Password combination. My database password takes a byte[] for the password (sqlserver 2000). I can't change that. When I generate my entities the User Entity bean has a
public void setPassword(byte[] password)method. Therefore I want a very simple POJO similar to the Greeter example that is not backed by the DB. I want to create this object as follows:
package com.foo.web.bean; import java.io.Serializable; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Out; @Name("Greeter") public class GreeterBean implements Serializable { /** * */ private static final long serialVersionUID = 1L; private String name = ""; private String password = ""; @Out public String getName() { return name; } @Out public String getPassword() { return this.password; } @In public void setName(String name) { this.name = name; } @In public void setPassword(String password) { this.password = password; } }
And then use it in a form as follows:
<div id="sidebar"> <fieldset> <div> <h:outputLabel for="name">Login Name</h:outputLabel> <h:inputText id="name" value="#{Greeter.name}" style="width: 175px;" /> </div> <div> <h:outputLabel for="password">Password</h:outputLabel> <h:inputSecret id="password" value="#{Greeter.password}" style="width: 175px;" /> </div> <div class="errors"><h:messages globalOnly="true"/></div> <div class="buttonBox"><h:commandButton action="#{Login.login}" value="Account Login" class="button" /></div> <div class="notes"><h:commandLink action="register">Register New User</h:commandLink></div> </fieldset> </div>
Inside my stateless LoginAction class, I have an @In Greeter variable and I will use it to extract the bytes from the password to login my user. However, when I do this I get the following error:
javax.faces.el.EvaluationException: /home.xhtml @25,77 value="#{Greeter.name}": Exception getting value of property name of base of type : com.clooster.web.ejb.session.GreeterBean$$EnhancerByCGLIB$$8988b3bf at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:60) at javax.faces.component.UIOutput.getValue(UIOutput.java:77) at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217) at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderInput(HtmlTextRendererBase.java:135) at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:53) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536) at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242) at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239) at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239) at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580) at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112) at java.lang.Thread.run(Thread.java:595) Caused by: javax.faces.el.EvaluationException: Bean: com.clooster.web.ejb.session.GreeterBean$$EnhancerByCGLIB$$8988b3bf, property: name at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:442) at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:82) at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:141) at com.sun.el.parser.AstValue.getValue(AstValue.java:117) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192) at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71) at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56) ... 36 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:438) ... 42 more Caused by: org.jboss.seam.RequiredException: In attribute requires value for component: Greeter.password at org.jboss.seam.Component.getInstanceToInject(Component.java:1878) at org.jboss.seam.Component.injectMethods(Component.java:1322) at org.jboss.seam.Component.inject(Component.java:1113) at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(BijectionInterceptor.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.util.Reflections.invoke(Reflections.java:18) at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64) at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.util.Reflections.invoke(Reflections.java:18) at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64) at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.seam.util.Reflections.invoke(Reflections.java:18) at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64) at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144) at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102) at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:140) at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:75) at com.clooster.web.ejb.session.GreeterBean$$EnhancerByCGLIB$$8988b3bf.getName(<generated>) ... 47 more
So my question is is this possible - am I doing something wrong? Any help is greatly appreciated.