How to point to a separate Carbon OSGi Repository?

It’s a well-known fact that all Carbon based products can be deployed on top of other application servers like Tomcat, JBoss, Web Logic etc. For example, WSAS on tomcat, WSAS on Web Logic and ESB on tomcat. When deploying Carbon on a separate application server, we have to point to a Carbon home directory through the CARBON_HOME environment variable.

Some users may set up more than one instance of Carbon, pointing to the same Carbon home. In this case, everything under Carbon home directory is shared by these Carbon instances. That includes configuration files (CARBON_HOME/conf), Axis2 repository (CARBON_HOME/repository) and Carbon OSGi repository (CARBON_HOME/repository/components). Even though sharing of configurations and Axis2 repository is perfectly OK, Carbon OSGi repository can cause problems when it is shared by more than one instance of Carbon.

So this is where we want to point to a separate Carbon OSGi repository while sharing the other stuff. In Carbon 2.x, you can do that by using the CARBON_REPOSITORY environment variable. Set it to some folder and create a folder called ‘components’ inside that folder. Finally start the server.

Example: If your Carbon OSGi repository is at /carbonRepo, set CARBON_REPOSITORY=/carbonRepo and create a folder /carbonRepo/components. Now start the server.

Now your Carbon instance uses the above place as the OSGi repository. After starting the server, you can see lot of folders inside your components folder.

There is something important to remember here. Even though you separate the OSGi repository from CARBON_HOME, if you want to use components/lib folder or components/extensions folder, you have to use them inside CARBON_HOME.

Example : If you want the my-sql driver, you have to place it in CARBON_HOME/repository/components/lib folder. NOT in /carbonRepo/components/lib folder.

So If you are also trying to use the same CARBON_HOME for multiple Carbon instances, make sure you use separate Carbon OSGi repository for each and every instance as shown in the following diagram.

How to invoke an Axis2 JAXWS service RESTfully?

Have you ever tried to invoke an Axis2 JAXWS service in RESTful manner? Was it successfull? If not, you will find the reason in this post. And also you will find how to do it.

Most of the time we write simple JAXWS services like this..

public class JAXWSAARService {

@WebMethod (operationName = “echo”, action = “urn:echo”)
public String echo(String in) {
return in;


In this service, @BindingType annotation is not used and according to the JAXWS specification, the default is SOAP 11 binding. So the generated WSDL for the above service will only generate a SOAP 11 binding. That’s why we can’t invoke the service in RESTful manner. If you try it, it will give you the following error.

“Incoming message protocol does not match endpoint protocol.”

In order to invoke a service RESTfully, an HTTP binding is needed. Therefore in the above service, you have to use the @BindingType annotation and set it’s value to HTTP binding as follows.

@BindingType(value= HTTPBinding.HTTP_BINDING)
public class JAXWSAARService {


Now the Axis2 JAXWS deployer will generate an HTTP binding for you. Now you can invoke the service RESTfully using the following URL.




Sri Lanka wins 2 Bronze medals and 3 Honourable Mentions in the 50th IMO

It was a great pleasure for me to know that Sri Lanka has won 2 bronze medals and 3 honourable mentions in the 50th International Mathematical Olympiad (IMO) competition held recently in Germany. Our students have scored 74 marks and become the 50th in the rankings out of 104 countries. This is a great achievement in the context of IMO.

I had the opportunity of representing Sri Lankan team in the 44th IMO which was held in Japan. Our team could score only few marks and we were among the lowest scorers in the rankings. It’s an extremely tough competition and normally other counties prepare students for IMO from their childhood.

Contestants must be below 20 years and must have not entered a university. Competition is held for 2 days and 3 problems are given each day. Time for a problem is 1.5 hours. Each problem carries 7 marks and the total is 42.

Mr. Chanakya J. Wijeratne who is a senior lecturer at the department of mathematics, university of Colombo, is the person who is behind this great success. He has been training students for IMO for more than 6 years now. We also were trained under him and he is doing a great job for our country.

I think our students can win more and more medals in IMO (even golds) if we can train them at least for one year. Definitely the required brains are there. What we lack is training. So well done boys.. Keep it up..

Sachin passes 17000 in style

Cricket is almost like a religion in India and Sachin is a god for Indian cricket fans. What a player he is.. Still hungry for runs, still scores centuries, still a match winner ans still improving.


The little master passed 17000 ODI runs with a huge century which almost took India home in the high scoring 5th ODI against Aussies. Who can break Sachin’s batting records? Actually I don’t see any one. And also I think there won’t be anyone for some time. 17000 ODI runs with 45 hundreds and 91 fifties. Almost 13000 test runs with 42 hundreds and 53 fifties. Oh.. unbelievable for a cricketer.

I always enjoy his batting when he’s not playing against Sri Lankans :). It’s great to watch his beautiful cover drives, straight drives, cuts, pulls etc. with an excellent technique.

I think he will play until the 2011 world cup and will definitely produce more and more centuries for India. So Sachin, score tons of runs against all the counties other than Sri Lanka :). Thanks for providing great entertainment for over 2 decades.. Keep going..

Can we deploy additional web applications in Carbon??..

This is a very common question and most people are asking this again and again. Answer to this question is like “Yes and No” :). So let me explain it in bit more details.

As you may already know, the standalone carbon server is build on top of an embedded Tomcat instance. Carbon is deployed within it as any other web application. In other words, Carbon itself is a web application. So it should be possible to deploy additional web apps in this embedded Tomcat instance and they should run in parallel with Carbon. But practically this is not the case.

We have done some customizations to this embedded Tomcat instance to support our OSGi based Carbon framework mounted on top of it. There are some additional libraries in CARBON_HOME/lib (equal to TOMCAT_HOME/lib) which are related to Carbon framework. Those jars can cause problems for your web application as Tomcat uses parent first class loading. And also, in Carbon we haven’t used all libraries which comes with a normal Tomcat instance. Therefore, some functionalities which are needed for full web application support may be not there.

Today, one user came up with a very good question. That is “If you have customised the embedded Tomcat instance to support Carbon, are we going to miss some functionalities when Carbon is deployed in some other Application server?”. The answer is “No”. So don’t worry about that :). Those customizations are not directly related to product functionalities. All Carbon based products are tested on may application servers like Tomcat, WebLogic, WebSphere etc.

So in conclusion, we don’t recommend deploying other web apps inside any of our Carbon based products. But basic web apps will work. If you want to have your additional web apps in parallel with Carbon, the recommended approach is to deploy Carbon in some other application server and deploy the other web apps inside the same application server.