IBM WebSphere Application Server deployment patterns
IBM® WebSphere® Application Server supports three ways to deploy Service Component Architecture (SCA) applications to fit different needs:
- Single asset
- Embedded asset
- Shared asset
Single asset is one Java archive (JAR) file. It contains all files, classes, and other artifacts that the application needs to work properly. This is the simplest deployment pattern, because you need to create only one composition unit (CU) for that asset in one business-level application (BLA). This is the default deployment pattern used in IBM® Rational® Application Developer to deploy and publish SCA applications.
With the embedded asset pattern, there is one main JAR file that contains a single or multiple JAR files. This is a way to keep your assets organized within the main JAR file that you will deploy. In WebSphere Application Server, this is more likely to single asset pattern in the way that you need to create one CU for the main asset and one BLA. Internally, WebSphere Application Server reads the contents of the asset and loads them all and includes them in the appropriate class loader.
Shared asset is a more complex pattern. This involves several independent JAR files that are not embedded. There is a main asset to be deployed (the SCA contribution asset) and secondary assets that will be used by the main asset. The secondary assets have resources that the main asset uses to work properly. Shared assets are imported into WebSphere Application Server in two ways:
- If the shared asset contains an SCA contribution and it exports a namespace or a Java package that is then imported by the SCA contribution in the main asset, then WebSphere Application Server automatically maps that asset as a shared asset. No additional work is necessary here.
- If it is a non-SCA asset, you can map it as a shared asset with the
relationshipdirective of the
importAssetcommand when importing the main asset.
In both cases, the shared asset must be deployed in WebSphere Application Server before importing the main SCA asset.
IBM Rational Application Developer tools
In addition to the deployment assembly features available on WebSphere Application Server, IBM Rational Application Developer has tools for mapping your deployment layout. You can choose during development how you will design the deployment layout of your SCA application.
Within Rational Application Developer, you map your SCA application and dependencies to be deployed as one asset (that is the default behavior in Rational Application Developer), a main asset that contains embedded assets or a main asset with several shared assets (but only the ones automatically generated by WebSphere Application Server). See the first bullet item in Shared Asset section). You can do this by adding deployment assembly support to your SCA project.
You can use deployment assembly to add dependencies in your project and to create a deployment layout to fit architectural goals. You can add a dependency to a project in the workspace, archives, folders, and Java build path entries.
The sample in this article is based on the Account Services Sample provided in IBM Rational Application Developer, but it will be enhanced to add assembly support to demonstrate the deployment patterns.
For convenience, you can import the projects into your workspace. You can find the projects in a zip file in the Downloads section.
The scenario covers three SCA projects:
- Handles the checking account requests. This is deployed as an embedded JAR file inside of the main SCA asset.
- Handles the savings account requests. This is deployed as an SCA shared asset. It will export a Java package to be imported in the contribution of AccountServices project.
- Contains an SCA composite that wires and exposes the services provided by SavingAccount and ChequingAccount as a single service. It is the main SCA contribution project in which the layout will be configured.
The composition looks like Figure 1.
Figure 1. Composite
Import the projects
To import the projects into your workspace, follow these steps:
- Click File and select Import.
- Expand General category.
- Select Existing projects into workspace.
- Click Next.
- Select Import from archive file.
- Click Browse.
- Browse the downloaded file that contains the projects.
- Click OK.
- Click Finish.
Add deployment assembly support
By default, SCA projects do not have deployment assembly support, so you need to add it. Use the context menu of the SCA project.
- Right-click on AccountServices, and expand Service Component Architecture 1.0 > Add Deployment Assembly support.
- In the Enhance SCA Project Wizard, select the three projects listed.
- Click Finish.
If you right-click the AccountServices project and select Properties > Deployment Assembly, you will see deployment assembly entries as in the screen capture in Figure 2.
Two things to notice here:
- The project dependency for ChequingAccount and SavingsAccount projects is already there. This is because the initial AccountServices project had an entry for each of the projects shown here in the Java build path. Adding deployment assembly support will also migrate the entries in Project References.
- The SCA Deployment Assembly page (Figure 2) has two check boxes for mapping the deployment patterns: Shared asset and Deploy as JAR.
Figure 2. SCA Deployment Assembly page
Deploying as a single asset
This is the default and simplest deployment task. If you do not further configure the deployment assembly, you will deploy a single asset. To do this, you just have to publish the application.
To review the publish job in the server, open WebSphere Application Server Administration Console and go to Applications > Application Types > Assets. You will see only one asset there.
Figure 3. Single deployed asset
Remove the application from the server to move to the next section.
Deploying an embedded asset
The ChequingAccount project will be selected to be deployed as an embedded asset:
- Open Deployment Assembly page of AccountServices project.
- Select ChequingAccount, and check Deploy as JAR.
- Click OK and publish as usual.
- After the deployment, open the WebSphere Application Server Administration Console and go to Assets page. There, you will see only one asset.
- Select the AccountServices.jar item in the table, and select Export.
- On the next page, click the AccountServices.jar link, and save to your local system.
- Open the saved JAR file with a decompression utility. You will see that the ChequingAccount project was packaged as an embedded JAR file.
- Inspect the contents of the archives.
Figure 4. Embedded asset
Remove the application from the server to move to the next section.
Deploying a shared asset
IBM Rational Application Developer supports the deployment of shared assets that are automatically mapped by IBM WebSphere Application Server. The application server looks for the following items in an asset to determine whether the asset is a candidate for this type of deployment (the first two steps apply to the shared asset; the remaining ones apply to the main SCA asset):
- Does the project have an sca-contribution.xml file in the META-INF folder? First, WebSphere Application Server needs to determine whether this is an SCA asset.
- Is the asset exporting any XML namespace or Java package through the sca-contribution.xml file? WebSphere Application Server reads the SCA contribution file looking for an export. If so, then it determines that the asset can be used as an SCA Shared Asset.
- Is this asset a deployable SCA asset? WebSphere Application Server looks for an SCA contribution file that contains deployable composites.
- Is there a missing artifact in the SCA composite at composition unit creation time? When creating the composition unit and can't find a Java or XML artifact, WebSphere Application Server looks in the SCA contribution file for an import element and tries to match the SCA import with the SCA exports it already knows. If there is a match, then it adds a composition unit of the shared asset.
Add the import and export statements in the SCA contribution files
In IBM Rational Application Developer, you need to add those import and export statements in the SCA contribution files of the projects. To export the Java package, follow these steps:
- Right-click on the SavingsAccount project, and select New > SCA 1.0 Contribution.
- Click Finish, and accept the default values in New SCA 1.0 Contribution wizard.
- In the Exports section, click Add, select export.java, and then click OK.
- In the export.java dialog window, click Browse, and select the org.example.components package.
- Click OK, and then OK again.
- Save your SCA contribution editor.
Your contribution should look like Figure 5.
Figure 5. Exports section in SCA Contribution editor
Import the Java package
Now you need to import the Java package in the AccountServices project:
- Now, open the SCA contribution from the AccountServices project.
- Click Add from Imports section.
- In the Add Import dialog window, select import.java, and click OK.
- Click Browse, and select the org.example.components package from the SavingsAccount project.
- Click OK, and then click OK again.
- Save your contribution. It should looks like Figure 6.
Figure 6. Imports section in SCA Contribution editor
Configure as a shared asset and deploy
- Open the Deployment Assembly page of the AccountServices project, select the SavingsAccount project, and you should see Shared asset check box enabled.
- Confirm that it is, and click OK.
- Now, deploy the AccountServices application.
- After deployment, open the WebSphere Application Server Administration console, and go to the Assets page. You should see two assets:
Figure 7. Shared asset and main asset in WebSphere Application Server
- Now go to the Business-Level Applications page, and click the AccountServices BLA.
You now should be able to see two composition units, one is for the AccountServices composite, and the other is for the shared asset for SavingsAccount that WebSphere Application Server created automatically.
Figure 8. Composition Units page segment
Remove the application from the server.
SCA applications in Rational Application Developer 8.5.1
Rational Application Developer Version 8.5.1 supports the two versions of SCA Specification: V1.0 (OSOA) and V1.1 (OASIS).
The concepts and procedures depicted in this article apply to both versions, starting from Rational Application Developer 8.5.1. Just ensure that you select SCA 1.0 or 1.1 in the context menus.
SCA 1.1 projects created in Rational Application Developer v8.5.1 have deployment assembly support by default. However, SCA 1.1 projects created in Rational Application Developer v8.5 do not have deployment assembly support. You need to add the support as in the Add deployment assembly support task.
You can use IBM WebSphere Application Server to design the deployment of your SCA application in a variety of ways:
- Single asset
- Embedded JAR files within the main asset
- Shared assets
IBM Rational Application Developer helps you map those deployment patterns during development without the need to create a deployment script to fit your architectural needs. This is done by adding deployment assembly support.
- Read these for more information related to this article:
- Developing Service Component Architecture applications using Rational Application Developer by Lokanadham Nalla (IBM developerWorks, December 2011)
- Exploring the WebSphere Application Server Feature Pack for SCA, Part 1: An overview of the Service Component Architecture feature pack by Chao M. Beck and Stephen Kinder (developerWorks, December 2008)
- Deploying SCA Composites, WebSphere Application Server 8.5 Information Center
- Java EE Deployment Assembly by Chuck Bridgham and Aidyl Kareh (PDF)
- Find out more about Rational Application Developer:
- See the Rational Application Developer for WebSphere overview for features, system requirements, ratings, and reviews.
- Browse the Rational Application Developer for WebSphere Software page on developerWorks for links to technical articles and many related resources.
- Explore the IBM Rational Application Developer 8.5 Information Center.
- Explore the Rational software area on developerWorks for technical resources, best practices, and information about Rational collaborative and integrated solutions for software and systems delivery.
- Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Improve your skills. Check the Rational training and certification catalog, which includes many types of courses on a wide range of topics. You can take some of them anywhere, anytime, and many of the Getting Started ones are free.
Get products and technologies
- Try Rational Application Developer for WebSphere Software, free.
- Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.
- Check Rational Application Developer wiki to keep up with news and to contribute.
- Join the Development Tools forum to ask questions and participate in discussions.
- Get connected with your peers and keep up on the latest information in the Rational community.
- Rate or review Rational software. It's quick and easy.
- Share your knowledge and help others who use Rational software by writing a developerWorks article. Find out what makes a good developerWorks article and how to proceed.
- Follow Rational software on Facebook, Twitter (@ibmrational), and YouTube, and add your comments and requests.
- Ask and answer questions and increase your expertise when you get involved in the Rational forums, cafés, and wikis.
Dig deeper into Rational software on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Experiment with new directions in software development.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.