1 2 Previous Next 28 Replies Latest reply on Jun 17, 2008 3:55 PM by mkiel

    Seam Project Design

    metal610

      Hi everyone.


      I have a question about how a project in Seam is supposed to be designed. Is it supposed to be like JSF, where you have a bean backing a page with a logic class and then the database access is in a different class, or is it supposed to be like the Seam examples, where everything is in one file. I think that the answer to this question may solve my problems with Seam, for those of you who have read my past posts who know what I'm talking about.


      Thanks,
      Robert

        • 1. Re: Seam Project Design
          endyamon
          • 2. Re: Seam Project Design
            metal610

            Thanks for the tip, but that doesn't really help me.


            I'm trying to find out whether or not my class structure is correct or not. For example, in my project, I have a xhtml page that has a stateful session bean backing it, much like you would do in JSF. All I have in that backing bean is some getters and setters, along with a few calls to another class that handles the logic for that page. The logic class takes care of all the logic and also calls another class that handles all of the database access. The database class injects the EntityManager and works its magic.


            All I need to know is if what I am doing is correct or if I have it all wrong. I say this because in all of the Seam examples, and even the Wiki, there is no tiering of classes. Everything is all in the stateful backing bean.


            I am asking this because I have come across a few problems with injection and I have a funny feeling that this may be the cause.


            Using my example above, the way I had all of the classes to begin with was I had the backing bean a Seam component and all of the other classes were instantiated using the new operator. This caused a problem when I tried to do database access with the EntityManager. Whenever I called it, it would be null. I found out through trial and error that you cannot inject an object into a non-component. I also found out that I could inject the EntityManager into the backing bean and if I passed it back to my database class, everything would be good, except that is not good design and coding practices. That's when I tried making all of my classes stateful session beans and I injected them into each other. That is supposed to work perfectly, but when I ran the page, it was telling me that my logic class could not be injected because of an error (the error is below).


            I know that I have asked some stupid questions before, but I'm trying to get this to work for my company and I think that this is a serious question.


            Thanks,
            Robert



            Caused by: java.lang.IllegalArgumentException: could not set field value: registrationBean.registrationLogic
                    at org.jboss.seam.Component.setFieldValue(Component.java:1789)
                    at org.jboss.seam.Component.access$600(Component.java:139)
                    at org.jboss.seam.Component$BijectedField.set(Component.java:2622)
                    at org.jboss.seam.Component.injectAttributes(Component.java:1598)
                    at org.jboss.seam.Component.inject(Component.java:1416)
                    at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
                    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                    at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                    at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                    at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                    at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                    at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                    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:597)
                    at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                    at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                    at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                    at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                    at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                    at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                    ... 102 more
            Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: RegisterBean.regLogic on: us.gaaoc.ejb.RegisterBean with value: class org.javassist.tmp.java.lang.Object_$$_javassist_0
                    at org.jboss.seam.util.Reflections.set(Reflections.java:79)
                    at org.jboss.seam.Component.setFieldValue(Component.java:1785)
                    ... 130 more
            Caused by: java.lang.IllegalArgumentException: Can not set us.gaaoc.ejb.logic.RegistrationLogic field us.gaaoc.ejb.RegisterBean.regLogic to org.javassist.tmp.java.lang.Object_$$_javassist_0
                    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
                    at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
                    at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
                    at java.lang.reflect.Field.set(Field.java:657)
                    at org.jboss.seam.util.Reflections.set(Reflections.java:64)
                    ... 131 more
            

            • 3. Re: Seam Project Design
              endyamon

              it seems to be a field with getter/setter private. Because i already had issues like that before.

              • 4. Re: Seam Project Design
                metal610

                None of my getters/setters are private. I had my class that I was injecting private, but I changed it to a public field and still there was nothing.


                The stack trace above is only the bottom part of the entire stack trace. I'll put the full one below because it may help out a bit. And no, the getter/setter for username is not private. That is only being thrown because the injection didn't work.


                javax.faces.FacesException: javax.el.ELException: /Register.xhtml @32,84 value="#{registrationBean.username}": Error reading 'username' on type org.javassist.tmp.java.lang.Object_$$_javassist_2
                        at javax.faces.component.UIOutput.getValue(UIOutput.java:176)
                        at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
                        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
                        at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
                        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
                        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
                        at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
                        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                        at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
                        at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                        at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
                        at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
                        at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
                        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                        at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                        at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                        at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                        at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
                        at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                        at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
                        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                        at java.lang.Thread.run(Thread.java:619)
                Caused by: javax.el.ELException: /Register.xhtml @32,84 value="#{registrationBean.username}": Error reading 'username' on type org.javassist.tmp.java.lang.Object_$$_javassist_2
                        at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
                        at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
                        ... 59 more
                Caused by: javax.ejb.EJBTransactionRolledbackException: could not set field value: registrationBean.registrationLogic
                        at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
                        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
                        at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
                        at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:204)
                        at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:100)
                        at $Proxy212.getUsername(Unknown Source)
                        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:597)
                        at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                        at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                        at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                        at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.
                14:06:08,269 ERROR [STDERR] jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                        at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
                        at org.javassist.tmp.java.lang.Object_$$_javassist_2.getUsername(Object_$$_javassist_2.java)
                        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:597)
                        at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
                        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                        at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                        at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
                        at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                        at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                        at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
                        ... 60 more
                Caused by: java.lang.IllegalArgumentException: could not set field value: registrationBean.registrationLogic
                        at org.jboss.seam.Component.setFieldValue(Component.java:1789)
                        at org.jboss.seam.Component.access$600(Component.java:139)
                        at org.jboss.seam.Component$BijectedField.set(Component.java:2622)
                        at org.jboss.seam.Component.injectAttributes(Component.java:1598)
                        at org.jboss.seam.Component.inject(Component.java:1416)
                        at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
                        at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                        at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                        at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
                        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:597)
                        at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
                        at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
                        at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
                        at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
                        ... 102 more
                Caused by: java.lang.IllegalArgumentException: Could not set field value by reflection: RegisterBean.regLogic on: us.gaaoc.ejb.RegisterBean with value: class org.javassist.tmp.java.lang.Object_$$_javassist_0
                        at org.jboss.seam.util.Reflections.set(Reflections.java:79)
                        at org.jboss.seam.Component.setFieldValue(Component.java:1785)
                        ... 130 more
                Caused by: java.lang.IllegalArgumentException: Can not set us.gaaoc.ejb.logic.RegistrationLogic field us.gaaoc.ejb.RegisterBean.regLogic to org.javassist.tmp.java.lang.Object_$$_javassist_0
                        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
                        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
                        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
                        at java.lang.reflect.Field.set(Field.java:657)
                        at org.jboss.seam.util.Reflections.set(Reflections.java:64)
                        ... 131 more
                

                • 5. Re: Seam Project Design

                  Could we see the code that caused these errors? I'm not a vetted expert in Seam yet... but I have had similar errors to those above, and may be able to tell you why they are happening.


                  And to make you feel better, I understand your design issues... I've had similar thoughts and I'm assuming I'll be able to work through them when I get there.

                  • 6. Re: Seam Project Design
                    israel.bgf

                    I have the same problem about these philosophical design issues.

                    • 7. Re: Seam Project Design
                      barbacena

                      The way your application is designed is up to you. If you like lot of layers do it: Facade, Manager, Repository, DAO. You can go all the way and mix POJO seam components with EJBs as you like (but remember the transaction demarcation of EJBs and Seam components).


                      The problem you are having is bug. You need to know if it is on your application (more likely) or on Seam (less likely).


                      The only thing I can say with the stacktrace is that Seam is trying to inject a proxy with a type different from the field. How is your injection annotation of regLogic on RegisterBean? How is us.gaaoc.ejb.logic.RegistrationLogic declared as Seam component? And what about the us.gaaoc.ejb.RegisterBean?


                      • 8. Re: Seam Project Design
                        gjeudy

                        If that can help I thought I would put a little insight based on my experience with Seam.


                        I was a bit confused too with the lack of layering in the Seam examples. I think it all goes down to complexity and the plans you have for re-use. If the problem you are solving is very simple then why not have everything in the same stateful bean? I find this is great for prototyping an application rapidly. However, the danger is to not refactor when your application evolves and add layering when needed, but this is not particular to Seam development I think it applies to application development in general.


                        Here's what I found worked well for me:



                        1. I use SFSBs to back my views and try to externalize navigation logic as much as possible in pages.xml or JPDL pageflows. Don't use logical outcomes but rather inspect state on your bean. This will make it easier to reuse your bean in different contexts.

                        2. I use SLSBs to manage entityManager interactions and build some simple stateless dao objects.

                        3. I use SMPC so I dont have to deal with the complex persistence context propagation rules in EJB3 and it also help on avoiding LazyInitException in the render view phase.

                        4. Use of nested conversations ease the re-use of the same SFSB because you can have more than 1 instance of your SFSB class active at any point in time. I found this aspect the most tricky to deal with. I found managing conversation boundaries is hard but its probably the most powerful feature I found in Seam.

                        5. When I refer to objects in my views I try not to reference state by referencing the bean it is attached to. Example:



                        #{myBean.state} EL expression couples the state to the bean, you should probably use #{state} only which decouples the state from the bean and allows for easy argument passing between beans participating in the same conversation. Use @In, @Out annotations to achieve this.



                        The doc for Seam is great but it does not highlight any best practices for developing mid to large size apps.


                        It would be nice to hear from others experience too.


                        Good luck with Seam!


                        -Guillaume



                        • 9. Re: Seam Project Design
                          metal610

                          Thanks everyone for all of the replies.


                          Here is the code that is causing the errors from above:



                          This is the backing bean for the page


                          @Stateful
                          @Scope(SESSION)
                          @Name("registrationBean")
                          public class RegisterBean implements Register, Serializable{
                          
                              @In(value="registrationLogic")
                              private RegistrationLogic regLogic;
                          



                          And here is the top of the RegistrationLogic class:


                          @Stateful
                          @Scope(SESSION)
                          @AutoCreate
                          @Name("registrationLogic")
                          public class RegistrationLogic implements RegistrationLogicInterface, Serializable{
                          



                          From my understanding of Seam so far, this should work just fine correct?


                          Thanks,
                          Robert

                          • 10. Re: Seam Project Design
                            gjeudy

                            Yeah, it looks like this should work in theory. If I were I would try different combinations to see if one of them works.


                            i.e. try:


                            @In(create=true) instead of @AutoCreate



                            and/or try


                            @In
                            
                            private RegistrationLogic registrationLogic;



                            instead.


                            I haven't tested any of these combinations but they are different ways to achieve the same thing.


                            Hope this helps,

                            • 11. Re: Seam Project Design
                              metal610

                              I tried both of those and a few others and none of them did anything.

                              • 12. Re: Seam Project Design
                                metal610

                                I changed my code a bit so that instead of using


                                @In
                                private RegistrationLogic regLogic;
                                



                                I changed it to


                                @In
                                public void setRegLogic(RegistrationLogic regLogic)
                                {
                                    this.regLogic = regLogic;
                                }
                                



                                in an attempt to see if that would help. The only thing that it did was give me this error:


                                Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: RegisterBean.setRegistrationLogic(us.gaaoc.ejb.logic.RegistrationLogic) with parameters: (org.javassist.tmp.java.lang.Object_$$_javassist_2) on: us.gaaoc.ejb.RegisterBean
                                        at org.jboss.seam.util.Reflections.invoke(Reflections.java:31)
                                        at org.jboss.seam.Component.setPropertyValue(Component.java:1773)
                                        ... 130 more
                                Caused by: java.lang.IllegalArgumentException: argument type mismatch
                                        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:597)
                                        at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                                        ... 131 more
                                



                                Those are the last two errors because the rest are the same.


                                I'm not sure if that is going to help at all, but I figured I would tell you guys.


                                Thanks

                                • 13. Re: Seam Project Design
                                  barbacena

                                  Did you tried to scope your beans in conversation besides session? Could you post your view and relevant part of pages.xml?


                                  Ty

                                  • 14. Re: Seam Project Design
                                    metal610

                                    I tried that just now and it didn't change it. It was still giving me the same error.


                                    I don't have anything in my pages.xml for this page except for


                                    <param name="eventFirstResult" value="#{eventTList.firstResult}"/>
                                    



                                    which is used for the datascroller on my table.


                                    What view are you talking about? The page itself?

                                    1 2 Previous Next