Deploying and Debugging
After creating your C-Apps and deployable archives, you are ready to deploy them to one or more Carbon servers (that is, servers for products based on WSO2 Carbon). You can then test them and debug your applications and artifacts as needed.
If you are running products in a cluster, you can use Deployment Synchronizer to keep the configurations on all nodes in the cluster in synch.
Deploying a C-App using the management console
To deploy the CAR file for the C-App to a Carbon server, start the server, log in to the management console for that product, go to Application -> Add, and browse for the CAR file that you have created.
Once you click Upload, you will be asked to Refresh the browser. Once you refresh, you will see that the CAR file has been deployed.
Deploying a C-App to a running server inside Eclipse
Before you deploy the created C-App project, you have to choose the artifacts you need to deploy. For that, double click on the pom.xml and select artifacts you need to deploy and save the changes.
Go to Servers view, right click and select New -> Server.
Select the relevant version of the server under the WSO2 category. For example, WSO2 Carbon 4.2 based server.
To see the relevant version of the Carbon based server, refer to the Release Matrix .
If you have not added WSO2 Server instances before, you will need to specify the location of the downloaded WSO2 Server instance.
Now you will see your version of the server (for example WSO2 Carbon 4.2 based server) added to the Server Runtime Environments. Click OK.
You can change ports if you want. If the default ports are not used by any other application, you can keep them as they are. After setting the ports click Next.
Add the C-App project and click Finish.
Now you will see the newly added server listed in the Servers view. Right click on the WSO2 Carbon x.x.x based server at localhost and select Start from the menu.
Redeploying a C-App to a running server inside Eclipse
After you have deployed your C-App to a running server inside Eclipse, you may want to change the content of your C-App. In that case you do not need to remove the deployed C-App from the server and deploy again to the server. Instead you can re-deploy an already deployed C-App. Deploy the C-App project according to the instructions given above and then do the necessary changes to your C-App project.
Open the Servers view in Eclipse using Window => Show View => Servers.
Click on the expandable icon of the Server you are running inside Eclipse. (This expandable icons available only if you have deployed a project in that server). Right-click on the project and click Re-deploy.
Then you will see that your Eclipse console is updated and you can notice that your C-App project is deployed again.
Deploying a C-App to multiple servers using the Maven plug-in
The WSO2 CAR Deploy plug-in for Maven allows you to generate the CAR file for a C-App and then deploy it (or undeploy it) on multiple local and remote Carbon servers, including StratosLivePaas. To use this plug-in, you add it to the pom.xml file for your C-App and then use the mvn clean deploy command to generate and deploy the CAR. See the Deploying a CAR File with the Maven Plug-In sample for a walk-though of how to deploy a CAR file containing ESB artifacts.
Adding the plug-in to the POM file
<plugin> <groupId>org.wso2.maven</groupId> <artifactId>maven-car-deploy-plugin</artifactId> <version>1.0.0</version> <extensions>true</extensions> <configuration> <carbonServers> <CarbonServer> <trustStorePath>${basedir}/src/main/resources/security/wso2carbon.jks </trustStorePath> <trustStorePassword>wso2carbon</trustStorePassword> <trustStoreType>JKS</trustStoreType> <serverUrl>https://${host}:${port}</serverUrl> <userName>admin</userName> <password>${password}</password> <operation>deploy|undeploy</operation> </CarbonServer> <CarbonServer> <trustStorePath>${basedir}/src/main/resources/security/wso2carbon.jks </trustStorePath> <trustStorePassword>wso2carbon</trustStorePassword> <trustStoreType>JKS</trustStoreType> <serverUrl>https://localhost:9445</serverUrl> <userName>admin</userName> <password>admin</password> <operation>deploy|undeploy</operation> </CarbonServer> . . . </carbonServers> </configuration> </plugin>
- Under the C-App you want to deploy, double-click the
pom.xml
file to open it in the editor. - Click the Source tab and navigate to the
maven-car-deploy-plugin
under<build>
-><plugins>
. - Modify the
maven-car-deploy-plugin
properties as follows:- Under
<carbonServers>
, create one<CarbonServer>
for each Carbon server where you want to deploy the CAR file. - Specify the following properties for each Carbon server:
- If you are using a custom certificate with your Carbon server, import the public key of the custom certificate to your trust store, and then set the
<trustStorePath>
,<trustStorePassword>
, and<trustStoreType>
properties to the location, password, and type of your trust store. - Set the
<serverUrl>
,<userName>
, and<password>
properties to the URL (such ashttps://localhost:9443
), user name, and password for the Carbon server. - In the
<operation>
element, specify whether to deploy or undeploy the CAR file for this Carbon server.To deploy:
<operation>deploy</operation>
To undeploy:
<operation>undeploy</operation>
Add the following line to the properties to ensure that the CAR file will be deployed:
<maven.car.deploy.skip>false</maven.car.deploy.skip>
If you want to deploy the CAR file to a remote Maven repository in addition to the Carbon servers, add the following line to the properties:
<maven.deploy.skip>false</maven.deploy.skip>
You will be able to override both of these settings when you run the Maven command. - If you are using a custom certificate with your Carbon server, import the public key of the custom certificate to your trust store, and then set the
- Under
- Save the file. You are now ready to generate and deploy the CAR file for this C-App.
Generating and deploying the CAR file
You now run the mvn clean deploy
command to generate the CAR file and deploy it to the Carbon servers in a single step. You can add parameters to the command to override the configuration. For example, to deploy the CAR file to the Carbon servers but not to the remote Maven repository, add the -Dmaven.deploy.skip=true
parameter, as follows:
mvn clean deploy -Dmaven.deploy.skip=true
If you want to deploy to the remote Maven repository but not the Carbon servers, add the -Dmaven.car.deploy.skip=true
parameter, as follows:
mvn clean deploy -Dmaven.car.deploy.skip=true
You can also skip deployment to both the remote repository AND the Carbon servers:
mvn clean deploy -Dmaven.deploy.skip=true -Dmaven.car.deploy.skip=true
Some useful Maven commands
The following are some useful Maven commands for a selective deployment of a CAR file to a remote Maven repository (Nexus) as well as to Carbon servers:
Skip deployment of CAR file to remote Maven repository and continue the deployment of CAR file to given Carbon server(s):
mvn clean deploy -Dmaven.deploy.skip=true -Dmaven.car.deploy.skip=false
Skip deployment of CAR file to given Carbon server(s) and continue the deployment of CAR file to a remote Maven repository:
mvn clean deploy -Dmaven.deploy.skip=false -Dmaven.car.deploy.skip=true
Deploy the CAR file to both Carbon server(s) as well as to a remote Maven repository:
mvn clean deploy -Dmaven.deploy.skip=false -Dmaven.car.deploy.skip=false
It is also possible to declare the
<maven.car.deploy.skip>
property in the properties section of the pom.xml and provide a parameter from the command line. In that case, the property value declared in the pom.xml will get overridden by the parameter value provided in the command line.In order to enable the deployment of a CAR file to Carbon server, you can also add
<maven.car.deploy.skip>false</maven.car.deploy.skip>
to the properties section of the C-App project pom.xml
Using these commands and aforementioned properties, you can do a selective deployment of a CAR file to a remote Maven repository as well as to Carbon servers.
Debugging your application
Suppose you want to develop a simple Apache Axis2 Service and want to debug your service when you invoke it. Let's see how to achieve this using WSO2 Developer Studio.
First, create a simple GreetingService.
Then create a Composite Application Project to group it.
Now add a WSO2 Application Server instance to your Eclipse workspace. Steps to add a Carbon Server is described in the Deploy a C-App to a running Server inside Eclipse section. After adding the server, start the server in the debug mode.
After the server is successfully started, add the GreetingServiceCApp project.
When your application has deployed successfully, you will see the following messages in your console.
Now go to your web browser and check whether your application is being deployed under the Web Services Listing page.
Now click on the Try This Service option at the right hand corner. Once you click it, it will go to a separate page where it lists all the operations related to the web service you choose.
Before you invoke the service, go back to your Eclipse Workspace and put a debug point inside your method.
Now go back to your web console and invoke the service. Once you invoke the service, you are asked whether to change into the Debug Perspective in Eclipse.
Click Yes. If your Eclipse instance could not find the relavent source for the class, it will show a blank page as below.
Click Edit Source Lookup Path.
Click Add and select the Java Project.
Select the GreetingService project from the list and click OK.
Now you will see the source being attached and you will see the debug point being hit.
In a similar manner, you can debug any application which will be associated with Java Sources.