3 Replies Latest reply on Jan 14, 2009 5:54 AM by Okanovi? Du?an

    Expose SLSB as CXF web service

    Okanovi? Du?an Newbie

      I have an example that works fine with native distribution, but fails to work with cxf. It also worked fine with Tomcat 6.
      It is a simple WS, SLSB that creates a City record in database.
      What is the proper way to configure this? Whatever I try to do, EntityManager is always null.

      @WebService(name="CityFacadeProxy", targetNamespace = "http://gint_scm_ws/")
      @SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.LITERAL)
      @Remote
      public interface CityFacadeService {
       public City createCity(@WebParam(name="cityName") String cityName);
      }


      @Stateless
      @WebService(endpointInterface = "yu.ac.ns.ftn.informatika.scm.CityFacadeService",
       serviceName = "CityFacadeServis", targetNamespace="http://gint_scm_ws")
      @Remote(CityFacadeService.class)
      public class CityFacade implements CityFacadeService {
      
       @PersistenceContext(name = "java:/scm")
       EntityManager em;
      
       public City createCity(String cityName) {
       System.out.println("!!!"+em);
       em.persist(new City(cityName.hashCode(), cityName));
       return new City(cityName.hashCode(), cityName);
       }
      
      }


      persistence.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
       <persistence-unit name="scm">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>scm</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
       <property name="hibernate.hbm2ddl.auto" value="update" />
       <property name="jboss.entity.manager.jndi.name" value="scm" />
       </properties>
       </persistence-unit>
      </persistence>


      context.xml:
      <Context path="scmDS" docBase="scmDS" debug="5"
       reloadable="true" crossContext="true">
       <Resource name="java:/scmDS" auth="Container"
       type="javax.sql.DataSource"
       description="MySQL database for SCM" maxActive="100"
       maxIdle="30" maxWait="10000" username="root" password="root"
       driverClassName="com.mysql.jdbc.Driver"
       url="jdbc:mysql://localhost/updater" />
      </Context>


      scmDS is also defined in mysql-ds.xml, but no errors are reported because of this.

      Files:
      +-yu.ac.ns.ftn.informatika.scm.CityFacade
      +-yu.ac.ns.ftn.informatika.scm.CityFacadeService
      +-META-INF
      +-----persistence.xml
      +-WEB-INF
      +-----context.xml
      +-----cxf-servlet.xml
      +-----web.xml