Is it possible access a database within osgi bundle's start method?

        public void start(BundleContext context) throws Exception {
            ModelService modelService = new ModelService();
            context.registerService(ModelService.class.getName(),
modelService, null);

* MLAlgorithmConfiguration mlAlgorithmConfiguration = new
MLAlgorithmConfiguration();
mlAlgorithmConfiguration.loadMLAlgorithmConfigurations();*
            logger.info("Model service started");
        }

loadMLConfigurations loads some default values to a database. Adding bold
lettered lines throws following exception

INFO {org.wso2.carbon.ml.dataset.DatasetServiceActivator} -  Dataset
service started
[2014-11-13 16:48:49,589] ERROR {org.wso2.carbon.ml.model.DatabaseHandler}
-  An error occurred while connecting to database. Name [jdbc/WSO2ML_DB] is
not bound in this Context. Unable to find [jdbc].
javax.naming.NameNotFoundException: Name [jdbc/WSO2ML_DB] is not bound in
this Context. Unable to find [jdbc].
    at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
    at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
    at
org.wso2.carbon.context.internal.CarbonContextDataHolder$CarbonInitialJNDIContext.lookup(CarbonContextDataHolder.java:705)
    at javax.naming.InitialContext.lookup(InitialContext.java:411)
    at
org.wso2.carbon.ml.model.DatabaseHandler.getDatabaseHandler(DatabaseHandler.java:62)

-- 
Lochana Menikarachchi
Senior Tech Lead
WSO2 Inc.
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to