1 Reply Latest reply on Sep 8, 2012 5:57 AM by Lars Aaslin

    Implementing RESTful views of an EJB with local interfaces

    Lars Aaslin Newbie

      Hi,

       

      I'm trying to expose an EJB through both a local business interface and a JAX-RS interface, but are getting the following error, running on a JBoss AS 7:

       

      ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.unit."finance.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."finance.war".PARSE: Failed to process phase PARSE of deployment "finance.war"

                at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]

                at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]

      Caused by: java.lang.IllegalArgumentException: JBAS011046: A component named 'FileServiceImpl' is already defined in this module

                at org.jboss.as.ee.component.EEModuleDescription.addComponent(EEModuleDescription.java:137)

                at org.jboss.as.ejb3.deployment.processors.EJBComponentDescriptionFactory.addComponent(EJBComponentDescriptionFactory.java:60)

                at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processSessionBeans(SessionBeanComponentDescriptionFactory.java:157)

                at org.jboss.as.ejb3.deployment.processors.SessionBeanComponentDescriptionFactory.processAnnotations(SessionBeanComponentDescriptionFactory.java:86)

                at org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.processAnnotations(AnnotatedEJBComponentDescriptionDeploymentUnitProcessor.java:58)

                at org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.deploy(AbstractDeploymentUnitProcessor.java:81)

                at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]

                ... 5 more

       

      This i my code:

       

      public interface FileService {

           ...

      }

       

      public interface FileServiceLocalBusiness extends FileService {

           ...

      }

       

      @Path("file")

      @Consumes({ "application/json" })

      @Produces({ "application/json" })

      public interface FileServiceWs extends FileService {

           ...

      }

       

      @Stateless

      @Local({FileServiceLocalBusiness.class, FileServiceWs.class})

      public class FileServiceImpl implements FileServiceLocalBusiness, FileServiceWs {

           ...

      }

       

      I have been trying to follow this guide http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Ftwbs_jaxrs_ejb_nointerface.html but I must be misunderstanding something or is this procedure not supported on JBoss AS?

       

      Any suggestions to point me in the right direction would be most appreciated.

        • 1. Re: Implementing RESTful views of an EJB with local interfaces
          Lars Aaslin Newbie

          Solved the problem. Removed @Local({FileServiceLocalBusiness.class, FileServiceWs.class}) from the implementing class and put it in the business interfaces instead.

           

          public interface FileService {

               ...

          }

           

          @Local

          public interface FileServiceLocalBusiness extends FileService {

               ...

          }

           

          @Local

          @Path("file")

          @Consumes({ "application/json" })

          @Produces({ "application/json" })

          public interface FileServiceWs extends FileService {

               ...

          }

           

          @Stateless

          public class FileServiceImpl implements FileServiceLocalBusiness, FileServiceWs {

               ...

          }