2 Replies Latest reply on Oct 4, 2011 5:59 AM by Sam W

    Failed to invoke CXF service in JBOSS 6.

    Sam W Expert

      Hi,

       

      I built a CXF2 web service with EJB3 for jboss6 using interface for mothod invocation.

      But JBOSS 6 throws the following error when it invokes a web service method through the interface.

       

      ERROR [org.jboss.wsf.common.invocation.InvocationHandlerJAXWS] Method invocation failed with exception: null: java.lang.reflect.InvocationTargetException

      ...

      ...

      Caused by: java.lang.RuntimeException

              at ix.houseware.category.service.CategoryWebServiceImpl.findAll(CategoryWebServiceImpl.java:52) [:]

       

       

      Interface CategoryService file:

       

       

      import ix.houseware.category.entity.CategorySubcategories;

      import java.util.Collection;

      import javax.jws.Oneway;

      import javax.jws.WebMethod;

      import javax.jws.WebParam;

      import javax.jws.WebService;

       

       

      @WebService

      public interface CategoryWebService {

          @WebMethod(operationName = "findAll")

          public Collection<CategorySubcategories> findAll();

      }

       

       

       

      Implementation CatagoryWebServiceImpl class:

       

       

      import ix.houseware.category.entity.CategorySubcategories;

      import ix.houseware.category.entity.facade.CategorySubcategoriesFacade;

      import java.util.ArrayList;

      import java.util.Collection;

      import javax.ejb.EJB;

      import javax.ejb.Stateless;

      import javax.jws.Oneway;

      import javax.jws.WebMethod;

      import javax.jws.WebParam;

      import javax.jws.WebService;

       

       

      @WebService(serviceName = "CategoryWebService")

      @Stateless()

      public class CategoryWebServiceImpl implements CategoryWebService {

       

          @EJB

          private CategorySubcategoriesFacade categorySubcategoriesFacade;

       

          @WebMethod(operationName = "findAll")

          @Override

          public Collection<CategorySubcategories> findAll() {

              try {

                  return categorySubcategoriesFacade.findAll();

              } catch (Exception e) {

                  throw new RuntimeException(e.getMessage());

              }

          }

       

      Facade class:

       

       

      public abstract class AbstractFacade<T> {

          private static final Logger logger = Logger.getLogger(AbstractFacade.class);

          private Class<T> entityClass;

       

       

          public AbstractFacade(Class<T> entityClass) {

              this.entityClass = entityClass;

          }

       

       

          protected abstract EntityManager getEntityManager();

       

          public List<T> findAll() {

              System.out.println("calling FindAll()................");

              logger.info("****************calling findAll()...**********************");

              try {

                  javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();

                  cq.select(cq.from(entityClass));

                  return getEntityManager().createQuery(cq).getResultList();

              } catch (Exception e) {

                 throw new RuntimeException(e.getMessage());

              }

          }

       

       

       

      The exception is occured at categorySubcategoriesFacade.findAll() where the method findAll() is not getting call at all.

       

      Does anyone know how to invoke a method through interface?

       

      Thanks

      Sam

        • 1. Re: Failed to invoke CXF service in JBOSS 6.
          Mark Paluch Master

          Hi Sam,

          from EJB point of view, everything you are doing is ok. Your member variable categorySubcategoriesFacade is not injected. As mentioned in my previous post, CXF deploys your webservice but does no EJB injection.

           

          Best regards,

          Mark

          • 2. Re: Failed to invoke CXF service in JBOSS 6.
            Sam W Expert

            Hi Mark,

             

            Thank you for the suggestion.

            I have implemented the web service in a EAR file.

            This time the ejb module (jar) could not deploy with the following WARN:

             

             

            19:51:08,604 INFO  [org.jboss.jpa.deployment.PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=category4-ws-ear.ear/category4-ws-ejb.jar#HousewareCategoryPU

            19:51:08,849 INFO  [org.hibernate.annotations.common.Version] Hibernate Commons Annotations 3.2.0.Final

            19:51:08,859 INFO  [org.hibernate.cfg.Environment] Hibernate 3.6.0.Final

            19:51:08,861 INFO  [org.hibernate.cfg.Environment] hibernate.properties not found

            19:51:08,865 INFO  [org.hibernate.cfg.Environment] Bytecode provider name : javassist

            19:51:08,872 INFO  [org.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling

            19:51:08,996 INFO  [org.hibernate.ejb.Version] Hibernate EntityManager 3.6.0.Final

            19:51:09,028 INFO  [org.hibernate.ejb.Ejb3Configuration] Processing PersistenceUnitInfo [

                    name: HousewareCategoryPU

                    ...]

            19:51:09,042 WARN  [org.hibernate.ejb.Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly.PersistenceUnitInfo.getNewTempClassLoader() is null.

            19:51:09,114 INFO  [org.hibernate.cfg.AnnotationBinder] Binding entity from annotated class: ix.houseware.category.entity.CategorySubcategories

            19:51:09,143 INFO  [org.hibernate.cfg.annotations.QueryBinder] Binding Named query: CategorySubcategories.findAll => SELECT c FROM CategorySubcategories c

            19:51:09,143 INFO  [org.hibernate.cfg.annotations.QueryBinder] Binding Named query: CategorySubcategories.findByCategoryId => SELECT c FROM CategorySubcategories c WHERE c.categoryId = :categoryId

            19:51:09,143 INFO  [org.hibernate.cfg.annotations.QueryBinder] Binding Named query: CategorySubcategories.findByCategoryName => SELECT c FROM CategorySubcategories c WHERE c.categoryName = :categoryName

             

             

            Here is my ear file:

             

             

            jar -xvf ../category4-ws-ear.ear

              created: META-INF/

            inflated: META-INF/MANIFEST.MF

              created: lib/

            inflated: category4-ws-ejb.jar

            inflated: category4-ws-web.war

            inflated: lib/commons-lang-2.6.jar

            inflated: lib/dom4j-1.6.1.jar

            inflated: lib/jboss-ejb-api_3.1_spec-1.0.1.Final.jar

            inflated: lib/joda-time-2.0.jar

            inflated: lib/log4j-1.2.14.jar

            inflated: lib/slf4j-api-1.5.8.jar

            inflated: lib/slf4j-log4j12-1.5.8.jar

            inflated: lib/xml-apis-1.0.b2.jar

            inflated: META-INF/application.xml

              created: META-INF/maven/

              created: META-INF/maven/ix.houseware.category/

              created: META-INF/maven/ix.houseware.category/category4-ws-ear/

            inflated: META-INF/maven/ix.houseware.category/category4-ws-ear/pom.xml

            inflated: META-INF/maven/ix.houseware.category/category4-ws-ear/pom.properties

             

             

            ejb module:

             

             

            jar -tvf category4-ws-ejb.jar

                 0 Tue Oct 04 20:49:50 EST 2011 META-INF/

               122 Tue Oct 04 20:49:48 EST 2011 META-INF/MANIFEST.MF

                 0 Tue Oct 04 20:49:48 EST 2011 ix/

                 0 Tue Oct 04 20:49:48 EST 2011 ix/caller/

                 0 Tue Oct 04 20:49:48 EST 2011 ix/houseware/

                 0 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/

                 0 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/

                 0 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/facade/

                 0 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/utils/

              1436 Tue Oct 04 20:49:48 EST 2011 ix/caller/CallerBean.class

               307 Tue Oct 04 20:49:48 EST 2011 ix/caller/CallerLocal.class

               738 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/CalculatorBean.class

               215 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/CalculatorLocal.class

              4182 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/CategoryImages.class

              1846 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/CategoryImagesPK.class

              4676 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/CategorySubcategories.class

              4050 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/facade/AbstractFacade.class

              4149 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/facade/CategoryImagesFacade.class

              1359 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/facade/CategorySubcategoriesFacade.class

               375 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/facade/CategorySubcategoriesFacadeLocal.class

              1261 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/entity/Order.class

              1212 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/utils/DateUtils$CalculationQuarter.class

            12588 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/utils/DateUtils.class

              2204 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/utils/Quarter.class

               771 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/utils/RandomNumberUtil.class

              3013 Tue Oct 04 20:49:48 EST 2011 ix/houseware/category/utils/XmlParser.class

               338 Tue Oct 04 20:49:46 EST 2011 META-INF/application.xml

              1103 Tue Oct 04 20:49:46 EST 2011 META-INF/persistence-junit.xml

               702 Tue Oct 04 20:49:46 EST 2011 META-INF/persistence.xml

               694 Tue Oct 04 20:49:46 EST 2011 META-INF/persistence_jboss7.xml

                 0 Tue Oct 04 20:49:50 EST 2011 META-INF/maven/

                 0 Tue Oct 04 20:49:50 EST 2011 META-INF/maven/ix.houseware.category/

                 0 Tue Oct 04 20:49:50 EST 2011 META-INF/maven/ix.houseware.category/category4-ws-ejb/

              6503 Tue Oct 04 19:55:40 EST 2011 META-INF/maven/ix.houseware.category/category4-ws-ejb/pom.xml

               134 Tue Oct 04 20:49:50 EST 2011 META-INF/maven/ix.houseware.category/category4-ws-ejb/pom.properties

             

             

            Very appreciate for your suggestion again.

            Thanks

            Sam