Thanks Clement - that worked perfectly!

I don't know how I've missed that FAQ but now I learned something new.

Yes, I used the latest maven-ipojo-plugin from trunk.

/Bengt



2010/10/3 clement escoffier <[email protected]>

> Hi,
>
> 2010/10/3 Bengt Rodehav <[email protected]>
>
> > Clement,
> >
> > I've upgrade to iPOJO 1.6.0 but I still have problems exposing services
> > using the @ServiceController.
> >
> > I get:
> >
> > factory name="connect.skandia.filetransfer" state="invalid" bundle="86"
> >
> >
> implementation-class="se.digia.connect.services.skandia.filetransfer.FileTransferService"
> > missinghandlers
> > list="[org.apache.felix.ipojo.annotations:servicecontroller]"
> > requiredhandlers list="[org.apache.felix.ipojo:requires,
> > org.apache.felix.ipojo:properties, org.apache.felix.ipojo:callback,
> > org.apache.felix.ipojo:provides,
> > org.apache.felix.ipojo.annotations:servicecontroller,
> > org.apache.felix.ipojo:architecture]"
> >
> > in the Webconsole under iPOJO/factories. It seems iPOJO cannot find a
> > handler for
> >
> > org.apache.felix.ipojo.annotations:servicecontroller
> >
> > What bundle am I missing?
> >
>
> No, but you must use the manipulator 1.6.4 as explained in:
>
> http://felix.apache.org/site/ipojo-faq.html#iPOJOFAQ-Usingadifferentversionofthemanipulatorduringthemanipulation
>
>
> >
> > BTW I also move away from using the ipojo url handler (online
> manipulator)
> > and started using the maven-ipojo-plugin instead. It turns out I cannot
> use
> > the latest released version of the plugin (1.6.0) but I have to use
> > 1.7.0-SNAPSHOT.
>
>
> Here is the configuration you should use.
>
> <plugin>
>        <groupId>org.apache.felix</groupId>
>        <artifactId>maven-ipojo-plugin</artifactId>
>        <executions>
>          <execution>
>            <goals>
>              <goal>ipojo-bundle</goal>
>            </goals>
>          </execution>
>        </executions>
>        <dependencies>
>                <dependency>
>                        <groupId>org.apache.felix</groupId>
>
>  <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
>                        <version>1.6.4</version>
>                </dependency>
>        </dependencies>
>      </plugin>
>
>
>
>
> > Otherwise I get the following exception:
> >
> > java.lang.NullPointerException
> >
>
> I will look into that. Did you use the latest from trunk ?
>
> Regards,
>
> Clement
>
>
>
> >
> >        at
> > >
> >
> org.apache.felix.ipojo.manipulation.annotations.MetadataCollector.visitEnd(MetadataCollector.java:215)
> >
> >        at org.objectweb.asm.ClassReader.accept(Unknown Source)
> >
> >        at org.objectweb.asm.ClassReader.accept(Unknown Source)
> >
> >        at
> > >
> >
> org.apache.felix.ipojo.manipulator.Pojoization.computeAnnotations(Pojoization.java:294)
> >
> >        at
> > >
> >
> org.apache.felix.ipojo.manipulator.Pojoization.manipulateComponents(Pojoization.java:484)
> >
> >        at
> > >
> >
> org.apache.felix.ipojo.manipulator.Pojoization.manipulateJarFile(Pojoization.java:335)
> >
> >        at
> > >
> >
> org.apache.felix.ipojo.manipulator.Pojoization.pojoization(Pojoization.java:194)
> >
> >        at
> > >
> >
> org.apache.felix.ipojo.plugin.ManipulatorMojo.execute(ManipulatorMojo.java:199)
> >
> >        at
> > >
> >
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
> >
> >        at
> > >
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
> >
> >        at
> > >
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
> >
> >        at
> > >
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
> >
> >        at
> > >
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
> >
> >        at
> > >
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
> >
> >        at
> > >
> >
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
> >
> >        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
> >
> >        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
> >
> >        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
> >
> >        at
> > > org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
> >
> >        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >
> >        at
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >
> >        at
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >
> >        at java.lang.reflect.Method.invoke(Method.java:597)
> >
> >        at
> > > org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
> >
> >        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
> >
> >        at
> > > org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
> >
> >        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> >
> >
> > /Bengt
> >
> >
> > /Bengt
> >
> > 2010/10/1 Clement Escoffier <[email protected]>
> >
> > >
> > > On 01.10.2010, at 18:30, Bengt Rodehav wrote:
> > >
> > > > Clement,
> > > >
> > > > Just a clarification:
> > > >
> > > > When you restart your instance, be sure that the filed is really
> > > re-assigned
> > > >> to false. To be sure, make your instance immediate and set the field
> > in
> > > the
> > > >> constructor.
> > > >
> > > >
> > > > I suspect you misspelled "filed". I'm not sure what you mean here. My
> > > > "mValid" field will be set from a configuration that file install
> picks
> > > up.
> > > > If the configuration value "connect.enabled" is set to true (which is
> > the
> > > > normal case) then I want the service to be started. If it is set to
> > > false,
> > > > then I do not want to start nor publish a service yet.
> > > >
> > > > I want to make sure that I never have a mismatch, that is if
> > > > the "connect.enabled" property is false, then the service can never
> be
> > > > started and vice versa. It is important that services that I have
> > > "disabled"
> > > > this way is never started (which has unfortunately happened...).
> > >
> > > I never tested having the @ServiceController on the same field as a
> > > @Property. This may have some side effects, like not-yet injected
> values.
> > > Try to set your component as immediate. This will force the injection.
> In
> > > fact, if the property has the value false, but there is no object
> > created,
> > > the
> > > @ServiceController has no way to know the current value. If the
> instance
> > is
> > > immediate, an object is created and the field is assigned to the
> property
> > > value.
> > > This will allow the service controller to get the value.
> > >
> > > Clement
> > >
> > > >
> > > > /Bengt
> > > >
> > > >
> > > > 2010/10/1 Clement Escoffier <[email protected]>
> > > >
> > > >>
> > > >> On 01.10.2010, at 17:03, Bengt Rodehav wrote:
> > > >>
> > > >>> OK - obviously @ServiceController is what I need...
> > > >>
> > > >> As said by Richard, The @ServiceController impacts the service
> > lifecycle
> > > >> The @Controller impacts the instance lifecycle. The @Controller is
> > > generally
> > > >> used to detect wrong configuration or really bad state where the
> > > instance
> > > >> decide to become invalid.
> > > >>
> > > >> The @ServiceController is not tied to the instance lifecycle, which
> > > means
> > > >> that despite the instance is valid, the service can be unpublished
> > using
> > > the
> > > >> @ServiceController.
> > > >>
> > > >> When you restart your instance, be sure that the filed is really
> > > >> re-assigned to false. To be sure, make your instance immediate and
> set
> > > the
> > > >> field in the constructor.
> > > >>
> > > >> Regards,
> > > >>
> > > >> Clement
> > > >>
> > > >>>
> > > >>> /Bengt
> > > >>>
> > > >>> 2010/10/1 Richard S. Hall <[email protected]>
> > > >>>
> > > >>>> On 10/1/10 10:41, Bengt Rodehav wrote:
> > > >>>>
> > > >>>>> OK - thanks,
> > > >>>>>
> > > >>>>> BTW, what then is @Controller used for?
> > > >>>>>
> > > >>>>
> > > >>>> It is for disabling the component itself and is generally more to
> > > signal
> > > >>>> error conditions from which the component cannot recover, such as
> > > faulty
> > > >> or
> > > >>>> missing configuration. On the other hand, @ServiceController
> allows
> > > you
> > > >> to
> > > >>>> control when your services are provided.
> > > >>>>
> > > >>>> -> richard
> > > >>>>
> > > >>>>
> > > >>>> /Bengt
> > > >>>>>
> > > >>>>> 2010/10/1 Karl Pauls<[email protected]>
> > > >>>>>
> > > >>>>> iirc, you want the @ServiceController and not the @Controller and
> > > >>>>>> again iirc, you need to update to ipojo 1.6.x for that one.
> > > >>>>>>
> > > >>>>>> regards,
> > > >>>>>>
> > > >>>>>> Karl
> > > >>>>>>
> > > >>>>>> On Fri, Oct 1, 2010 at 4:06 PM, Bengt Rodehav<[email protected]
> >
> > > >> wrote:
> > > >>>>>>
> > > >>>>>>> I'm using iPOJO 1.4.0. My installed iPOJO related artifacts (in
> > > Karaf
> > > >>>>>>>
> > > >>>>>> 1.6.0)
> > > >>>>>>
> > > >>>>>>> are:
> > > >>>>>>>
> > > >>>>>>> org.apache.felix.ipojo-1.4.0.jar
> > > >>>>>>>
> > > >>>>>>> org.apache.felix.ipojo.handler.extender-1.4.0.jar
> > > >>>>>>>
> > > >>>>>>> org.apache.felix.ipojo.online.manipulator-1.4.2.jar
> > > >>>>>>>
> > > >>>>>>> org.apache.felix.ipojo.webconsole-1.4.0.jar
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>> I also use
> > > >>>>>>>
> > > >>>>>>> org.apache.felix.fileinstall-3.0.2.jar
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>> ... and a whole lot of other bundles.
> > > >>>>>>>
> > > >>>>>>> I publish services using factories. An example of a
> configuration
> > > >> file
> > > >>>>>>>
> > > >>>>>> for
> > > >>>>>>
> > > >>>>>>> my factories is:
> > > >>>>>>>
> > > >>>>>>> connect.enabled=true
> > > >>>>>>>
> > > >>>>>>> connect.name=Sample file transfer from file to file
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>> The "connect.enabled" property is bound to the field in my
> > service
> > > >> class
> > > >>>>>>> that is a "controller":
> > > >>>>>>>
> > > >>>>>>> @Controller
> > > >>>>>>>
> > > >>>>>>> @Property(name = "connect.enabled", mandatory = false, value =
> > > >> "true")
> > > >>>>>>>
> > > >>>>>>> private boolean mValid;
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>> The intention is that I can then disable my service by setting
> > this
> > > >>>>>>> configuration property to false. However, I've encounted a
> > problem
> > > >>>>>>>
> > > >>>>>> regarding
> > > >>>>>>
> > > >>>>>>> this. While the service is active, I set "connect.enabled" to
> > > false.
> > > >>>>>>> File
> > > >>>>>>> install picks up the changes and the service is de-registered -
> > > works
> > > >>>>>>> perfectly. But if I now shutdown Karaf and restart it again,
> the
> > > >> service
> > > >>>>>>>
> > > >>>>>> is
> > > >>>>>>
> > > >>>>>>> started (registered) despite the fact that "connect.disabled"
> is
> > > >> still
> > > >>>>>>> false. Is this a bug in iPOJO or have I misunderstood
> something?
> > > >>>>>>>
> > > >>>>>>> When googling about this problem I noticed that there is also
> an
> > > >>>>>>>
> > > >>>>>> annotation
> > > >>>>>>
> > > >>>>>>> called @ServiceController. What is the difference between
> > > @Controller
> > > >>>>>>> and
> > > >>>>>>> @ServiceController?
> > > >>>>>>>
> > > >>>>>>> I tried to switch to @ServiceController instead but get the
> > > following
> > > >>>>>>>
> > > >>>>>> error:
> > > >>>>>>
> > > >>>>>>> 2010-10-01 15:48:03,341 | ERROR | guration Updater |
> configadmin
> > > >>>>>>>
> > > >>>>>>>>        | ?                                   ? |
> > > >>>>>>>> [org.apache.felix.ipojo.Factory,
> > > >>>>>>>>
> > > >>>>>>> org.osgi.service.cm.ManagedServiceFactory,
> > > >>>>>>
> > > >>>>>>> id=174, bundle=84]: Updating configuration property
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>
> > >
> >
> {service.pid=connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795,
> > > >>>>>>
> > > >>>>>>> fromuri=file:data/connect/test/sample/file2file,
> > > >>>>>>>> touris=file:data/connect/test/sample/file2file/test-out,
> > > >>>>>>>> service.factorypid=connect.skandia.filetransfer,
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>
> > >
> >
> felix.fileinstall.filename=connect.skandia.filetransfer-sample-file2file.cfg,
> > > >>>>>>
> > > >>>>>>> connect.enabled=true, instance.name
> > > >>>>>>>>
> > > >>>>>>>
> > =connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795,
> > > >>>>>>
> > > >>>>>>> connect.name=Sample file transfer from file to file} caused a
> > > >> problem:
> > > >>>>>>>> Missing handlers :
> > > >> org.apache.felix.ipojo.annotations:servicecontroller
> > > >>>>>>>>
> > > >>>>>>> org.osgi.service.cm.ConfigurationException:
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>>
> > > >>
> > >
> >
> {service.pid=connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795,
> > > >>>>>>
> > > >>>>>>> fromuri=file:data/connect/test/sample/file2file,
> > > >>>>>>>> touris=file:data/connect/test/sample/file2file/test-out,
> > > >>>>>>>> service.factorypid=connect.skandia.filetransfer,
> > > >>>>>>>>
> > > >>>>>>>>
> > > >>
> > >
> >
> felix.fileinstall.filename=connect.skandia.filetransfer-sample-file2file.cfg,
> > > >>>>>>
> > > >>>>>>> connect.enabled=true, instance.name
> > > >>>>>>>>
> > > >>>>>>>
> > =connect.skandia.filetransfer.269d25ad-c4d6-4277-9d78-6d4b15acb795,
> > > >>>>>>
> > > >>>>>>> connect.name=Sample file transfer from file to file} : Missing
> > > >> handlers
> > > >>>>>>>>
> > > >>>>>>> :
> > > >>>>>>
> > > >>>>>>> org.apache.felix.ipojo.annotations:servicecontroller
> > > >>>>>>>>
> > > >>>>>>> at
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>>
> > > >>
> > >
> >
> org.apache.felix.ipojo.IPojoFactory.updated(IPojoFactory.java:609)[38:org.apache.felix.ipojo:1.4.0]
> > > >>>>>>
> > > >>>>>>> at
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>>
> > > >>
> > >
> >
> org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceFactoryUpdate.run(ConfigurationManager.java:1279)[6:org.apache.felix.configadmin:1.2.4]
> > > >>>>>>
> > > >>>>>>> at
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>>
> > > >>
> > >
> >
> org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)[6:org.apache.felix.configadmin:1.2.4]
> > > >>>>>>
> > > >>>>>>>
> > > >>>>>>> I'm not sure in which jar the
> > > >>>>>>> " org.apache.felix.ipojo.annotations:servicecontroller"
> resides.
> > I
> > > >> tried
> > > >>>>>>>
> > > >>>>>> to
> > > >>>>>>
> > > >>>>>>> deploy "org.apache.felix.ipojo.handler.whiteboard-1.4.0.jar"
> but
> > it
> > > >>>>>>>
> > > >>>>>> didn't
> > > >>>>>>
> > > >>>>>>> seem to help.
> > > >>>>>>>
> > > >>>>>>> Can anyone help me sort this out?
> > > >>>>>>>
> > > >>>>>>> /Bengt
> > > >>>>>>>
> > > >>>>>>>
> > > >>>>>>
> > > >>>>>> --
> > > >>>>>> Karl Pauls
> > > >>>>>> [email protected]
> > > >>>>>>
> > > >>>>>>
> > > ---------------------------------------------------------------------
> > > >>>>>> To unsubscribe, e-mail: [email protected]
> > > >>>>>> For additional commands, e-mail: [email protected]
> > > >>>>>>
> > > >>>>>>
> > > >>>>>>
> > > >>>>
> > ---------------------------------------------------------------------
> > > >>>> To unsubscribe, e-mail: [email protected]
> > > >>>> For additional commands, e-mail: [email protected]
> > > >>>>
> > > >>>>
> > > >>
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: [email protected]
> > > >> For additional commands, e-mail: [email protected]
> > > >>
> > > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> > >
> >
>

Reply via email to