3 Replies Latest reply on Sep 13, 2007 4:34 AM by Thor Kummer

    Adding Seam to an existing EJB2 application

    Thor Kummer Newbie

      I'm trying to add Seam to an old EJB2 application so that we can do new development in Seam and gradually port the old stuff into Seam.

      I starting by merging the deployment directory of an "empty" Seam application, SeamApp, (created with seam-gen new-project) into the exploaded deployment legacy application, just to see if this was workable. There isn't really that much to copy across:

      - the jars, including SeamApp.jar.
      - module entries in META-INF/application.xml.
      - security.drl - the jboss rules' security defintions.
      - Seam-specific entries in web.xml
      - other files in SeamApp.war

      I left META-INF/jboss-app.xml intact. It already contains a <loader-repository> entry and cannot have two.

      After this the old application worked fine and I could access home.seam.

      Next I created a SFSB, DemoManager, using create-conversation in seam-gen and copied the diff of the deploy the same way to the deploeyd old app. This time (also after server restart) I get an exception when trying to access the new page:

      18:14:16,421 ERROR [STDERR] 12.09.2007 18:14:16 com.sun.facelets.FaceletViewHandler handleRenderException
      SCHWERWIEGEND: Error Rendering View[/demoManager.xhtml]
      javax.el.ELException: /demoManager.xhtml: Exception getting value of property value of base of type : org.javassist.tmp.java.lang.Object_$$_javassist_0
       at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:48)
       at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase.java:280)
       at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:189)
       at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:184)
       at org.ajax4jsf.framework.renderer.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:244)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:573)
       at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
       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.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:60)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
       at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
       at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:234)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at lu.deka.servlets.LoggedInFilter.doFilter(LoggedInFilter.java:56)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
       at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
       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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       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: org.javassist.tmp.java.lang.Object_$$_javassist_0, property: value
       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:125)
       at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:195)
       at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
       at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
       ... 56 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)
       ... 62 more
      Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: DemoManager.getValue() on: $Proxy167
       at org.jboss.seam.util.Reflections.invoke(Reflections.java:30)
       at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       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.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       at org.javassist.tmp.java.lang.Object_$$_javassist_0.getValue(Object_$$_javassist_0.java)
       ... 67 more
      Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
       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:20)
       ... 75 more
      


      Do you have any idea how to solve this or am I perhaps on the wrong track altogeather?

      Cheers
      Thor

        • 1. Re: Adding Seam to an existing EJB2 application
          Jacob Orshalick Apprentice

          Posting the code for DemoManager and the Remote or Local interface would help. Did you add the method getValue() to the Local or Remote interface that DemoManager implements?

          • 2. Re: Adding Seam to an existing EJB2 application
            Thor Kummer Newbie

            The demoManager is created using seam-gen's new-conversation target. The xhtml page (as generated) has buttons for beginning and ending a conversation and for incrementing a value, which is shown on the page. The bean has the corresponding methods. Again, this is the raw product from the new-conversation target. Here is the code for the interface, the bean and the XHTML:

            DemoManager.java

            package lu.deka.tukan.session;
            
            import javax.ejb.Local;
            
            @Local
            public interface DemoManager {
            
             //seam-gen methods
             public String begin();
             public String increment();
             public String end();
             public int getValue();
             public void destroy();
            
             //add additional interface methods here
            }
            
            


            DemoManagerBean.java

            package lu.deka.tukan.session;
            
            import javax.ejb.Remove;
            import javax.ejb.Stateful;
            import org.jboss.seam.annotations.Name;
            import org.jboss.seam.annotations.Begin;
            import org.jboss.seam.annotations.End;
            import org.jboss.seam.annotations.Destroy;
            import org.jboss.seam.annotations.Logger;
            import org.jboss.seam.log.Log;
            
            @Stateful
            @Name("DemoManager")
            public class DemoManagerBean implements DemoManager {
            
             @Logger private Log log;
            
             private int value;
            
             @Begin
             public String begin()
             {
             //implement your begin conversation business logic
             log.info("beginning conversation");
             return "success";
             }
            
             public String increment()
             {
             log.info("incrementing");
             value++;
             return "success";
             }
            
             //add additional action methods that participate in this conversation
            
             @End
             public String end()
             {
             //implement your end conversation business logic
             log.info("ending conversation");
             return "home";
             }
            
             public int getValue()
             {
             return value;
             }
            
             @Destroy @Remove
             public void destroy() {}
            }
            


            demoManager.xhtml

            <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <ui:composition xmlns="http://www.w3.org/1999/xhtml"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:f="http://java.sun.com/jsf"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:rich="http://richfaces.ajax4jsf.org/rich"
             template="layout/template.xhtml">
            
            <ui:define name="body">
            
             <h:messages globalOnly="true" styleClass="message"/>
            
             <rich:panel>
             <f:facet name="header">demoManager</f:facet>
            
             <div class="dialog">
             <div class="prop">
             <span class="name">Value</span>
             <span class="value">#{DemoManager.value}</span>
             </div>
             </div>
            
             </rich:panel>
            
             <h:form id="DemoManager">
             <div class="actionButtons">
             <h:commandButton id="begin" value="Begin"
             action="#{DemoManager.begin}"/>
             <h:commandButton id="inc" value="Increment"
             action="#{DemoManager.increment}"/>
             <h:commandButton id="end" value="End"
             action="#{DemoManager.end}"/>
             </div>
             </h:form>
            
            </ui:define>
            
            </ui:composition>
            
            
            


            • 3. Re: Adding Seam to an existing EJB2 application
              Thor Kummer Newbie

              Solved
              The missing piece was changing the JNDI name pattern in components.xml to reflect the name of the old application (tukan).

              <core:init debug="true" jndi-pattern="tukan/#{ejbName}/local"/>


              Thanks for listening ;-).