10 Replies Latest reply on Mar 19, 2008 4:22 PM by chawax

    Seam, web services and business process context

    chawax

      Hi,


      I created a Seam component as an EJB3 stateless session bean. This component has a method that puts variables in the business process context and starts the business process. The name of the business process is dynamic, so I could not use @Out or @CreateProcess annotations (maybe I am wrong about this ?). So I injected businessProcess component this way :


      @org.jboss.seam.annotations.In(create = true)
      protected org.jboss.seam.bpm.BusinessProcess businessProcess;



      Then my method works this way :


      Context context = Contexts.getBusinessProcessContext();
      context.set("demandeAbsence", demande);
      context.set("codeProcessus", processus.getCode());
      this.businessProcess.createProcess(processus.getCodeModele());
      



      It works perfect when using this Seam component from another Seam component.


      Now I want this Seam component to be exposed as a web service. So I added the following annotations to the class :



      @javax.jws.WebService(
           endpointInterface = "fr.mycompany.t4.module.commons.absences.ServiceAbsenceWSInterface",
           serviceName = "ServiceAbsenceBean")
      @org.jboss.ws.annotation.WebContext(
           contextRoot = "/t4-module-commons-ws", 
           urlPattern="/services/ServiceAbsence/*")
      



      But it doesn't work. The method is called but businessProcess variable is not injected (null) and context variable is null. Anybody has an idea what I did wrong ? Is it possible to use built-in Seam components in a Seam component exposed as a web service ?


      Thanks in advance ;)

        • 1. Re: Seam, web services and business process context
          nickarls

          Have you configured the seam handler as described in "20.1. Configuration and Packaging"?

          • 2. Re: Seam, web services and business process context
            chawax

            You are right, I had forgotten this. So I did it, it solved the problem for context variable, but businessProcess is still not injected. Do you see a reason why ?

            • 3. Re: Seam, web services and business process context
              chawax

              I tried to inject a POJO Seam component, same problem : injection does not work, so the problem doesn't deal with business processes. It looks like Seam interceptor is not runned. While I added the standard-jaxws-endpoint-config.xml file in /META-INF directory and I have this problem only when calling Seam component as a web service.

              • 4. Re: Seam, web services and business process context
                srini.ragu

                verify that seam interceptors are added in the META-INF/ejb-jar.xml


                Given your webservice endpoint is an EJB, and also a seam component by having @Name annotation in it. It worked for me.

                • 5. Re: Seam, web services and business process context
                  chawax

                  Yes, I added them.


                  <interceptors>
                     <interceptor>
                         <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
                      </interceptor>
                  </interceptors>
                  <assembly-descriptor>
                      <interceptor-binding>
                          <ejb-name>*</ejb-name>
                          <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
                      </interceptor-binding>
                  </assembly-descriptor>



                  My Seam component is declared in components.xml file (my code is generated with AndroMDA and that's the choice they did) but I don't think it could cause a problem.



                  <component
                      name="serviceAbsence"
                      class="fr.xxx.t4.module.commons.absences.ServiceAbsenceBean"
                      scope="STATELESS" />
                  



                  The Seam component is also declared as an EJB in ejb-jar.xml :


                  <session>
                      <description>
                          <![CDATA[
                          ]]>
                      </description>
                      <ejb-name>ServiceAbsenceBean</ejb-name>
                      <remote>fr.xxx.t4.module.commons.absences.ServiceAbsenceRemote</remote>
                      <local>fr.xxx.t4.module.commons.absences.ServiceAbsenceLocal</local>
                      <ejb-class>fr.xxx.t4.module.commons.absences.ServiceAbsenceBean</ejb-class>
                      <session-type>Stateless</session-type>
                      <transaction-type>Container</transaction-type>
                  </session>



                  Do you use Seam 2.0.1.GA too ?

                  • 6. Re: Seam, web services and business process context
                    srini.ragu

                    Yes.


                    @Stateless
                    @WebService
                    @WebContext(contextRoot="WebServices/services")
                    @Name("listEjbService")
                    public class ListServiceImpl2  implements  ListService
                    {
                        @In(create=true, value=FactoryBean.COMPONENT_NAME)
                        DomainFactory factoryBean;



                    verify the its registered as seam component in the startup by checking the server log. I did used the @Name annotation rather installing it thru components.xml


                    Please post root stack trace that would be helpful

                    • 7. Re: Seam, web services and business process context
                      chawax

                      Well, you are right ... When I register my component with @Name annotation as you did, injection works (I have other problems I have to investigate, but injection works). When I register it with components.xml, injection doesn't work. In both cases anyway the component is well loaded on startup. And this problem occurs only when calling my Seam component as a web service. So it looks like there is a bug in the Seam handler for web services, doesn't it ?

                      • 8. Re: Seam, web services and business process context
                        pmuir

                        Shane is away, therefore, so we don't loose this issue, please create a bug in JIRA, and attach an example of this that he can use to debug the issue.

                        • 9. Re: Seam, web services and business process context
                          chawax

                          I filed a JIRA : http://jira.jboss.com/jira/browse/JBSEAM-2765
                          I attached a small example, a Maven project that can reproduce the problem on a very simple example.

                          • 10. Re: Seam, web services and business process context
                            chawax

                            By the way, I tried with the very latest release of Seam (2.1.0.A1) and there is the same problem.