4 Replies Latest reply on Nov 10, 2008 10:50 AM by Olivier Thierry

    Problems using Seam Mail from a process

    Olivier Thierry Apprentice

      Hi,


      I created a Seam component that has a method using Seam Mail to send mails.



      public void mailDemandeAcceptee() throws java.lang.Exception
      {
          VOEmploye demandeur = getServiceBaseEmploye().loadEmploye(this.demandeAbsence.getMatriculeDemandeur());
          Context context = Contexts.getEventContext();
          context.set("demandeur", demandeur);
          context.set("demandeAbsence", this.demandeAbsence);
          renderer.render("/mails/demandeAbsenceAcceptee.xhtml");
      }



      This method is called on a transition in a JPBM process.


      <node name="acceptation">
          <transition to="end">
              <action expression="#{processusDemandeAbsenceAction.mailDemandeAcceptee()}" />
          </transition>
          <action expression="#{processInstanceHandler.callELMethods('EL_ACTION_OK')}" />
      </node>
      



      I want these transition to be fired from either a facelet or a web service, so I created a Seam component to fire this transition with the following method :


      public void followTransition(Long taskId, String transitionName) throws Exception {
          BusinessProcess businessProcess = BusinessProcess.instance();
          if (businessProcess != null) {
              if (businessProcess.resumeTask(taskId)) {
               if (businessProcess.validateTask()) {
                businessProcess.startTask();
                businessProcess.endTask(transitionName);
               }
           }
          }
      }



      Everything works perfect when I call this method from a facelet (on a <s:button> for example).


      But when I call it as a web service, I have the following error on calling the renderer.render() method:


      Caused by: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
           at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
           at org.jboss.seam.mock.MockFacesContext.<init>(MockFacesContext.java:60)
           at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.init(FaceletsRenderer.java:95)
           at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.run(FaceletsRenderer.java:77)
           at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:169)
      



      Is it a bug ? Or is there something special to do to use Seam mail in this context ?


      Thanks in advance for your help,


      Olivier

        • 1. Re: Problems using Seam Mail from a process
          Olivier Thierry Apprentice

          I just made a very simple test with a Seam component exposed as a web service and using Seam Mail. It works when I call the Seam component from a facelet, it doesn't work when calling the Seam component as a web service. I have this stack trace, the same as besides :


          Caused by: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
               at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
               at org.jboss.seam.mock.MockFacesContext.<init>(MockFacesContext.java:60)
               at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.init(FaceletsRenderer.java:95)
               at org.jboss.seam.ui.facelet.FaceletsRenderer$RenderingContext.run(FaceletsRenderer.java:77)
               at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:169)
          



          Does it mean that Seam Mail can be used only from a facelet ? If yes, is it planned to workaround this limitation ?

          • 3. Re: Problems using Seam Mail from a process
            Olivier Thierry Apprentice

            Tanks Pete for your response. Just have to wait 2.1.0.BETA2 version of I understand well.

            • 4. Re: Problems using Seam Mail from a process
              Olivier Thierry Apprentice

              Hi,


              I still try to send a mail from a web service using Seam Mail. I hoped it would work with Seam 2.1.0, but it still have the same error. It looks like it needs Faces context, but I have none when running a web service. The component works perfect when called from a JSF page. Maybe I do something wrong, but I couldn't find an example of mail sent from a web service.


              Here is the class that implements my web service :


              @javax.ejb.Stateless
              @org.jboss.seam.annotations.Name("testEnvoiMailWS")
              @org.jboss.seam.annotations.Scope(ScopeType.STATELESS)
              @javax.jws.WebService(
                   endpointInterface = "t4.module.gt.absence.TestEnvoiMailWSInterface",
                   serviceName = "TestEnvoiMailBean")
              @org.jboss.ws.annotation.WebContext(
                   contextRoot = "/t4-module-gt-ws", 
                   urlPattern="/services/TestEnvoiMail/*")
              public class TestEnvoiMailBean 
                  implements t4.module.gt.absence.TestEnvoiMailLocal, t4.module.gt.absence.TestEnvoiMailRemote
              {
                  @org.jboss.seam.annotations.In(create=true)
                  private Renderer renderer;
              
                  public TestEnvoiMailBean()
                  {
                      super();
                  }
              
                  public void start() throws java.lang.Exception
                  {
                       VOEmployee applicant = new VOEmployee();
                       applicant.setFirstName("FirstName");
                       applicant.setName("Name");
                       applicant.setEmail("firstName.name@myCompany.com");
                       
                       Context context = Contexts.getEventContext();
                       context.set("applicant", applicant);
                       renderer.render("/mails/acceptAbsenceRequest.xhtml");
                  }
                  
              }



              And I have the following stack trace :


              10:44:31,598 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
              javax.ejb.EJBException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.ui.facelet.facesContextFactory
                   at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
                   at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
                   at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
                   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.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
                   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.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
                   at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
                   at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:174)
                   at org.jboss.ws.integration.jboss42.ServiceEndpointInvokerEJB3.invokeServiceEndpointInstance(ServiceEndpointInvokerEJB3.java:114)
                   at org.jboss.ws.core.server.AbstractServiceEndpointInvoker.invoke(AbstractServiceEndpointInvoker.java:207)
                   at org.jboss.ws.core.server.ServiceEndpoint.processRequest(ServiceEndpoint.java:212)
                   at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:448)
                   at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                   at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                   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.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:156)
                   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:595)
              Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.ui.facelet.facesContextFactory
                   at org.jboss.seam.Component.newInstance(Component.java:2096)
                   at org.jboss.seam.Component.getInstance(Component.java:1978)
                   at org.jboss.seam.Component.getInstance(Component.java:1957)
                   at org.jboss.seam.Component.getInstance(Component.java:1951)
                   at org.jboss.seam.Component.getInstance(Component.java:1924)
                   at org.jboss.seam.Component.getInstance(Component.java:1919)
                   at org.jboss.seam.ui.facelet.RendererFacesContextFactory.instance(RendererFacesContextFactory.java:72)
                   at org.jboss.seam.ui.facelet.RendererRequest.init(RendererRequest.java:45)
                   at org.jboss.seam.ui.facelet.RendererRequest.run(RendererRequest.java:72)
                   at org.jboss.seam.ui.facelet.FaceletsRenderer.render(FaceletsRenderer.java:43)
                   at t4.module.gt.absence.TestEnvoiMailBean.start(TestEnvoiMailBean.java:53)
                   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.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
                   at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
                   at org.jboss.seam.intercept.EJBInvocationContext.proceed(EJBInvocationContext.java:44)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                   at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:29)
                   at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                   at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:31)
                   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:585)
                   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.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.invokeInOurTx(TxPolicy.java:79)
                   ... 42 more
              Caused by: java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
                   at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:256)
                   at org.jboss.seam.ui.facelet.RendererFacesContextFactory.create(RendererFacesContextFactory.java:47)
                   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:22)
                   at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
                   at org.jboss.seam.Component.callComponentMethod(Component.java:2201)
                   at org.jboss.seam.Component.callCreateMethod(Component.java:2124)
                   at org.jboss.seam.Component.newInstance(Component.java:2084)
                   ... 86 more
              


              Any idea ?


              Olivier