2 Replies Latest reply on Jul 27, 2017 1:32 AM by Dominik Sammer

    Injection of enterprise beans in a SwitchYard Service Task

    Dominik Sammer Newbie

      Hey there!

       

      I have spent a lot of time to find out how I can inject a Java Enterprise Bean from a deployed ear. In general I have two different EARs, one with my database services and other things and another one that contains different SwitchYard Jars. I want to inject a Remote Service in a SwitchYardServiceTask class, that is part of a BPMN process. Normally that shouldn't be a big task but with SwitchYard, that we use to have a Workflow, there are some troubles to do that. The SwitchYard Project is packaged within a jar, that is bundled in an EAR that is deployed at the same Wildfly instance as the other ear.

      As the application server we use Wildfly 10. My deployed service does work correctly but I just cannot inject that service in my SwitchYard Service Task. The deployment section of this service looks like that:

      2017-07-25 08:42:21,053 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-8) WFLYEJB0473: JNDI bindings for session bean named 'transportationOrderService' in deployment unit 'subdeployment "shipping-rest-1.0.war" of deployment "shipping-application-1.0.ear"' are as follows: java:global/shipping-application/shipping-rest-1.0/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceLocaljava:app/shipping-rest-1.0/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceLocaljava:module/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceLocaljava:global/shipping-application/shipping-rest-1.0/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceRemotejava:app/shipping-rest-1.0/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceRemotejava:module/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceRemotejava:jboss/exported/shipping-application/shipping-rest-1.0/transportationOrderService!at.locoso.laps.shipping.transportationorder.dal.transportationorderdalmgmt.serviceapi.TransportationOrderServiceRemote

      My SwitchYard ServiceTask looks like that:

      @Service(ReadTransportationOrder.class) public class ReadTransportationOrderBean implements ReadTransportationOrder {  @EJB(mappedName = "java:global/shipping-application/shipping-rest-1.0/transportationOrderService") private TransportationOrderServiceRemote transportationOrderService;  public void someMethod(SomeParameter parameter) {..} }

      If I try to deploy that SwitchYardService that is bundled in another EAR I get the following exception:

      2017-07-25 09:20:56,129 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.subunit."shipping-if-application-1.0.ear"."ExpTransportationOrderProcess-1.0.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.subunit."shipping-if-application-1.0.ear"."ExpTransportationOrderProcess-1.0.jar".SwitchYardService: org.switchyard.SwitchYardException: SWITCHYARD030412: Unknown Service name '{urn:at.locoso.laps.shipping.exchange:ExpTransportationOrderProcess:1.0}ReadTransportationOrder'. at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:84) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.switchyard.SwitchYardException: SWITCHYARD030412: Unknown Service name '{urn:at.locoso.laps.shipping.exchange:ExpTransportationOrderProcess:1.0}ReadTransportationOrder'. at org.switchyard.component.bean.deploy.BeanComponentActivator.activateService(BeanComponentActivator.java:90) at org.switchyard.deploy.internal.Deployment.deployImplementations(Deployment.java:554) at org.switchyard.deploy.internal.Deployment.start(Deployment.java:144) at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:158) at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:77) ... 5 more

      If I remove the property with the EJB annotation the service is deployed correctly.

      So I think the problem is, that I cannot inject remote services in the SwitchYard ServiceTask of my BPMN Process, but I don't understand why. Does anybody know what my mistake is and how I can solve that?