10 Replies Latest reply on Apr 3, 2013 2:43 PM by rcernich

    SwitchYard + OpenShift For The Win...

    bfitzpat

      (work in progress)

       

      So I've been looking into SWITCHYARD-1293, which addresses integrating SwitchYard and OpenShift to simplify the process for the user who wants to develop a SwitchYard application on OpenShift or move an existing local project on OS.

       

      While doing that, I needed to figure out the steps to get this working so that we knew what needed to be done to improve the process in the tooling. So here are the steps (assuming you have an OpenShift account at http://openshift.redhat.com):

       

      (1) Find your vavorite Eclipse Juno installation with SwitchYard tooling installed and add the OpenShift tooling (from the JBoss Tools Juno site - choose JBoss Cloud Development Tools).

       

      (2) Create a new OpenShift application with the SwitchYard 0.6 cartridge (it's really 0.7.0.Final).

       

      (3) Update the .openshift/config/standalone.xml file in two places:

       

      * In the <extensions> element, add a new <extension module="org.switchyard"/> to the list of extensions.

      * And in the <subsystems> element, you need to add a subsystem for the switchyard bits:

      {code}

      <subsystem xmlns="urn:jboss:domain:switchyard:1.0">

          <modules>

                <module identifier="org.switchyard.component.bean" implClass="org.switchyard.component.bean.deploy.BeanComponent"/>

                <module identifier="org.switchyard.component.soap" implClass="org.switchyard.component.soap.deploy.SOAPComponent"/>

                <module identifier="org.switchyard.component.camel.core" implClass="org.switchyard.component.camel.core.deploy.CamelCoreComponent"/>

                <module identifier="org.switchyard.component.rules" implClass="org.switchyard.component.rules.deploy.RulesComponent"/>

                <module identifier="org.switchyard.component.bpm" implClass="org.switchyard.component.bpm.deploy.BPMComponent"/>

                <module identifier="org.switchyard.component.bpel" implClass="org.switchyard.component.bpel.deploy.BPELComponent"/>

                <module identifier="org.switchyard.component.resteasy" implClass="org.switchyard.component.resteasy.deploy.RESTEasyComponent"/>

                <module identifier="org.switchyard.component.http" implClass="org.switchyard.component.http.deploy.HttpComponent"/>

           </modules>

      </subsystem>

      {code}

       

      (4) (Optional) Change the default packaging in the pom.xml from WAR to JAR. In the pom.xml for the project, there are two places to change:

       

      * Look for <packaging>war</packaging> near the top of the file and change it to <packaging>jar</packaging>.

      {code}

      <plugin>

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

             <version>2.1.1</version>

             <configuration>

                   <outputDirectory>deployments</outputDirectory>

                   <warName>ROOT</warName>

             </configuration>

      </plugin>

       

      {code}

       

      * Next, look for <plugin><artifactId>maven-war-plugin</artifactId> and change that section to:

      {code}

      <plugin>

         <artifactId>maven-jar-plugin</artifactId>

         <version>2.3.1</version>

         <configuration>

           <outputDirectory>deployments</outputDirectory>

         </configuration>

      </plugin>

      {code}

       

      (5) So now you have your OpenShift project ready to go, we have to configure the project in Eclipse so that the SwitchYard tooling is enabled.

       

      * Right-click on the project and select Properties...

      * In the Properties dialog, find the Project Facets listing.

      * In the list of project facets, if Java isn't yet checked, go ahead and check it. And then check the SwitchYard facet as well.

      * Click OK to apply the changes.

       

      (6) Lastly, you have to select the SwitchYard components you'll be using in this project. These components will differ based on what you want to do in your SwitchYard configuration.

       

      * Right-click on the project, find the SwitchYard->Configure Capabilities... menu.

      * This opens the Properties dialog so you can choose the various components you want to use. Since I wanted to use the Bean Quickstart for this project, I'll go ahead and check Implementation Support-> Bean and Gateway Bindings -> SOAP.

       

      Once all that was done, I was able to grab my favorite SwitchYard Quickstart. I took the Bean Quickstart.(You can find it here: https://github.com/jboss-switchyard/quickstarts/tree/master/bean-service) I copied all the relevant bits into the same locations in my OS/SY project, pushed it to the git repository, and was able to test the exposed WSDL using the JBoss Web Service Tester.

       

      ----------------------------------------

       

      Obviously this is too many steps. Far too many potholes for users to fall into to get their project running on OpenShift.

       

      What we're going to look into is:

       

      * Handling steps 3 and 4 when the user adds the SwitchYard facet to the project. Basically we'll check to see if the project is OpenShift enabled and update those files accordingly.

      * Handling step 5 is a bit cumbersome as well. Would be better to make it so the Configure->SwitchYard Capabilities... menu automatically adds the facet if it's not there and then enables you to specify the components you want to include.

       

      That would reduce steps 3-6 down to a couple of less convoluted steps.

        • 1. Re: SwitchYard + OpenShift For The Win...
          kcbabo

          Couple of minor points:

           

          I don't think we should worry about moving an existing non-OpenShift application to OpenShift.  We want to focus on:

          1) New OpenShift applications created inside of Eclipse using the JBT OpenShift support.

          2) Existing OpenShift applications created outside of Eclipse.  Upon import, we want to add SwitchYard to the existing OpenShift app.

           

          I think #1 and #2 use the same underlying plumbing.

           

          #4 is missing, so I'm not sure if this is for binary deployment or source deployment.  For binary deployment, the jar for the application can be dropped in deployments/.  For source deployment, you can create the app just like any other app using our tooling (once the standalone.xml and pom changes are in place).

           

          Thanks for putting this together, Brian!  Can't wait to get the editor updated to make this automagic.

          • 2. Re: SwitchYard + OpenShift For The Win...
            bfitzpat

            I am not a fan of this editor, so I'm doing a little at a time - sorry.

            • 3. Re: SwitchYard + OpenShift For The Win...
              bfitzpat

              Ok, so investigating the "Configure->SwitchYard Capabilities..." menu. I've discovered that it works to a point if the maven project is configured for a jar deployment, but not for a war deployment. The preset facet set is different with one than the other. Still investigating...

              • 4. Re: SwitchYard + OpenShift For The Win...
                bfitzpat

                So it turns out that when you have a Maven-enabled project with a WAR deployment specified, you get these presets:

                 

                [preset.jst.jsf.v1_1, preset.jst.jsf.v2_0, preset.jst.jsf.v1_2, minimal.configuration, default.configuration, preset.jst.jsf.v2_1]

                 

                And when you have a Maven-enabled project with a JAR deployment specified, you get these:

                 

                [preset.jst.jsf.v1_1, preset.jboss.seamportlet.v22, minimal.configuration, jst.seam21.preset, jbossws.core.preset, jst.seam23.preset, preset.jboss.seamportlet.v20, jst.seam22.preset, jboss.jst.cdi.preset, preset.jst.jsf.v2_1, preset.jst.ejb.xdoclet, jst.seam2.preset, jst.seam.preset, preset.jst.jsf.v2_0, preset.switchyard.jar, preset.jst.web.xdoclet, cxf.jst.web25.preset, preset.jst.jsf.v1_2, preset.switchyard.basic, default.configuration]

                 

                And the code that updates the project to be a Switchyard project needs that preset.switchyard.basic facet preset to be in there before it'll work.

                 

                I'm not seeing anything obvious in the facet code to tell me why it works for jar, but not war - any ideas where to look?

                 

                Your suggestion to do a Maven->Update Project was a good one, but I didn't notice any difference there.

                 

                I did notice however that if I update the pom using the Maven POM editor and update the "Packaging" setting from war to jar, it doesn't work. The section in the pom doesn't update the deployments bits...

                 

                {code}

                     <plugin>

                        <artifactId>maven-jar-plugin</artifactId>

                        <version>2.3.2</version>

                        <executions>

                          <execution>

                            <id>default-jar</id>

                            <phase>package</phase>

                            <goals>

                              <goal>jar</goal>

                            </goals>

                          </execution>

                        </executions>

                      </plugin>

                {code}

                 

                So we have a few mysteries to solve in this area...

                • 5. Re: SwitchYard + OpenShift For The Win...
                  rcernich

                  Hey Brian,

                   

                  That's definitely an issue.  Could you please create a JIRA for this?  The SwitchYard facet should only require a JEE module type.  By default, a SwitchYard project is created with a utility module facet, but it should be possible to add the facet to any JEE project.  The other requirement is that the project be a Java project.

                   

                  From the sounds of things, it looks like the only thing that needs to be done is to attach the basic switchyard facet to the created project, which I thought occurred as part of the m2e configuration for the project (i.e. m2e sees the switchyard mojo, asks the switchyard m2e plugin to configure itself, which should be adding the basic switchyard facet, along with a builder to handle the configure mojo execution).

                   

                  Also do you change the packaging plugin or the packaging type of the project (i.e. <packaging>jar</packaging>)?

                   

                  Best,

                  Rob

                  • 6. Re: SwitchYard + OpenShift For The Win...
                    bfitzpat

                    Ok, I created SWITCHYARD-1316 for this issue.

                     

                    As far as the packaging type/packaging plug-in question, all I did in this case was open the pom.xml in the Maven POM Editor (provide by m2e I believe) and change the "packaging" setting on the Overview page from war to jar. That doesn't seem to set up the jar deployment bits as described in SWITCHYARD-1293.

                    • 7. Re: SwitchYard + OpenShift For The Win...
                      kcbabo

                      By "jar deployment bits" are you referring to the use of the maven-jar-plugin and the output directory of deployments/ ?  If so, that's specific to OpenShift applications and likely something we will have to change on our own.  Switching the packaging type or facet won't do that as part of the conversion.

                      • 8. Re: SwitchYard + OpenShift For The Win...
                        bfitzpat

                        Well, that's part of it. OpenShift aside, even changing it from war to jar in the POM editor doesn't seem to trigger whatever is holding the facet configuration back. So it's looking for something else in there, but for the life of me I can't figure out what.

                        • 9. Re: SwitchYard + OpenShift For The Win...
                          rcernich

                          Hey Brian,

                           

                          If this is holding you up, I can look at the facet stuff as soon as I've finished what I'm currently working on.  That said, you're probably better off focusing on the non-facet related bits.

                           

                          Best,

                          Rob

                          • 10. Re: SwitchYard + OpenShift For The Win...
                            rcernich

                            Hey Brian,

                             

                            I'd make sure the switchyard plugin is configured in the pom.  That is what I believe triggers facet configuration in m2e.  I may have thought that it would be added automatically based on dependencies, but that is not correct, it is the plugin.

                             

                            I'll still investigate the issues using the facet in conjunction with a war project.

                             

                            Thanks,

                            Rob