Friday, February 1, 2013

Deploying Carbon bundles in Geronimo

In this post I'll explain the steps to test deploying WSO2 Carbon bundles in Apache Geronimo V3 server. Before deploying the bundles we need to setup the configuration environment required by the Carbon bundles. 
Please note that deploying Carbon bundles in Geronimo has several bundle resolution issues which need to be manually identified and rectified in order to setup all Carbon bundles to function properly. 

For this effort, I'm using the Geronimo J2EE distribution with Tomcat 7 integration for Linux platform downloaded from here
I'm using carbon-4.0.2 bundles for the deployment. You can download carbon-4.0.2 distribution from previous releases found here

1. Create CARBON_HOME directory under Geronimo home. Copy the repository directory in the carbon distribution to Geronimo home. I have highlighted the important sub-directories and configuration files for our use-case.  

Mainly we need to focus on datasources/master-datasources.xml, registry.xml and user-mgt.xml to configure the Carbon datasource and components/plugins directory to point Geronimo to find the bundle set to deploy.
eg:
GERONIMO_HOME
 |
 |── CARBON_HOME
│   └── repository│    
│       │   └── conf
│       │       ├── axis2
│       │       ├── carbon.xml
│       │       ├── datasources
│       │       │   └── master-datasources.xml
│       │       ├── etc
│       │       ├── log4j.properties
│       │       ├── osgi-debug.options
│       │       ├── README
│       │       ├── registry.xml
│       │       ├── security
│       │       ├── tomcat
│       │       │   ├── carbon
│       │       │   │   ├── META-INF
│       │       │   │   │   └── context.xml
│       │       │   │   └── WEB-INF
│       │       │   │       └── web.xml
│       │       │   ├── catalina-server.xml
│       │       │   ├── tomcat-users.xml
│       │       │   └── web.xml
│       │       └── user-mgt.xml
│       ├── carbonapps
│       ├── components
│       │   ├── dropins
│       │   ├── extensions
│       │   ├── features
│       │   ├── lib
│       │   ├── p2
│       │   ├── patches
│       │   ├── plugins



The repository directory includes all the main artifacts, bundles and configurations for Carbon.


2. Remove the tomcat related bundles from $GERONIMO_HOME/CARBON_HOME/repository/components/plugins as Geronimo provides tomcat bundle by default; 
(remove below bundles)
  org.wso2.carbon.tomcat_4.0.1.jar 
           org.wso2.carbon.tomcat.ext_4.0.2.jar
           org.wso2.carbon.tomcat.fragment.dummy_4.0.0.jar
           org.wso2.carbon.tomcat.patch_4.0.1.jar 
           tomcat_7.0.28.wso2v1.jar
           tomcat-ha_7.0.28.wso2v1.jar

Also remove org.eclipse.osgi_3.7.0.v20110613 bundle as Geronimo provides the bundle by default.


3. Create a database for WSO2 UserManager and Registry and configure WSO2Carbon DataSource in $GERONIMO_HOME/CARBON_HOME/repository/conf/datasources/master-datasources.xml.

To create the database you can use the db-scripts from CARBON_HOME/dbscripts.
For more details on this, you can refer this blog post on configuring an embedded Derby Carbon datasource in Geronimo and how to configure user-manager and registry to use it.

4. Configure carbon.home system.property required by Carbon in $GERONIMO_HOME/etc/system.properties. 
carbon.home=${karaf.base}/CARBON_HOME

5. Setup Carbon bundle installation location in Geronimo by configuring $GERONIMO_HOME/etc/hotbundles-config/org.apache.felix.fileinstall-deploy.cfg to point to CARBON_HOME/repository/components/plugins to install Carbon bundles at startup.
felix.fileinstall.dir=${karaf.base}/CARBON_HOME/repository/components/plugins

6. Optionally you can modify Geronimo server's log4j configuration to support Carbon logging by adding the configurations to $GERONIMO_HOME/var/log/server-log4j.properties.
You can find the Carbon log4j configurations in :$CARBON_HOME/repository/conf/log4j.properties

An example configuration addition is as below;

log4j.rootLogger=INFO, CONSOLE, FILE, CARBON_CONSOLE, CARBON_LOGFILE

# CARBON_CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CARBON_CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CARBON_CONSOLE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
# ConversionPattern will be overridden by the configuration setting in the DB
log4j.appender.CARBON_CONSOLE.layout.ConversionPattern=[%d] %P%5p {%c} - %x %m%n
log4j.appender.CARBON_CONSOLE.layout.TenantPattern=%U%@%D[%T]
log4j.appender.CARBON_CONSOLE.threshold=DEBUG


# CARBON_LOGFILE is set to be a DailyRollingFileAppender using a PatternLayout.
log4j.appender.CARBON_LOGFILE=org.apache.log4j.DailyRollingFileAppender
# Log file will be overridden by the configuration setting in the DB
# This path should be relative to WSO2 Carbon Home
log4j.appender.CARBON_LOGFILE.File=${carbon.home}/repository/logs/${instance.log}/wso2carbon${instance.log}.log
log4j.appender.CARBON_LOGFILE.Append=true
log4j.appender.CARBON_LOGFILE.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
# ConversionPattern will be overridden by the configuration setting in the DB
log4j.appender.CARBON_LOGFILE.layout.ConversionPattern=TID: [%T] [%S] [%d] %P%5p {%c} - %x %m {%c}%n
log4j.appender.CARBON_LOGFILE.layout.TenantPattern=%U%@%D [%T] [%S]
log4j.appender.CARBON_LOGFILE.threshold=DEBUG




With above given minimal configurations you can test deploying Carbon bundles in Geronimo server. Please note that there are several bundle resolution issues which avoids complete startup of Carbon. 

For example some of the problems faced are: 
  • When using Geronimo v3, some of our bundles have import package resolution issue for javax.activation package. Some of our bundles (eg: jaxb, abdera, org.wso2.carbon.core.common, org.wso2.carbon.user.mgt.common) require package javax.activation with version [0.0.0,1.0.0) but Geronimo Spec system bundle in Geronimo provides javax.activation;version=1.1.0.  
  • We either have to override the export package version of javax.activation package to support our bundles import version range or change our bundle set not to bind to version range [0.0.0,1.0.0) for javax.activation package.
  • The bundle org.eclipse.equinox.util_1.0.300.v20110502 in plugins doesn't get resolved as it's  Missing Constraint: Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.1 in the runtime.  To resolve thisn change the OSGi execution environment property to OSGi/Minimum-1.1 in $GERONIMO_HOME/etc/config.properties
  • Carbon bundles require osgi.http.service to register servlets. Need a bundle which exposes osgi.http.service in the container for Carbon bundles to use. (eg: we can use org.eclipse.equinox.http bundle to provide osgi http service)
  • Noticed that the org.eclipse.equinox.http.helper_1.0.0.qualifier.jar doesn't get picked up automatically from plugins, because of this org.wso2.carbon.ui bundle doesn't get started. Therefore install org.eclipse.equinox.http.helper_1.0.0.qualifier.jar manually from the Geronimo console and start org.wso2.carbon.ui bundle
  • Class loading issues for org.wso2.carbon.core package
These issues require further investigations and experiments inorder to resolve completely.

No comments:

Post a Comment