1 Reply Latest reply on May 22, 2010 3:20 AM by davidfdr.davidfdr.gmail.com

    JbossWS Webservice @In for injection not working.

    davidfdr.davidfdr.gmail.com

      Hi.


      I am using the following configuration:


      Jboss 4.2.3
      Seam 2.1.2
      Java 5


      I have a webservice (Not stateless ejb) correct deployed.


      When I try to use @In to inject a EJB (Stateless), the component is allways null.
      When I try to use Component.getInstance() aproach, I am getting the following exception: java.lang.IllegalStateException: No active event context


      My web.xml:




      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
           version="2.5">
           <listener>
                <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
           </listener>
           <filter>
                <filter-name>Seam Servlet Filter</filter-name>
                <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
           </filter>
      
           <filter-mapping>
                <filter-name>Seam Servlet Filter</filter-name>
                <url-pattern>/TesteWebService</url-pattern>
           </filter-mapping>
           <context-param>
                <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                <param-value>.xhtml</param-value>
           </context-param>
           <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
           </servlet>
           <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.seam</url-pattern>
           </servlet-mapping>
           <session-config>
                <session-timeout>10</session-timeout>
           </session-config>
      
           <servlet>
                <servlet-name>TesteWebService</servlet-name>
                <servlet-class>br.gov.infosolo.servico.TesteWebService</servlet-class>
           </servlet>
      
           <servlet-mapping>
                <servlet-name>TesteWebService</servlet-name>
                <url-pattern>/TesteWebService</url-pattern>
           </servlet-mapping>
      </web-app>



      My webservice:




      /*
       * 21/05/2010 20:45:11
       * TesteWebService.java
       * david
       */
      
      package br.gov.infosolo.servico;
      
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      
      import org.jboss.seam.Component;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      
      import br.com.infosolo.negocio.ejb.TesteInjectionLocal;
      
      
      @WebService
      @Name("TesteWebService")
      public class TesteWebService {
           
           @In(create=true) 
           private TesteInjectionLocal testeInjection;     
           
           @WebMethod
           public String teste(String teste){
                TesteInjectionLocal testeInjection = (TesteInjectionLocal)Component.getInstance("testeInjection");
                String teste2 = testeInjection.helloInjection(teste);
                return "Testando: " + teste + " - " + teste2;
           }
      }




      The seam context appears to be ok when we are using a jsf normal page.


      Anybody help me please.


        • 1. Re: JbossWS Webservice @In for injection not working.
          davidfdr.davidfdr.gmail.com

          Hi, my problem was almost solved.


          @In annotation doesn't work (yet) but Component.getInstance() is working ok.


          I have to put the following configuration on my components.xml:




          <?xml version="1.0" encoding="UTF-8"?>
          <components xmlns="http://jboss.com/products/seam/components"
                      xmlns:core="http://jboss.com/products/seam/core"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns:web="http://jboss.com/products/seam/web"
                      xsi:schemaLocation=
                          "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                           http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd
                           http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.1.xsd">
          
              <core:init jndi-pattern="migracao-primaverap3/#{ejbName}/local"/>
              <web:context-filter url-pattern="/TesteWebService"/>
          
          </components>



          I still want to use @In annotation.


          Anybody have any idea????