Deploying and Debugging
After creating your projects, you are ready to test them by deploying and then debugging them.
Creating a Carbon Application Archive (CAR) file
There are two ways you can create a .car file. One way is to right click on the C-App project and select Export Carbon Application Project from the pop-up menu.
The other way is to select the option from the pom.xml. Open the pom.xml in Carbon Application Project POM Editor and there is a button to create the Carbon Application Archive [CAR] at the right most top corner.
Specify the location to save the Carbon Application Archive [CAR] file.
Then select the artifacts you want to include to the Carbon Application Archive [CAR] and click finish.
Now you have successfully created a Carbon Application Archive [CAR] file which is ready to be deployed in to a Carbon Server.
To deploy the created CAR file in to a Carbon Server, start the carbon server. Once the server being started, log in to management console, and go to Application -> Add and browse for the CAR file that you have created.
Once you click Upload, it will ask you 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 CApp 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 3.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 3.2 based server) added to the Server Runtime Environments. Then 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 CApp project and click Finish.
Now you will see newly added server is 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 Select Re-deploy option from the popup menu.
Then you will see that your Eclipse console is updated and you can notice that your C-App project is deployed again.
Debugging a Carbon Application
Suppose I develop a simple Apache Axis2 Service and I want to debug my service when I invoke it. Let's see how we can achieve this using WSO2 Developer Studio.
First, I create a simple GreetingService.
Then I create a Carbon Application Project to group it.
Now I'm going to add a WSO2 Application Server instance to my Eclipse workspace. Steps to add a Carbon Server is described in Deploy C-App to a running Server inside Eclipse section. After adding the server, I'm going to start the server in the debug mode.
After server being successfully started, add the GreetingServiceCApp project.
When your application being deployed successfully, you will see following messages in your console.
Now go to your web browser and check whether your application being deployed under Web Services Listing page.
Now click on Try This Service option at the right hand corner. Once you click it, it will go to a seperate page where it lists all the operations related to the web service you choose.
Before 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, it will ask whether to change in to 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 on Edit Source Lookup Path....
Click on Add button and select Java Project.
Select GreetingService project from the list and click OK.
Now you will see the source being attached and you will see the debug point is being hit.
In the similar manner, you can debug any application which will be associated with Java Sources.