You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Sam Liu <vi...@gmail.com> on 2012/08/07 17:20:02 UTC

OSGi bundle configuration file

Hi guys,

I have a few OSGi bundles written using Equinox, and they were deployed
under the Equinox framework. Now I am trying to deploy them under Karaf.
However, I have some properties that these bundles would read from the
/configuration/config.ini file under the Equinox framework before the
bundles start. Under Karaf, I am having troubles to find the place/file to
store those bundle properties.

I tried to follow some online posts, and but they seem to be a bit
complicated than how Equinox framework handles this. Is there a particular
file that I can just put these bundle properties in? I also tried to create
a mybundlename.cfg file in the /etc folder. However, it didn't work. Could
anyone please tell me what I should do?

Many thanks!

Sam

Re: OSGi bundle configuration file

Posted by Sam Liu <vi...@gmail.com>.
Hi JB,

Thanks for the quick response. I tried to include the bundle properties in
the config.properties file, but it didn't seem to work.

I created a etc/my.bundle.name.cfg file. I was able to see it when typing
config:list in the karaf console, and the Pid is the bundle name, and I can
see the bundle properties. However, the bundle still wouldn't work
correctly. Is there anything else I need to do? Do I need to recreate my
bundle? When you said "your bundle has to use ConfigAdmin", could you
please elaborate a little bit?

Thanks again!

Sam


On Tue, Aug 7, 2012 at 11:37 AM, Jean-Baptiste Onofré <jb...@nanthrax.net>wrote:

> Hi Sam,
>
> AFAIR, Equinox uses system properties, so you can try to put it in
> config.properties.
>
> If you want to use etc/my.bundle.name.cfg, your bundle has to use
> ConfigAdmin.
>
> Regards
> JB
>
>
> On 08/07/2012 05:20 PM, Sam Liu wrote:
>
>> Hi guys,
>>
>> I have a few OSGi bundles written using Equinox, and they were deployed
>> under the Equinox framework. Now I am trying to deploy them under Karaf.
>> However, I have some properties that these bundles would read from the
>> /configuration/config.ini file under the Equinox framework before the
>> bundles start. Under Karaf, I am having troubles to find the place/file
>> to store those bundle properties.
>>
>> I tried to follow some online posts, and but they seem to be a bit
>> complicated than how Equinox framework handles this. Is there a
>> particular file that I can just put these bundle properties in? I also
>> tried to create a mybundlename.cfg file in the /etc folder. However, it
>> didn't work. Could anyone please tell me what I should do?
>>
>> Many thanks!
>>
>> Sam
>>
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: OSGi bundle configuration file

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Sam,

AFAIR, Equinox uses system properties, so you can try to put it in 
config.properties.

If you want to use etc/my.bundle.name.cfg, your bundle has to use 
ConfigAdmin.

Regards
JB

On 08/07/2012 05:20 PM, Sam Liu wrote:
> Hi guys,
>
> I have a few OSGi bundles written using Equinox, and they were deployed
> under the Equinox framework. Now I am trying to deploy them under Karaf.
> However, I have some properties that these bundles would read from the
> /configuration/config.ini file under the Equinox framework before the
> bundles start. Under Karaf, I am having troubles to find the place/file
> to store those bundle properties.
>
> I tried to follow some online posts, and but they seem to be a bit
> complicated than how Equinox framework handles this. Is there a
> particular file that I can just put these bundle properties in? I also
> tried to create a mybundlename.cfg file in the /etc folder. However, it
> didn't work. Could anyone please tell me what I should do?
>
> Many thanks!
>
> Sam

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: OSGi bundle configuration file

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Besides remove the whole data folder, I believe refresh your customer bundles which need read properties can also pick up the change.

Freeman
-------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-8-9, at 下午9:17, Sam Liu wrote:

> Hi Christian,
> 
> The problem seems to be solved, after I placed the bundle properties into the system.properties file. However, the /data folder needs to be removed before starting karaf. This could be why it didn't work the first time I tried to use system.properties file. 
> 
> Anyway, thanks a lot for your suggestion.
> 
> Best,
> 
> Sam
> 
> On Tue, Aug 7, 2012 at 4:14 PM, Christian Schneider <ch...@die-schneider.net> wrote:
> Hi Sam,
> 
> how did you read the config.ini? Did you directly open a File using the relative path configuration/config.ini? This could also work in Karaf but is not really recommended as you should not assume where the current
> directory is. So using the config admin service would be the recommended way to do configurations in OSGi. On the other hand I am not sure plain Equinox already has a working config admin service implementation.
> So you may have to install the felix config admin service impl and felix file install to get the same functionality.
> 
> Christian
> 
> 
> Am 07.08.2012 20:31, schrieb Sam Liu:
>> Thank you, Christian. I am aware of your tutorial, and have been trying to follow that. 
>> 
>> Just wanted to make it clear, please allow me to describe my problem again: 
>> 
>> I have two OSGi bundles which were running under Equinox OSGi framework. The two bundles would read some properties/parameters when they started, e.g., host ip address, port, container name, etc., from the configuration/config.ini file under the Equinox framework. 
>> 
>> Now when I deploy the two bundles into karaf /deploy folder, the two bundles would try to start when karaf starts, but they quickly failed since they are not able to read the properties/parameters, no matter where I put these properties, in the etc/config.properties or system.properties or my.bundle.name.cfg files. 
>> 
>> So back to what you have suggested, a fundamental question I have is do I need to recreate my bundle using config admin service? 
>> 
>> Thanks!
>> 
>> Sam
>> 
>> 
>> On Tue, Aug 7, 2012 at 1:52 PM, Christian Schneider <ch...@die-schneider.net> wrote:
>> Hi Sam,
>> 
>> If you are talking about configuration properties for your bundles then you should consider using the config admin service.
>> See: http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service 
>> 
>> Karaf also allows to access the properties from etc/system.properties as System.getProperty("...")
>> 
>> Christian
>> 
>> Am 07.08.2012 17:20, schrieb Sam Liu:
>> 
>> Hi guys,
>> 
>> I have a few OSGi bundles written using Equinox, and they were deployed under the Equinox framework. Now I am trying to deploy them under Karaf. However, I have some properties that these bundles would read from the /configuration/config.ini file under the Equinox framework before the bundles start. Under Karaf, I am having troubles to find the place/file to store those bundle properties.
>> 
>> I tried to follow some online posts, and but they seem to be a bit complicated than how Equinox framework handles this. Is there a particular file that I can just put these bundle properties in? I also tried to create a mybundlename.cfg file in the /etc folder. However, it didn't work. Could anyone please tell me what I should do?
>> 
>> Many thanks!
>> 
>> Sam
>> 
>> 
>> -- 
>>  Christian Schneider
>> http://www.liquid-reality.de
>> 
>> Open Source Architect
>> Talend Application Integration Division http://www.talend.com
>> 
>> 
> 
> 
> -- 
>  
> Christian Schneider
> http://www.liquid-reality.de
> 
> Open Source Architect
> Talend Application Integration Division http://www.talend.com 
> 


Re: OSGi bundle configuration file

Posted by Sam Liu <vi...@gmail.com>.
Hi Christian,

The problem seems to be solved, after I placed the bundle properties into
the system.properties file. However, the /data folder needs to be removed
before starting karaf. This could be why it didn't work the first time I
tried to use system.properties file.

Anyway, thanks a lot for your suggestion.

Best,

Sam

On Tue, Aug 7, 2012 at 4:14 PM, Christian Schneider <chris@die-schneider.net
> wrote:

>  Hi Sam,
>
> how did you read the config.ini? Did you directly open a File using the
> relative path configuration/config.ini? This could also work in Karaf but
> is not really recommended as you should not assume where the current
> directory is. So using the config admin service would be the recommended
> way to do configurations in OSGi. On the other hand I am not sure plain
> Equinox already has a working config admin service implementation.
> So you may have to install the felix config admin service impl and felix
> file install to get the same functionality.
>
> Christian
>
>
> Am 07.08.2012 20:31, schrieb Sam Liu:
>
> Thank you, Christian. I am aware of your tutorial, and have been trying to
> follow that.
>
>  Just wanted to make it clear, please allow me to describe my problem
> again:
>
>  I have two OSGi bundles which were running under Equinox OSGi framework.
> The two bundles would read some properties/parameters when they started,
> e.g., host ip address, port, container name, etc., from the
> configuration/config.ini file under the Equinox framework.
>
>  Now when I deploy the two bundles into karaf /deploy folder, the two
> bundles would try to start when karaf starts, but they quickly failed since
> they are not able to read the properties/parameters, no matter where I put
> these properties, in the etc/config.properties or system.properties or
> my.bundle.name.cfg files.
>
>  So back to what you have suggested, a fundamental question I have is do
> I need to recreate my bundle using config admin service?
>
>  Thanks!
>
>  Sam
>
>
> On Tue, Aug 7, 2012 at 1:52 PM, Christian Schneider <
> chris@die-schneider.net> wrote:
>
>> Hi Sam,
>>
>> If you are talking about configuration properties for your bundles then
>> you should consider using the config admin service.
>> See:
>> http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service
>>
>> Karaf also allows to access the properties from etc/system.properties as
>> System.getProperty("...")
>>
>> Christian
>>
>> Am 07.08.2012 17:20, schrieb Sam Liu:
>>
>>  Hi guys,
>>>
>>> I have a few OSGi bundles written using Equinox, and they were deployed
>>> under the Equinox framework. Now I am trying to deploy them under Karaf.
>>> However, I have some properties that these bundles would read from the
>>> /configuration/config.ini file under the Equinox framework before the
>>> bundles start. Under Karaf, I am having troubles to find the place/file to
>>> store those bundle properties.
>>>
>>> I tried to follow some online posts, and but they seem to be a bit
>>> complicated than how Equinox framework handles this. Is there a particular
>>> file that I can just put these bundle properties in? I also tried to create
>>> a mybundlename.cfg file in the /etc folder. However, it didn't work. Could
>>> anyone please tell me what I should do?
>>>
>>> Many thanks!
>>>
>>> Sam
>>>
>>
>>
>>   --
>>  Christian Schneider
>> http://www.liquid-reality.de
>>
>> Open Source Architect
>> Talend Application Integration Division http://www.talend.com
>>
>>
>
>
> --
>
> Christian Schneiderhttp://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>

Re: OSGi bundle configuration file

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Sam,

how did you read the config.ini? Did you directly open a File using the 
relative path configuration/config.ini? This could also work in Karaf 
but is not really recommended as you should not assume where the current
directory is. So using the config admin service would be the recommended 
way to do configurations in OSGi. On the other hand I am not sure plain 
Equinox already has a working config admin service implementation.
So you may have to install the felix config admin service impl and felix 
file install to get the same functionality.

Christian


Am 07.08.2012 20:31, schrieb Sam Liu:
> Thank you, Christian. I am aware of your tutorial, and have been 
> trying to follow that.
>
> Just wanted to make it clear, please allow me to describe my problem 
> again:
>
> I have two OSGi bundles which were running under Equinox OSGi 
> framework. The two bundles would read some properties/parameters when 
> they started, e.g., host ip address, port, container name, etc., from 
> the configuration/config.ini file under the Equinox framework.
>
> Now when I deploy the two bundles into karaf /deploy folder, the two 
> bundles would try to start when karaf starts, but they quickly failed 
> since they are not able to read the properties/parameters, no matter 
> where I put these properties, in the etc/config.properties or 
> system.properties or my.bundle.name.cfg files.
>
> So back to what you have suggested, a fundamental question I have is 
> do I need to recreate my bundle using config admin service?
>
> Thanks!
>
> Sam
>
>
> On Tue, Aug 7, 2012 at 1:52 PM, Christian Schneider 
> <chris@die-schneider.net <ma...@die-schneider.net>> wrote:
>
>     Hi Sam,
>
>     If you are talking about configuration properties for your bundles
>     then you should consider using the config admin service.
>     See:
>     http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service
>
>
>     Karaf also allows to access the properties from
>     etc/system.properties as System.getProperty("...")
>
>     Christian
>
>     Am 07.08.2012 17:20, schrieb Sam Liu:
>
>         Hi guys,
>
>         I have a few OSGi bundles written using Equinox, and they were
>         deployed under the Equinox framework. Now I am trying to
>         deploy them under Karaf. However, I have some properties that
>         these bundles would read from the /configuration/config.ini
>         file under the Equinox framework before the bundles start.
>         Under Karaf, I am having troubles to find the place/file to
>         store those bundle properties.
>
>         I tried to follow some online posts, and but they seem to be a
>         bit complicated than how Equinox framework handles this. Is
>         there a particular file that I can just put these bundle
>         properties in? I also tried to create a mybundlename.cfg file
>         in the /etc folder. However, it didn't work. Could anyone
>         please tell me what I should do?
>
>         Many thanks!
>
>         Sam
>
>
>
>     -- 
>      Christian Schneider
>     http://www.liquid-reality.de
>
>     Open Source Architect
>     Talend Application Integration Division http://www.talend.com
>
>


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: OSGi bundle configuration file

Posted by Sam Liu <vi...@gmail.com>.
Thank you, Christian. I am aware of your tutorial, and have been trying to
follow that.

Just wanted to make it clear, please allow me to describe my problem again:

I have two OSGi bundles which were running under Equinox OSGi framework.
The two bundles would read some properties/parameters when they started,
e.g., host ip address, port, container name, etc., from the
configuration/config.ini file under the Equinox framework.

Now when I deploy the two bundles into karaf /deploy folder, the two
bundles would try to start when karaf starts, but they quickly failed since
they are not able to read the properties/parameters, no matter where I put
these properties, in the etc/config.properties or system.properties or
my.bundle.name.cfg files.

So back to what you have suggested, a fundamental question I have is do I
need to recreate my bundle using config admin service?

Thanks!

Sam


On Tue, Aug 7, 2012 at 1:52 PM, Christian Schneider <chris@die-schneider.net
> wrote:

> Hi Sam,
>
> If you are talking about configuration properties for your bundles then
> you should consider using the config admin service.
> See: http://www.liquid-reality.de/**display/liquid/2011/09/23/**
> Karaf+Tutorial+Part+2+-+Using+**the+Configuration+Admin+**Service<http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service>
>
> Karaf also allows to access the properties from etc/system.properties as
> System.getProperty("...")
>
> Christian
>
> Am 07.08.2012 17:20, schrieb Sam Liu:
>
>  Hi guys,
>>
>> I have a few OSGi bundles written using Equinox, and they were deployed
>> under the Equinox framework. Now I am trying to deploy them under Karaf.
>> However, I have some properties that these bundles would read from the
>> /configuration/config.ini file under the Equinox framework before the
>> bundles start. Under Karaf, I am having troubles to find the place/file to
>> store those bundle properties.
>>
>> I tried to follow some online posts, and but they seem to be a bit
>> complicated than how Equinox framework handles this. Is there a particular
>> file that I can just put these bundle properties in? I also tried to create
>> a mybundlename.cfg file in the /etc folder. However, it didn't work. Could
>> anyone please tell me what I should do?
>>
>> Many thanks!
>>
>> Sam
>>
>
>
> --
>  Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>

Re: OSGi bundle configuration file

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Sam,

If you are talking about configuration properties for your bundles then 
you should consider using the config admin service.
See: 
http://www.liquid-reality.de/display/liquid/2011/09/23/Karaf+Tutorial+Part+2+-+Using+the+Configuration+Admin+Service 


Karaf also allows to access the properties from etc/system.properties as 
System.getProperty("...")

Christian

Am 07.08.2012 17:20, schrieb Sam Liu:
> Hi guys,
>
> I have a few OSGi bundles written using Equinox, and they were 
> deployed under the Equinox framework. Now I am trying to deploy them 
> under Karaf. However, I have some properties that these bundles would 
> read from the /configuration/config.ini file under the Equinox 
> framework before the bundles start. Under Karaf, I am having troubles 
> to find the place/file to store those bundle properties.
>
> I tried to follow some online posts, and but they seem to be a bit 
> complicated than how Equinox framework handles this. Is there a 
> particular file that I can just put these bundle properties in? I also 
> tried to create a mybundlename.cfg file in the /etc folder. However, 
> it didn't work. Could anyone please tell me what I should do?
>
> Many thanks!
>
> Sam


-- 
  
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com