celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriele Ricciardi <lele.riccia...@gmail.com>
Subject Re: issue with celix
Date Thu, 09 Jun 2016 12:54:16 GMT
bundleContext_getProperty expects a "clean" (i.e. NULL) pointer as
destination for the property. (The failing line is stated in the error log,
you can even have a look at the source code in
framework//private/src/bundle_context.c)

In your case, the first bundleContext_getProperty in the bundleCreate goes
fine because dm_hello_data=NULL.
When you restart the bundle dm_hello_data!=NULL because it was set by the
first bundleContext_getProperty, so the second bundleContext_getProperty
fails.

As a general rule, whatever is initialized/created in the create should be
de-initialized/destroyed in the destroy, and whatever is
initialized/created in the start should be de-initialized/destroyed in the
stop.

Set  dm_hello_data=NULL in the destroy and it will work. ;-)

Regards,

Gabriele

2016-06-09 14:22 GMT+02:00 Anupam Datta <adbd04@gmail.com>:

> Yes, I just had fixed the issue and seen your mail.
>
> It was successful. However when I stop the bundle and again start it, shows
> :
>
> anupam@anupam
> :~/Dev/ApacheCelix/git_celix/DM_proj_001/build/deploy/myproject-deploy$
> sh run.sh
> -> Anupam, Hello World
> Launcher: Framework Started
>
> -> lb
>   ID    State        Name
>   0     Active       framework
>   1     Active       apache_celix_shell
>   2     Active       apache_celix_shell_tui
>   3     Active       dm_bundle_001
> -> stop 3
> Anupam, Goodbye World
> -> lb
>   ID    State        Name
>   0     Active       framework
>   1     Active       apache_celix_shell
>   2     Active       apache_celix_shell_tui
>   3     Resolved     dm_bundle_001
> -> start 3
> ERROR: Illegal argument [70003]: "Failed to get property [name=DM_HELLO]"
> at
>
> bundleContext_getProperty(/home/anupam/Dev/ApacheCelix/git_celix/celix-src/framework/private/src/bundle_context.c:374)
> Anupam, Hello World
>
>
> Thanks & Regards
> Anupam Datta
>
>
> On Thu, Jun 9, 2016 at 5:03 PM, Gabriele Ricciardi <
> lele.ricciardi@gmail.com
> > wrote:
>
> > Hi Anupam,
> >
> > I think I found your issue: you declared in your activator
> >
> > #define HELLO_ACTIVATOR "DM HELLO"
> >
> > Defines in general should not contain spaces, but in this case it's even
> > more important because the properties_load() function parses properties
> in
> > the format KEY = VALUE , where both KEY and VALUE are strings containing
> > "conventional characters (i.e. a-z, A-Z, 1-9, . , - , _   ... and I
> > wouldn't dare to use something different :-) )
> >
> > Try to fix your define in
> >
> > #define HELLO_ACTIVATOR "DM_HELLO"
> >
> > and then put in your config.properties (by the way, I could not find
> custom
> > properties in the config.properties you sent us)
> >
> > DM_HELLO=<whatever_string.you-prefer>
> >
> > I tried it right now starting from your project and it works fine.
> >
> > Regards,
> >
> > Gabriele
> >
> >
> > 2016-06-09 11:45 GMT+02:00 Anupam Datta <adbd04@gmail.com>:
> >
> > > Hi I tried your suggestion and it showed (null) on the test.prop ie. it
> > > didn't take the property value from config.properties
> > >
> > > I am sending the directory structure and my built proj
> > >
> > > I followed the instruction :
> > >
> >
> https://github.com/apache/celix/blob/develop/documents/getting_started/readme.md
> > >
> > > anupam@anupam:~/Dev/ApacheCelix/git_celix/DM_proj_001$ tree
> > > .
> > > ├── build
> > > │   ├── bundles
> > > │   │   └── dm_bundle_001
> > > │   │       ├── CMakeFiles
> > > │   │       │   ├── CMakeDirectoryInformation.cmake
> > > │   │       │   ├── dm_bundle_001_bundle.dir
> > > │   │       │   │   ├── build.make
> > > │   │       │   │   ├── cmake_clean.cmake
> > > │   │       │   │   ├── DependInfo.cmake
> > > │   │       │   │   ├── depend.internal
> > > │   │       │   │   ├── depend.make
> > > │   │       │   │   └── progress.make
> > > │   │       │   ├── dm_bundle_001.dir
> > > │   │       │   │   ├── build.make
> > > │   │       │   │   ├── C.includecache
> > > │   │       │   │   ├── cmake_clean.cmake
> > > │   │       │   │   ├── DependInfo.cmake
> > > │   │       │   │   ├── depend.internal
> > > │   │       │   │   ├── depend.make
> > > │   │       │   │   ├── flags.make
> > > │   │       │   │   ├── link.txt
> > > │   │       │   │   ├── private
> > > │   │       │   │   │   └── src
> > > │   │       │   │   │       └── activator.c.o
> > > │   │       │   │   └── progress.make
> > > │   │       │   ├── myproject-deploy.dir
> > > │   │       │   │   ├── build.make
> > > │   │       │   │   ├── cmake_clean.cmake
> > > │   │       │   │   ├── DependInfo.cmake
> > > │   │       │   │   ├── depend.internal
> > > │   │       │   │   ├── depend.make
> > > │   │       │   │   └── progress.make
> > > │   │       │   └── progress.marks
> > > │   │       ├── cmake_install.cmake
> > > │   │       ├── dm_bundle_001_content
> > > │   │       │   └── libdm_bundle_001.so.1
> > > │   │       ├── dm_bundle_001_gen
> > > │   │       │   ├── lib-dm_bundle_001-copy-timestamp
> > > │   │       │   ├── MANIFEST.MF
> > > │   │       │   ├── MANIFEST.step1
> > > │   │       │   └── MANIFEST.step2
> > > │   │       ├── dm_bundle_001.zip
> > > │   │       ├── libdm_bundle_001.so -> libdm_bundle_001.so.1
> > > │   │       ├── libdm_bundle_001.so.1 -> libdm_bundle_001.so.1.0.0
> > > │   │       ├── libdm_bundle_001.so.1.0.0
> > > │   │       ├── Makefile
> > > │   │       └── myproject-deploy-timestamp
> > > │   ├── CMakeCache.txt
> > > │   ├── CMakeFiles
> > > │   │   ├── 3.5.1
> > > │   │   │   ├── CMakeCCompiler.cmake
> > > │   │   │   ├── CMakeDetermineCompilerABI_C.bin
> > > │   │   │   ├── CMakeSystem.cmake
> > > │   │   │   └── CompilerIdC
> > > │   │   │       ├── a.out
> > > │   │   │       └── CMakeCCompilerId.c
> > > │   │   ├── bundles.dir
> > > │   │   │   ├── build.make
> > > │   │   │   ├── cmake_clean.cmake
> > > │   │   │   ├── DependInfo.cmake
> > > │   │   │   ├── depend.internal
> > > │   │   │   ├── depend.make
> > > │   │   │   └── progress.make
> > > │   │   ├── cmake.check_cache
> > > │   │   ├── CMakeDirectoryInformation.cmake
> > > │   │   ├── CMakeOutput.log
> > > │   │   ├── CMakeRuleHashes.txt
> > > │   │   ├── CMakeTmp
> > > │   │   ├── deploy.dir
> > > │   │   │   ├── build.make
> > > │   │   │   ├── cmake_clean.cmake
> > > │   │   │   ├── DependInfo.cmake
> > > │   │   │   ├── depend.internal
> > > │   │   │   ├── depend.make
> > > │   │   │   └── progress.make
> > > │   │   ├── feature_tests.bin
> > > │   │   ├── feature_tests.c
> > > │   │   ├── Makefile2
> > > │   │   ├── Makefile.cmake
> > > │   │   ├── progress.marks
> > > │   │   ├── rat.dir
> > > │   │   │   ├── build.make
> > > │   │   │   ├── cmake_clean.cmake
> > > │   │   │   ├── DependInfo.cmake
> > > │   │   │   └── progress.make
> > > │   │   └── TargetDirectories.txt
> > > │   ├── cmake_install.cmake
> > > │   ├── deploy
> > > │   │   └── myproject-deploy
> > > │   │       ├── config.properties
> > > │   │       ├── config.properties.step1
> > > │   │       ├── core
> > > │   │       ├── myproject-deploy
> > > │   │       └── run.sh
> > > │   └── Makefile
> > > ├── bundles
> > > │   └── dm_bundle_001
> > > │       ├── CMakeLists.txt
> > > │       └── private
> > > │           └── src
> > > │               └── activator.c
> > > └── CMakeLists.txt
> > >
> > > 24 directories, 78 files
> > >
> > > And my project is attached.
> > >
> > > Thanks & Regards
> > > Anupam Datta
> > >
> > > On Thu, Jun 2, 2016 at 8:28 PM, Gabriele Ricciardi <
> > > lele.ricciardi@gmail.com> wrote:
> > >
> > >> Hi Anupam,
> > >>
> > >> In principle your code looks correct, so I tried (more or less) the
> same
> > >> as you and for me it works fine.
> > >>
> > >> Just to be sure, and also to give you a reference example, find
> attached
> > >> a sample project based on the hello_world.
> > >>
> > >> Probably you already know how to build a bundle, but just in case (and
> > >> assuming you already have Celix correctly installed on your machine)
> > >>
> > >> - Untar the project
> > >> - Create a hello_props_build folder besides it
> > >> - cd hello_props_build && ccmake
> > >>  -DCELIX_DIR=<path_to_your_celix_install_path> ../hello_props
> > >> - make && make deploy
> > >> - cd deploy/hello_properties
> > >> - echo 'DM_HELLO=test.props' >> config.properties
> > >> - sh run.sh
> > >>
> > >> This should print the Hello World and then the property just appended
> to
> > >> the config.properties .
> > >>
> > >> I hope this clarify a bit!
> > >>
> > >> Regards,
> > >>
> > >> Gabriele Ricciardi
> > >>
> > >>
> > >> 2016-06-01 12:10 GMT+02:00 Anupam Datta <adbd04@gmail.com>:
> > >>
> > >>> I tried with config.properties but not sure how actually I can
> achieve
> > >>> that. Do you have any example code or clear docs ?
> > >>> I had added DM_HELLO="hello_properties" in config.properties file
> > >>> and in activator.c file I added :
> > >>>
> > >>> #define HELLO_ACTIVATOR "DM HELLO" //DM_HELLO is the name of the
> > property
> > >>> mentioned in config.properties file
> > >>> char *dm_hello_data = NULL;
> > >>>
> > >>> Then inside bundleActivator_create(...
> > >>> I added bundleContext_getProperty(context, HELLO_ACTIVATOR,
> > >>> &dm_hello_data);
> > >>>
> > >>> Inside bundleActivator_start(....
> > >>> I added : printf("%sHello %s\n", dm_hello_data, data->word);
> > >>>
> > >>> But I could not get "hello_properties" printed in last line ie .
> > >>> printf("%sHello
> > >>> %s\n", dm_hello_data, data->word);
> > >>>
> > >>> Let me know what is the exact way of adding and retrieving from
> > >>> config.properties
> > >>>
> > >>> Thanks & Regards
> > >>> Anupam Datta
> > >>>
> > >>> On Fri, May 27, 2016 at 1:36 PM, Pepijn Noltes <
> pepijnnoltes@gmail.com
> > >
> > >>> wrote:
> > >>>
> > >>> > Hi,
> > >>> >
> > >>> > On Thu, May 26, 2016 at 9:11 AM, Anupam Datta <adbd04@gmail.com>
> > >>> wrote:
> > >>> > > Hi Pepjin,
> > >>> > > I had some query regarding celix :
> > >>> > >
> > >>> > > 1. is it possible to pass arguments to bundles ? ie. at the
time
> of
> > >>> > > starting I want to send some configurable parameters.
> > >>> >
> > >>> > Yes. Currently there are two ways.
> > >>> >
> > >>> >  1 Add a property to the config.properties file. A bundle can
> > retrieve
> > >>> > the values using the bundleContext_getProperty. See [1] and [2].
> > >>> > When possible we try to follow the Java OSGi api (adapted to C).
> > >>> >  2 Declare a env variable. In case of the Celix
> > >>> > bundleContext_getProperty method if a property is not present
in
> the
> > >>> > framework properties (read the config.properties file) the
> framework
> > >>> > will look if there is an environment variable present with the
> > >>> > requested property name
> > >>> >
> > >>> > [1]
> > >>> >
> > >>>
> >
> https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#getProperty%28java.lang.String%29
> > >>> > [2]
> > >>> >
> > >>>
> >
> https://github.com/apache/celix/blob/master/framework/public/include/bundle_context.h
> > >>> >
> > >>> > Another way is to use the config admin, this is more flexible
but
> > also
> > >>> > more complex. And there are still some TODO's left for the config
> > >>> > admin.
> > >>> >
> > >>> >
> > >>> > > 2. What is the way of remotely controlling and data capturing
via
> > >>> celix
> > >>> > > bundles ? Is there any server where device can register itself
> via
> > >>> celix
> > >>> > > and from server through browser we can start stop bundle
and
> fetch
> > >>> data?
> > >>> > > I had seen the remote shell and remote service folder but
not
> much
> > >>> > > documentation is available there in the folders to understand
how
> > >>> exactly
> > >>> > > it works.
> > >>> >
> > >>> > For remote controlling the bundles you can use the remote shell
and
> > >>> Apache
> > >>> > ACE.
> > >>> > For remote shell you can try the remote_shell example (in the
> > >>> > deploy/remote_shell folder of the build).
> > >>> > When started use a telnet program to connect (telnet localhost
> 6666).
> > >>> > The remote_shell depends on the shell bundle.
> > >>> > Note that remote_shell is a nice feature to gain remote control,
> but
> > >>> > is (by design) not secure.
> > >>> >
> > >>> > An other option is to use Apache ACE. In this case different
> devices
> > >>> > can register to Apache ACE using the deployment_admin bundle.
You
> can
> > >>> > then use Apache ACE to define which bundles should be deployed
on
> > >>> > which devices. See Apache ACE [3] for more info. You can combine
> this
> > >>> > with remote shell for more control.
> > >>> >
> > >>> > [3] https://ace.apache.org/
> > >>> >
> > >>> >
> > >>> >
> > >>> > Remote services can be used to create distributed application
base
> on
> > >>> > services. The Apache Celix remote services implementation works
> with
> > >>> > the Amdatu Remote Services implementation [4]
> > >>> > The remote-services-cfg example should work out of the box to
give
> > you
> > >>> an
> > >>> > idea.
> > >>> > Note that although technically remote services works, you still
> need
> > >>> > to put considerable effort in it to get something working.
> > >>> > We are aware of this and are working on a solution to simplify
the
> > use
> > >>> > of remote services, but for the time being manually effort is
> needed
> > >>> > to get it running.
> > >>> >
> > >>> > [4] http://www.amdatu.org/components/remote.html
> > >>> >
> > >>> > Could you specify in more details why do want to build / meand
with
> > >>> > 'data capturing via celix' ? Because I am not sure if the remote
> > >>> > services is want you want (synchronized communication).
> > >>> >
> > >>> >
> > >>> >
> > >>> > >
> > >>> > > Thanks & Regards
> > >>> > > Anupam Datta
> > >>> > >
> > >>> > > On Tue, May 24, 2016 at 12:42 AM, Anupam Datta <adbd04@gmail.com
> >
> > >>> wrote:
> > >>> > >
> > >>> > >> Thank you Pepjin. I will definitely try that out.
> > >>> > >>
> > >>> > >> Thanks & Regards
> > >>> > >> Anupam Datta
> > >>> > >> On 24-May-2016 12:28 AM, "Pepijn Noltes" <
> pepijnnoltes@gmail.com>
> > >>> > wrote:
> > >>> > >>
> > >>> > >>> Hi Anupam,
> > >>> > >>>
> > >>> > >>> Please use the documentation at
> > >>> > >>> https://github.com/apache/celix/tree/develop/documents
> > >>> > >>> The idea is when a new Celix release has been made,
the website
> > >>> will
> > >>> > >>> refer to documentation github.
> > >>> > >>>
> > >>> > >>> On Mon, May 23, 2016 at 11:52 AM, Anupam Datta <
> adbd04@gmail.com
> > >
> > >>> > wrote:
> > >>> > >>> > Hi,
> > >>> > >>> > I had tried with git version as per the doc
:
> > >>> > >>> > https://celix.apache.org/documentation/getting_started.html
> > >>> > >>> > after
> > >>> > >>> > make all
> > >>> > >>> > I did :
> > >>> > >>> > #install the framework and the bundles
> > >>> > >>> > sudo make install-all
> > >>> > >>> >
> > >>> > >>> > It showed me error : make: *** No rule to make
target
> > >>> 'install-all'.
> > >>> > >>> Stop.
> > >>> > >>> >
> > >>> > >>> > So I did sudo make install
> > >>> > >>> >
> > >>> > >>> > log file attached : install_log.txt
> > >>> > >>> >
> > >>> > >>> > I created the demo project . After creating,
built it and
> > another
> > >>> > error
> > >>> > >>> > showed  :
> > >>> > >>> >
> > >>> > >>> > -- Using jar to create bundles
> > >>> > >>> > -- bundle function is deprecated. update target
'hello_001'
> to
> > >>> > >>> add_bundle
> > >>> > >>> > -- Configuring done
> > >>> > >>> > CMake Error at
> > >>> > >>> >
> > >>> /usr/local/share/celix/cmake/modules/cmake_celix/Packaging.cmake:149
> > >>> > >>> > (add_library):
> > >>> > >>> >   Cannot find source file:
> > >>> > >>> >
> > >>> > >>> >     (
> > >>> > >>> >
> > >>> > >>> >   Tried extensions .c .C .c++ .cc .cpp .cxx
.m .M .mm .h .hh
> > >>> .h++ .hm
> > >>> > >>> .hpp
> > >>> > >>> >   .hxx .in .txx
> > >>> > >>> > Call Stack (most recent call first):
> > >>> > >>> >
> > >>> > >>>
> > >>> >
> > >>>
> > /usr/local/share/celix/cmake/modules/cmake_celix/PackagingLegacy.cmake:41
> > >>> > >>> > (add_bundle)
> > >>> > >>> >   bundles/hello_001/CMakeLists.txt:4 (bundle)
> > >>> > >>> >
> > >>> > >>>
> > >>> > >>> The documentation was incorrect. The should be no
parentheses
> > >>> around
> > >>> > >>> the bundle SOURCES.
> > >>> > >>> If you remove them, it should work ....
> > >>> > >>>
> > >>> > >>> >
> > >>> > >>> > CMake Error: CMake can not determine linker
language for
> > target:
> > >>> > >>> hello_001
> > >>> > >>> > CMake Error: Cannot determine link language
for target
> > >>> "hello_001".
> > >>> > >>> > -- Generating done
> > >>> > >>> > -- Build files have been written to:
> > >>> > >>> > /home/anupam/Dev/ApacheCelix/git_celix/DM_proj_001-build
> > >>> > >>> >
> > >>> > >>> > So what was the issue with it? The directory
structure of the
> > >>> demo
> > >>> > proj
> > >>> > >>> :
> > >>> > >>> >
> > >>> > >>> > ├── DM_proj_001
> > >>> > >>> > │   ├── bundles
> > >>> > >>> > │   │   └── hello_001
> > >>> > >>> > │   │       ├── CMakeLists.txt
> > >>> > >>> > │   │       └── private
> > >>> > >>> > │   │           └── src
> > >>> > >>> > │   │               └── activator.c
> > >>> > >>> > │   └── CMakeLists.txt
> > >>> > >>> > └── DM_proj_001-build
> > >>> > >>> >     ├── bundles
> > >>> > >>> >     │   └── hello_001
> > >>> > >>> >     │       ├── CMakeFiles
> > >>> > >>> >     │       │   ├── CMakeDirectoryInformation.cmake
> > >>> > >>> >     │       │   ├── hello_001_bundle.dir
> > >>> > >>> >     │       │   │   ├── build.make
> > >>> > >>> >     │       │   │   ├── cmake_clean.cmake
> > >>> > >>> >     │       │   │   ├── DependInfo.cmake
> > >>> > >>> >     │       │   │   └── progress.make
> > >>> > >>> >     │       │   ├── hello_001.dir
> > >>> > >>> >     │       │   │   ├── build.make
> > >>> > >>> >     │       │   │   ├── cmake_clean.cmake
> > >>> > >>> >     │       │   │   ├── DependInfo.cmake
> > >>> > >>> >     │       │   │   ├── depend.make
> > >>> > >>> >     │       │   │   ├── flags.make
> > >>> > >>> >     │       │   │   └── progress.make
> > >>> > >>> >     │       │   └── progress.marks
> > >>> > >>> >     │       ├── cmake_install.cmake
> > >>> > >>> >     │       ├── hello_001_gen
> > >>> > >>> >     │       │   ├── MANIFEST.MF
> > >>> > >>> >     │       │   ├── MANIFEST.step1
> > >>> > >>> >     │       │   └── MANIFEST.step2
> > >>> > >>> >     │       └── Makefile
> > >>> > >>> >     ├── CMakeCache.txt
> > >>> > >>> >     ├── CMakeFiles
> > >>> > >>> >     │   ├── 3.5.1
> > >>> > >>> >     │   │   ├── CMakeCCompiler.cmake
> > >>> > >>> >     │   │   ├── CMakeDetermineCompilerABI_C.bin
> > >>> > >>> >     │   │   ├── CMakeSystem.cmake
> > >>> > >>> >     │   │   └── CompilerIdC
> > >>> > >>> >     │   │       ├── a.out
> > >>> > >>> >     │   │       └── CMakeCCompilerId.c
> > >>> > >>> >     │   ├── bundles.dir
> > >>> > >>> >     │   │   ├── build.make
> > >>> > >>> >     │   │   ├── cmake_clean.cmake
> > >>> > >>> >     │   │   ├── DependInfo.cmake
> > >>> > >>> >     │   │   └── progress.make
> > >>> > >>> >     │   ├── cmake.check_cache
> > >>> > >>> >     │   ├── CMakeDirectoryInformation.cmake
> > >>> > >>> >     │   ├── CMakeOutput.log
> > >>> > >>> >     │   ├── CMakeRuleHashes.txt
> > >>> > >>> >     │   ├── CMakeTmp
> > >>> > >>> >     │   ├── deploy.dir
> > >>> > >>> >     │   │   ├── build.make
> > >>> > >>> >     │   │   ├── cmake_clean.cmake
> > >>> > >>> >     │   │   ├── DependInfo.cmake
> > >>> > >>> >     │   │   └── progress.make
> > >>> > >>> >     │   ├── feature_tests.bin
> > >>> > >>> >     │   ├── feature_tests.c
> > >>> > >>> >     │   ├── Makefile2
> > >>> > >>> >     │   ├── Makefile.cmake
> > >>> > >>> >     │   ├── progress.marks
> > >>> > >>> >     │   ├── rat.dir
> > >>> > >>> >     │   │   ├── build.make
> > >>> > >>> >     │   │   ├── cmake_clean.cmake
> > >>> > >>> >     │   │   ├── DependInfo.cmake
> > >>> > >>> >     │   │   └── progress.make
> > >>> > >>> >     │   └── TargetDirectories.txt
> > >>> > >>> >     ├── cmake_install.cmake
> > >>> > >>> >     └── Makefile
> > >>> > >>> >
> > >>> > >>> > Please share your view on it. let me know if
any other log is
> > >>> needed.
> > >>> > >>> >
> > >>> > >>> > Thanks & Regards
> > >>> > >>> > Anupam Datta
> > >>> > >>> >
> > >>> > >>>
> > >>> > >>> Greetings,
> > >>> > >>> Pepijn
> > >>> > >>>
> > >>> > >>
> > >>> >
> > >>>
> > >>
> > >>
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message