Note: information on this page refers to Ceylon 1.2, not to the current release.
Deploying Ceylon modules in OSGi containers
Ceylon is fully interoperable with OSGI, so that Ceylon modules: - can be deployed as pure OSGI bundles in an OSGI container out-of-the-box without any modification of the module archive file, - can embed additional OSGI metadata, to declare services for example, - can easily use OSGI standard services
This provides a great and straightforward opportunity to run Ceylon code inside a growing number of JEE application servers or enterprise containers that are based upon (or integrated with) OSGI.
In order to be able to resolve and start Ceylon module archives (.car
files) inside an OSGI container, you will first need to install, in the OSGI container, all the bundles of the Ceylon distribution and SDK.
Retrieving the Ceylon Distribution and SDK for OSGI
In order to be able to resolve and start Ceylon module archives (.car
files) inside an OSGI container, you will first need to install, in the OSGI container, all the bundles of the Ceylon distribution and SDK.
These bundles are available in a dedicated place on the Ceylon language web site :
-
as OBR bundle repositories:
-
Old-style OBR syntax (still used by Apache Felix):
https://downloads.ceylon-lang.org/osgi/distribution/1.2.2/repository.xml
https://downloads.ceylon-lang.org/osgi/sdk/1.2.2/repository.xml
-
New standard R5 OBR syntax:
https://downloads.ceylon-lang.org/osgi/distribution/1.2.2/index.xml
-
-
as P2 repositories for Eclipse development :
-
as Zip archives for direct deployment inside containers :
https://downloads.ceylon-lang.org/osgi/distribution/1.2.2/ceylon.distribution.osgi.bundles-1.2.2.zip
https://downloads.ceylon-lang.org/osgi/sdk/1.2.2/ceylon.sdk.osgi.bundles-1.2.2.zip
-
as Apache Karaf (aka JBoss Fuse) features:
-
ceylon.distribution.runtime
, available in the following feature repositoryhttps://downloads.ceylon-lang.org/osgi/distribution/1.2.2/karaf-features.xml
-
ceylon.sdk
, available in the following feature repositoryhttps://downloads.ceylon-lang.org/osgi/distribution/1.2.2/karaf-features.xml
-
Installing the Ceylon Distribution and SDK in an OSGI container
Apache Felix 5.4.0:
Let's assume we start with a fresh installation of Apache Felix v5.4.0 (
org.apache.felix.main.distribution-5.4.0.zip
)-
In the
conf/config.properties
file of the Felix installation directory, add the following property:org.osgi.framework.executionenvironment=J2SE-1.7,JavaSE-1.7,J2SE-1.6,JavaSE-1.6,J2SE-1.5,JavaSE-1.5,J2SE-1.4,JavaSE-1.4,J2SE-1.3,JavaSE-1.3,J2SE-1.2,,JavaSE-1.2,CDC-1.1/Foundation-1.1,CDC-1.0/Foundation-1.0,J2ME,OSGi/Minimum-1.1,OSGi/Minimum-1.0
This is necessary since by default the Felix OSGI container provided execution environments don't include
J2SE-1.7
, which is required by a transitive dependency of theceylon.net
module. In the
conf/config.properties
file of the Felix installation directory, find theobr.repository.url
property.Uncomment this property if necessary
-
Add the 2 Ceylon following OBR urls at the end of this property (space-separated):
https://downloads.ceylon-lang.org/osgi/distribution/1.2.2/repository.xml https://downloads.ceylon-lang.org/osgi/sdk/1.2.2/repository.xml
-
From the Felix installation directory, Start Felix with the following command:
java -jar bin/felix.jar
-
From the Felix Gogo shell, deploy the Ceylon Distribution with:
obr:deploy "Ceylon Distribution Bundle"
-
Deploy any SDK module you need with the following command:
obr:deploy ceylon.file
Glassfish v4.1:
Since Glassfish is based on Apache Felix, it can be configured to use the OBR. However the simplest way to install the Ceylon Distribution and SDK bundles is to copy then manually.
Let's assume we start with a fresh installation of Glassfish v4.1
-
Unzip the 2 zip archives mentioned earlier (distribution and sdk) into :
../glassfish4/glassfish/domains/domain1/autodeploy/bundles
-
start the glassfish server :
../glassfish4/bin/asadmin start-domain
-
verify that the various Ceylon bundles were deployed correctly in the following log file :
../glassfish4/glassfish/domains/domain1/logs
Apache Karaf 4.0.4 (Karaf is a part of JBoss Fuse) with Karaf features:
Let's assume we start with a fresh installation of Apache Karaf v4.0.4 (
apache-karaf-4.0.4.zip
)-
In the karaf installation directory, start Karaf with the following command:
./bin/karaf
-
In the karaf shell, add the Ceylon distribution feature repository with the following command:
feature:repo-add https://downloads.ceylon-lang.org/osgi/distribution/1.2.2/karaf-features.xml
-
In the karaf shell, add the Ceylon SDK feature repository with the following command:
feature:repo-add https://downloads.ceylon-lang.org/osgi/sdk/1.2.2/karaf-features.xml
-
In the karaf shell, install the Ceylon distribution feature with the following command:
feature:install ceylon.distribution.runtime
-
In the karaf shell, install the Ceylon SDK feature with the following command:
feature:install ceylon.sdk