8 Replies Latest reply on Jul 31, 2013 6:27 AM by Lukasz Sroka

    Inject SY service from jarapp into webapp

    Lukasz Sroka Newbie

      Hello. In previous topic https://community.jboss.org/thread/230820?tstart=0 i have added post, but i think that topic was closed so I made new one.
      This time i'm really stuck with injection. Let me introduce what is the problem: To my test app hellosy.war i am traying to inject service from another SY project, lets name it switchyard-example.

      In hellosy app i have switchyard.xml like this.

                      

      <?xml version="1.0" encoding="UTF-8"?>

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="hellosy" targetNamespace="urn:com.example.hellosy:hellosy:1.0.0-SNAPSHOT">

        <sca:composite name="hellosy" targetNamespace="urn:com.example.hellosy:hellosy:1.0.0-SNAPSHOT">

          <sca:component name="InternalTestServiceBean">

            <bean:implementation.bean class="com.example.hellosy.InternalTestServiceBean"/>

            <sca:service name="InternalTestService">

              <sca:interface.java interface="com.example.hellosy.InternalTestService"/>

            </sca:service>

            <sca:reference name="ExternalTestService">

              <sca:interface.java interface="com.example.switchyard.switchyard_example.ExternalTestService"/>

            </sca:reference>

          </sca:component>

          <sca:service name="InternalTestService" promote="InternalTestServiceBean/InternalTestService">

            <sca:interface.java interface="com.example.hellosy.InternalTestService"/>

          </sca:service>

          <sca:reference name="ExternalTestService" multiplicity="0..1" promote="InternalTestServiceBean/ExternalTestService">

            <sca:interface.java interface="com.example.switchyard.switchyard_example.ExternalTestService"/>

          </sca:reference>

        </sca:composite>

      </switchyard>

                                                                           

      Like you see in switchyard example i have service  ExternalService which is injecting into InternalService form hellosy.war app

       

      When i want to deploy this 2 projects (war and jar) i have following error.

      16:36:40,299 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "hellosy.war"

      16:36:40,299 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "switchyard-example.jar"

      16:36:40,529 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016002: Processing weld deployment hellosy.war

      16:36:40,577 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016005: Starting Services for CDI deployment: hellosy.war

      16:36:40,597 INFO  [org.jboss.weld.Version] (MSC service thread 1-8) WELD-000900 1.1.10 (Final)

      16:36:40,630 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016008: Starting weld service for deployment hellosy.war

      16:36:40,829 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

          at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)

          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:1145) [rt.jar:1.7.0_25]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

          at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311)

          at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)

          at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)

          at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)

          at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)

          at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)

          at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)

          at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)

          at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)

          ... 5 more

       

      16:36:40,837 INFO  [org.jboss.as] (MSC service thread 1-8) JBAS015951: Admin console listening on http://127.0.0.1:9990

      16:36:40,838 ERROR [org.jboss.as] (MSC service thread 1-8) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2573ms - Started 210 of 305 services (21 services failed or missing dependencies, 71 services are passive or on-demand)

      16:36:41,042 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015871: Deploy of deployment "hellosy.war" was rolled back with no failure message

      16:36:41,043 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "switchyard-example.jar" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.module.service.\"deployment.switchyard-example.jar\".mainjboss.module.spec.service.\"deployment.switchyard-excluded.jar\".mainMissing[jboss.module.service.\"deployment.switchyard-example.jar\".mainjboss.module.spec.service.\"deployment.switchyard-excluded.jar\".main]"]}

      16:36:41,064 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment hellosy.war in 21ms

      16:36:41,064 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment switchyard-example.jar in 20ms

      16:36:41,065 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report

      JBAS014775:    New missing/unsatisfied dependencies:

            service jboss.module.spec.service."deployment.switchyard-excluded.jar".main (missing) dependents: [service jboss.module.service."deployment.switchyard-example.jar".main]

      JBAS014777:   Services which failed to start:      service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

       

      16:36:41,068 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.module.service.\"deployment.switchyard-example.jar\".mainjboss.module.spec.service.\"deployment.switchyard-excluded.jar\".mainMissing[jboss.module.service.\"deployment.switchyard-example.jar\".mainjboss.module.spec.service.\"deployment.switchyard-excluded.jar\".main]"]}}}

      16:36:41,070 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS014654: Composite operation was rolled back

      I have atached this 2 projects.

      Thanks for any help.

      Or maybe this is not posible to inject service from another project into other web project.

        • 1. Re: Inject SY service from jarapp into webapp
          Keith Babo Master

          A binding is required in order to communicate between applications in SwitchYard.  Even if the applications are in the same runtime (or even the same EAR), a binding is required.  Of course, you don't necessarily want to go out of process over a transport to communicate between applications, so we provide a binding which is capable of handling local communication called the SCA binding.  There is a quickstart which demonstrates this:

           

          https://github.com/jboss-switchyard/quickstarts/tree/master/ear-deployment

           

          The above application has a provider service which has an SCA binding:

          https://github.com/jboss-switchyard/quickstarts/blob/master/ear-deployment/order-service/src/main/resources/META-INF/switchyard.xml#L6

           

          It also has a consumer which uses a reference to consume the service:

          https://github.com/jboss-switchyard/quickstarts/blob/master/ear-deployment/order-consumer/src/main/resources/META-INF/switchyard.xml#L25

           

          Here are the basic steps you need to follow:

          1) In the project which provides the service, promote the service you want to consume (interface type should be com.example.switchyard.switchyard_example.ExternalTestService) and add a binding.sca to the promoted service.

          2) Promote the reference in your webapp switchyard.xml and add a binding.sca to that.  Make sure you map the targetNamespace value correctly.

          3) You have two applications sharing the same Java interface, which means you will only want to include one copy of that class. You can do this by including the class in one application and then adding a dependency to this application in your other application.  Or you can create a distinct jar to hold shared classes and deploy both applications in an EAR (see ear-deployment quickstart for example).

          • 2. Re: Inject SY service from jarapp into webapp
            Lukasz Sroka Newbie

            Thanks for answer but i have this error again.
            I added binding sca like you wrote i both switchyard.xml

             

            hellosy: switchyard.xml

            <?xml version="1.0" encoding="UTF-8"?>

            <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:sy="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="hellosy" targetNamespace="urn:com.example.hellosy:hellosy:1.0.0-SNAPSHOT">

              <sca:composite name="hellosy" targetNamespace="urn:com.example.hellosy:hellosy:1.0.0-SNAPSHOT">

                <sca:component name="InternalTestServiceBean">

                  <bean:implementation.bean class="com.example.hellosy.InternalTestServiceBean"/>

                  <sca:service name="InternalTestService">

                    <sca:interface.java interface="com.example.hellosy.InternalTestService"/>

                  </sca:service>

                  <sca:reference name="ExternalTestService">

                    <sca:interface.java interface="com.example.switchyard.switchyard_example.ExternalTestService"/>

                  </sca:reference>

                </sca:component>

                <sca:service name="InternalTestService" promote="InternalTestServiceBean/InternalTestService">

                  <sca:interface.java interface="com.example.hellosy.InternalTestService"/>

                </sca:service>

                <sca:reference name="ExternalTestService" multiplicity="0..1" promote="InternalTestServiceBean/ExternalTestService">

                  <sca:interface.java interface="com.example.switchyard.switchyard_example.ExternalTestService"/>

                  <sca:binding.sca sy:targetNamespace="urn:com.example.switchyard:switchyard-example:1.0"/>

                </sca:reference>

              </sca:composite>

            </switchyard>

             

            sy-example: switchyard.xml

            <?xml version="1.0" encoding="UTF-8"?>

            <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="switchyard-example" targetNamespace="urn:com.example.switchyard:switchyard-example:1.0">

              <sca:composite name="switchyard-example" targetNamespace="urn:com.example.switchyard:switchyard-example:1.0">

                <sca:component name="ExternalTestServiceBean">

                  <bean:implementation.bean class="com.example.switchyard.switchyard_example.ExternalTestServiceBean"/>

                  <sca:service name="ExternalTestService">

                    <sca:interface.java interface="com.example.switchyard.switchyard_example.ExternalTestService"/>

                  </sca:service>

                </sca:component>

                <sca:service name="ExternalTestService" promote="ExternalTestServiceBean/ExternalTestService">

                  <sca:interface.java interface="com.example.switchyard.switchyard_example.ExternalTestService"/>

                  <sca:binding.sca/>

                </sca:service>

              </sca:composite>

            </switchyard>

             

            error:

            14:14:52,212 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "hellosy.war"

            14:14:52,212 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876: Starting deployment of "switchyard-example.jar"

            14:14:52,552 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016002: Processing weld deployment switchyard-example.jar

            14:14:52,555 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016002: Processing weld deployment hellosy.war

            14:14:52,581 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016005: Starting Services for CDI deployment: switchyard-example.jar

            14:14:52,600 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016005: Starting Services for CDI deployment: hellosy.war

            14:14:52,601 INFO  [org.jboss.weld.Version] (MSC service thread 1-8) WELD-000900 1.1.10 (Final)

            14:14:52,615 INFO  [org.switchyard] (MSC service thread 1-8) Deploying SwitchYard application 'switchyard-example.jar'

            14:14:52,622 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) JBAS016008: Starting weld service for deployment switchyard-example.jar

            14:14:52,634 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016008: Starting weld service for deployment hellosy.war

            14:14:52,807 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

                at org.jboss.as.weld.services.WeldService.start(WeldService.java:83)

                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:1145) [rt.jar:1.7.0_25]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

                at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

            Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

                at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311)

                at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)

                at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)

                at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)

                at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)

                at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)

                at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)

                at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:83)

                at org.jboss.as.weld.services.WeldService.start(WeldService.java:76)

                ... 5 more

             

            14:14:52,819 INFO  [org.switchyard] (MSC service thread 1-7) Starting SwitchYard service

            14:14:52,963 INFO  [org.apache.camel.management.ManagementStrategyFactory] (MSC service thread 1-7) JMX enabled.

            14:14:52,974 INFO  [org.switchyard.security.SecurityProvider] (MSC service thread 1-7) Using SecurityProvider implementation: org.switchyard.security.jboss.JBossJaasSecurityProvider

            14:14:52,975 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-7) Apache Camel 0.8.0.Final (CamelContext: camel-1) is starting

            14:14:52,976 INFO  [org.apache.camel.management.DefaultManagementLifecycleStrategy] (MSC service thread 1-7) StatisticsLevel at All so enabling load performance statistics

            14:14:53,049 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-7) Loaded 179 type converters

            14:14:53,068 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-7) Total 0 routes, of which 0 is started.

            14:14:53,069 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-7) Apache Camel 0.8.0.Final (CamelContext: camel-1) started in 0.093 seconds

            14:14:53,076 INFO  [org.switchyard.component.sca.deploy.SCAActivator] (MSC service thread 1-7) Unable to resolve cache-container cluster.  clustering for <binding.sca> will not be available for services and references.

            14:14:53,172 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-7) Loaded 179 type converters

            14:14:53,563 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-7) Route: direct:{urn:com.example.switchyard:switchyard-example:1.0}ExternalTestService started and consuming from: Endpoint[direct://%7Burn:com.example.switchyard:switchyard-example:1.0%7DExternalTestService]

            14:14:53,659 INFO  [org.switchyard.as7.extension.cluster.RemoteEndpointListener] (MSC service thread 1-7) Published Remote Service Endpoint /switchyard-remote

            14:14:53,662 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015951: Admin console listening on http://127.0.0.1:9990

            14:14:53,663 ERROR [org.jboss.as] (MSC service thread 1-7) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 3375ms - Started 230 of 324 services (20 services failed or missing dependencies, 71 services are passive or on-demand)

            14:14:53,865 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "hellosy.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"hellosy.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"hellosy.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]"}}

            14:14:53,867 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015871: Deploy of deployment "switchyard-example.jar" was rolled back with no failure message

            14:14:53,875 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-1) Apache Camel 0.8.0.Final (CamelContext: camel-1) is shutting down

            14:14:53,876 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] (MSC service thread 1-1) Starting to graceful shutdown 1 routes (timeout 300 seconds)

            14:14:53,878 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] (Camel (camel-1) thread #1 - ShutdownTask) Route: direct:{urn:com.example.switchyard:switchyard-example:1.0}ExternalTestService shutdown complete, was consuming from: Endpoint[direct://%7Burn:com.example.switchyard:switchyard-example:1.0%7DExternalTestService]

            14:14:53,879 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] (MSC service thread 1-1) Graceful shutdown of 1 routes completed in 0 seconds

            14:14:53,880 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015877: Stopped deployment hellosy.war in 15ms

            14:14:53,883 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-1) TypeConverterRegistry utilization[attempts=0, hits=0, misses=0, failures=0] mappings[total=179, misses=0]

            14:14:53,885 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-1) Apache Camel 0.8.0.Final (CamelContext: camel-1) is shutdown in 0.010 seconds. Uptime 0.910 seconds.

            14:14:53,886 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016009: Stopping weld service for deployment switchyard-example.jar

            14:14:53,893 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment switchyard-example.jar in 24ms

            14:14:53,894 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report

            JBAS014777:   Services which failed to start:      service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.msc.service.StartException in service jboss.deployment.unit."hellosy.war".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

             

            14:14:53,896 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS014654: Composite operation was rolled back

            14:14:53,897 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"hellosy.war\".WeldService" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"hellosy.war\".WeldService: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]"}}}}

             

            I have also dependency in hellosy pom.xml to switchyard-example to share this interface - just like you wrote in point 3)


            hellosy pom.xml

            <?xml version="1.0" encoding="UTF-8"?>

            <project

                xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"

                xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

                <modelVersion>4.0.0</modelVersion>

                <groupId>com.example.hellosy</groupId>

                <artifactId>hellosy</artifactId>

                <version>1.0.0-SNAPSHOT</version>

                <packaging>war</packaging>

                <properties>

                    <switchyard.version>1.0.0.Final</switchyard.version>

                </properties>

                <dependencyManagement>

                    <dependencies>

                        <dependency>

                            <groupId>org.jboss.spec</groupId>

                            <artifactId>jboss-javaee-6.0</artifactId>

                            <version>3.0.2.Final</version>

                            <type>pom</type>

                            <scope>import</scope>

                        </dependency>

                        <dependency>

                            <groupId>org.richfaces</groupId>

                            <artifactId>richfaces-bom</artifactId>

                            <version>4.3.3.Final</version>

                            <type>pom</type>

                            <scope>import</scope>

                        </dependency>

                    </dependencies>

                </dependencyManagement>

                <dependencies>

                    <dependency>

                        <groupId>org.jboss.spec.javax.servlet</groupId>

                        <artifactId>jboss-servlet-api_3.0_spec</artifactId>

                        <scope>provided</scope>

                    </dependency>

                    <dependency>

                        <groupId>org.jboss.spec.javax.faces</groupId>

                        <artifactId>jboss-jsf-api_2.1_spec</artifactId>

                        <scope>provided</scope>

                    </dependency>

                    <dependency>

                        <groupId>javax.enterprise</groupId>

                        <artifactId>cdi-api</artifactId>

                        <scope>provided</scope>

                    </dependency>

                    <dependency>

                        <groupId>org.jboss.spec.javax.annotation</groupId>

                        <artifactId>jboss-annotations-api_1.1_spec</artifactId>

                        <scope>provided</scope>

                    </dependency>

                    <dependency>

                        <groupId>org.richfaces.ui</groupId>

                        <artifactId>richfaces-components-ui</artifactId>

                        <version>4.3.3.Final</version>

                    </dependency>

                    <dependency>

                        <groupId>org.richfaces.core</groupId>

                        <artifactId>richfaces-core-impl</artifactId>

                        <version>4.3.3.Final</version>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard</groupId>

                        <artifactId>switchyard-api</artifactId>

                        <version>${switchyard.version}</version>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard</groupId>

                        <artifactId>switchyard-transform</artifactId>

                        <version>${switchyard.version}</version>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard</groupId>

                        <artifactId>switchyard-validate</artifactId>

                        <version>${switchyard.version}</version>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard</groupId>

                        <artifactId>switchyard-plugin</artifactId>

                        <version>${switchyard.version}</version>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard</groupId>

                        <artifactId>switchyard-test</artifactId>

                        <version>${switchyard.version}</version>

                        <scope>test</scope>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard.components</groupId>

                        <artifactId>switchyard-component-test-mixin-cdi</artifactId>

                        <version>${switchyard.version}</version>

                        <scope>test</scope>

                    </dependency>

                    <dependency>

                        <groupId>org.switchyard.components</groupId>

                        <artifactId>switchyard-component-bean</artifactId>

                        <version>${switchyard.version}</version>

                    </dependency>

                    <dependency>

                        <groupId>com.example.switchyard</groupId>

                        <artifactId>switchyard-example</artifactId>

                        <version>0.0.1-SNAPSHOT</version>

                </dependency>

                    <dependency>

                        <groupId>org.switchyard.components</groupId>

                        <artifactId>switchyard-component-sca</artifactId>

                        <version>${switchyard.version}</version>

                    </dependency>

                </dependencies>

                <repositories>

                    <repository>

                        <id>JBOSS_NEXUS</id>

                        <url>http://repository.jboss.org/nexus/content/groups/public</url>

                    </repository>

                </repositories>

                <pluginRepositories>

                    <pluginRepository>

                        <id>jboss-public-repository</id>

                        <name>JBoss Public Maven Repository</name>

                        <url>http://repository.jboss.org/nexus/content/groups/public</url>

                    </pluginRepository>

                </pluginRepositories>

                <build>

                    <finalName>hellosy</finalName>

                    <plugins>

                        <plugin>

                            <artifactId>maven-compiler-plugin</artifactId>

                            <version>2.3.2</version>

                            <configuration>

                                <source>1.7</source>

                                <target>1.7</target>

                                <encoding>UTF-8</encoding>

                            </configuration>

                        </plugin>

                        <plugin>

                            <artifactId>maven-war-plugin</artifactId>

                            <version>2.1.1</version>

                            <configuration>

                                <failOnMissingWebXml>false</failOnMissingWebXml>

                                <packagingExcludes>

                                    <!-- -->

                                    WEB-INF/lib/*.jar,

                                    WEB-INF/classes/META-INF/switchyard.xml,

                                </packagingExcludes>

                                <webResources>

                                    <resource>

                                        <directory>target/classes/META-INF</directory>

                                        <targetPath>WEB-INF</targetPath>

                                        <includes>

                                            <include>switchyard.xml</include>

                                        </includes>

                                    </resource>

                                </webResources>

                                <archive>

                                    <manifestEntries>

                                        <Dependencies>deployment.switchyard-example.jar</Dependencies>

                                    </manifestEntries>

                                </archive>

                            </configuration>

                        </plugin>

                        <plugin>

                            <groupId>org.switchyard</groupId>

                            <artifactId>switchyard-plugin</artifactId>

                            <version>${switchyard.version}</version>

                            <executions>

                                <execution>

                                    <goals>

                                        <goal>configure</goal>

                                    </goals>

                                </execution>

                            </executions>

                            <configuration>

                                <scannerClassNames>

                                    <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>

                                </scannerClassNames>

                            </configuration>

                        </plugin>

                    </plugins>

                </build>

            </project>

             

            Please look at this when you can. Maybe i missed something more.

            • 3. Re: Inject SY service from jarapp into webapp
              Keith Babo Master

              A Maven dependency is only going to help you resolve the class in your project build.  You need to package as an EAR or use the AS 7 dependency support for deployments which is documented here:

               

              https://docs.jboss.org/author/display/AS71/Class+Loading+in+AS7

               

              Follow the instructions to add Dependencies entry in the manifest of your war or use a jboss-deployment-structure.xml.

              • 4. Re: Inject SY service from jarapp into webapp
                Lukasz Sroka Newbie

                <archive>

                                        <manifestEntries>

                                            <Dependencies>deployment.switchyard-example.jar</Dependencies>

                                        </manifestEntries>

                                    </archive>

                I think this part of pom do this, but i'm not sure 100%

                 

                This is my MANIFEST after deplyoment

                Manifest-Version: 1.0

                Built-By: lukasz

                Build-Jdk: 1.7.0_25

                Created-By: Maven Integration for Eclipse

                Dependencies: deployment.switchyard-example.jar

                 

                • 5. Re: Inject SY service from jarapp into webapp
                  Keith Babo Master

                  Looked at your projects and the wiring is setup correctly.  Can you confirm you're using a 1.0.0.Final runtime?

                  • 6. Re: Inject SY service from jarapp into webapp
                    Lukasz Sroka Newbie

                    i can confirm that.
                    I have tested it on  switchyard-as7-0.8 and jboss-eap-6.1 with switchyard-installer-1.0.0.Final.zip installed via ant from this page https://docs.jboss.org/author/display/SWITCHYARD/Installing+SwitchYard

                     

                    This full server-log:

                    15:46:34,896 INFO  [org.jboss.modules] (main) JBoss Modules version 1.2.0.Final-redhat-1

                    15:46:35,030 INFO  [org.jboss.msc] (main) JBoss MSC version 1.0.4.GA-redhat-1

                    15:46:35,079 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015899: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) starting

                    15:46:35,734 INFO  [org.switchyard] (ServerService Thread Pool -- 10) SwitchYard version 1.0.0.Final

                    15:46:35,785 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found hellosy.war in deployment directory. To trigger deployment create a file called hellosy.war.dodeploy

                    15:46:35,805 INFO  [org.xnio] (MSC service thread 1-2) XNIO Version 3.0.7.GA-redhat-1

                    15:46:35,807 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)

                    15:46:35,810 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.0.7.GA-redhat-1

                    15:46:35,818 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 3.2.16.GA-redhat-1

                    15:46:35,885 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 30) JBAS010280: Activating Infinispan subsystem.

                    15:46:35,919 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 36) JBAS012605: Activated the following JSF Implementations: [main, 1.2]

                    15:46:35,949 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem

                    15:46:35,951 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 26) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

                    15:46:35,959 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 43) JBAS013171: Activating Security Subsystem

                    15:46:35,975 INFO  [org.jboss.as.naming] (MSC service thread 1-7) JBAS011802: Starting Naming Service

                    15:46:35,976 INFO  [org.jboss.as.security] (MSC service thread 1-6) JBAS013170: Current PicketBox version=4.0.17.Final-redhat-1

                    15:46:35,980 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 26) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)

                    15:46:35,983 INFO  [org.switchyard] (ServerService Thread Pool -- 49) Activating SwitchYard Subsystem

                    15:46:35,985 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]

                    15:46:35,985 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (IronJacamar 1.0.17.Final-redhat-1)

                    15:46:36,021 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 47) JBAS015537: Activating WebServices Extension

                    15:46:36,229 INFO  [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.1.3.Final-redhat-3

                    15:46:36,496 INFO  [org.apache.coyote.http11] (MSC service thread 1-4) JBWEB003001: Coyote HTTP/1.1 initializing on : http-/0.0.0.0:8080

                    15:46:36,556 INFO  [org.apache.coyote.http11] (MSC service thread 1-4) JBWEB003000: Coyote HTTP/1.1 starting on: http-/0.0.0.0:8080

                    15:46:36,691 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/jbpmDS]

                    15:46:36,692 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]

                    15:46:36,701 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) JBAS010400: Bound data source [java:jboss/datasources/MySqlDSSOA]

                    15:46:36,729 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on 0.0.0.0:4447

                    15:46:36,730 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory /home/lukasz/jboss-eap-6.1/standalone/deployments

                    15:46:36,731 INFO  [org.jboss.as.remoting] (MSC service thread 1-7) JBAS017100: Listening on 127.0.0.1:9999

                    15:46:36,732 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "hellosy.war" (runtime-name: "hellosy.war")

                    15:46:36,732 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "switchyard-example.jar" (runtime-name: "switchyard-example.jar")

                    15:46:36,998 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016002: Processing weld deployment switchyard-example.jar

                    15:46:37,038 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016002: Processing weld deployment hellosy.war

                    15:46:37,058 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016005: Starting Services for CDI deployment: switchyard-example.jar

                    15:46:37,097 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016005: Starting Services for CDI deployment: hellosy.war

                    15:46:37,118 INFO  [org.jboss.weld.Version] (MSC service thread 1-3) WELD-000900 1.1.13 (redhat)

                    15:46:37,138 INFO  [org.switchyard] (MSC service thread 1-3) Deploying SwitchYard application 'switchyard-example.jar'

                    15:46:37,163 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016008: Starting weld service for deployment hellosy.war

                    15:46:37,163 INFO  [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016008: Starting weld service for deployment switchyard-example.jar

                    15:46:37,347 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."hellosy.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."hellosy.war".WeldStartService: Failed to start service

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_25]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_25]

                        at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_25]

                    Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [ExternalTestService] with qualifiers [@Default] at injection point [[field] @Inject com.example.hellosy.InternalTestServiceBean.extTestService]

                        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:311)

                        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)

                        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)

                        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)

                        at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)

                        at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)

                        at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)

                        at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:64)

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

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

                        ... 3 more

                     

                    15:46:37,356 INFO  [org.switchyard] (MSC service thread 1-4) Starting SwitchYard service

                    15:46:37,499 INFO  [org.apache.camel.management.ManagementStrategyFactory] (MSC service thread 1-4) JMX enabled.

                    15:46:37,513 INFO  [org.switchyard.security.spi.SecurityProvider] (MSC service thread 1-4) Using SecurityProvider implementation: org.switchyard.security.jboss.spi.JBossJaasSecurityProvider

                    15:46:37,516 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Apache Camel 1.0.0.Final (CamelContext: camel-1) is starting

                    15:46:37,516 INFO  [org.apache.camel.management.DefaultManagementLifecycleStrategy] (MSC service thread 1-4) StatisticsLevel at All so enabling load performance statistics

                    15:46:37,600 INFO  [org.apache.deltaspike.core.util.ProjectStageProducer] (MSC service thread 1-4) Computed the following DeltaSpike ProjectStage: Production

                    15:46:37,605 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-4) Loaded 179 type converters

                    15:46:37,625 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Total 0 routes, of which 0 is started.

                    15:46:37,626 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Apache Camel 1.0.0.Final (CamelContext: camel-1) started in 0.109 seconds

                    15:46:37,632 INFO  [org.switchyard.component.sca.deploy.SCAActivator] (MSC service thread 1-4) Unable to resolve cache-container cluster.  clustering for <binding.sca> will not be available for services and references.

                    15:46:37,736 INFO  [org.apache.camel.impl.converter.DefaultTypeConverter] (MSC service thread 1-4) Loaded 179 type converters

                    15:46:38,146 INFO  [org.switchyard.common.camel.SwitchYardCamelContext] (MSC service thread 1-4) Route: direct:{urn:com.example.switchyard:switchyard-example:1.0}ExternalTestService started and consuming from: Endpoint[direct://%7Burn:com.example.switchyard:switchyard-example:1.0%7DExternalTestService]

                    15:46:38,228 INFO  [org.switchyard.as7.extension.cluster.RemoteEndpointListener] (MSC service thread 1-4) Published Remote Service Endpoint /switchyard-remote

                    15:46:38,468 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 27) JBAS018559: Deployed "hellosy.war" (runtime-name : "hellosy.war")

                    15:46:38,469 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 27) JBAS018559: Deployed "switchyard-example.jar" (runtime-name : "switchyard-example.jar")

                    15:46:38,470 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report

                    JBAS014777:   Services which failed to start:      service jboss.deployment.unit."hellosy.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."hellosy.war".WeldStartService: Failed to start service

                     

                    15:46:38,516 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management

                    15:46:38,517 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990

                    15:46:38,517 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) started (with errors) in 3887ms - Started 231 of 315 services (17 services failed or missing dependencies, 64 services are passive or on-demand)

                    • 7. Re: Inject SY service from jarapp into webapp
                      Keith Babo Master

                      I tried this starting with the most recent copy of the applications you have attached to this thread and my results are different.  The first error I hit is that your deployment dependency was bad in the webapp.  You had this:

                       

                      <archive>
                         <manifestEntries>
                            <Dependencies>deployment.switchyard-example.jar</Dependencies>
                          </manifestEntries>
                      </archive>
                      

                       

                      You needed this:

                       

                      <archive>
                         <manifestEntries>
                            <Dependencies>deployment.switchyard-example-0.0.1-SNAPSHOT.jar</Dependencies>
                         </manifestEntries>
                      </archive>
                      

                       

                      Next up, it looks like you added a backing bean called RichBean which has an injection for InternalTestService, but you didn't define the RichBean component or the reference in your switchyard.xml.  Here's what's missing:

                       

                      <sca:component name="RichBean">
                            <bean:implementation.bean class="com.example.hellosy.RichBean"/>
                            <sca:reference name="InternalTestService">
                              <sca:interface.java interface="com.example.hellosy.InternalTestService"/>
                            </sca:reference>
                      </sca:component>
                      

                       

                      After making these changes and deploying both applications, I get the following which I believe indicates success:

                       

                      20:58:39,209 INFO  [stdout] (http-/127.0.0.1:8080-1) start rich bean doTest
                      20:58:39,228 INFO  [stdout] (http-/127.0.0.1:8080-1) do Internal test: name from rich bean
                      20:58:39,232 INFO  [stdout] (http-/127.0.0.1:8080-1) From external test: name from rich bean
                      
                      • 8. Re: Inject SY service from jarapp into webapp
                        Lukasz Sroka Newbie

                        It looks like i have missed this RichBean component xml. I dont even need to change Dependencies name in pom.
                        Test app work nice.

                         

                        Now i have to move all my SOA stuff on EAP 6.1. I am wonder if it will work... if not i will post on forum again

                         

                        Thanks a lot !!!