I think the chain of events is slightly different than what Jason
wrote, but the end result is the same.

Properties from configuration annotations are only included in the XML
if the configuration annotation is used in the signature of the
activate/deactivate methods (maybe modified as well, possibly others).

Now, in this case, the activate method was not recognized and thus the
config annotation was not referenced from any of the lifecycle method
signature. Ergo: no properties in the XML.

Regards
Julian


PS: I wrote a small commandline tool that helps diffing bundles before
and after the annotation refactoring (or any other changes done to
DS/MetaType). It's far from perfect, but already helped me avoid some
bugs. PRs welcome of course!
https://github.com/jsedding/osgi-ds-metatype-diff


On Fri, May 18, 2018 at 4:56 AM, Daniel Klco <dk...@apache.org> wrote:
> That was the problem, thanks Jason! 10 internet points and a meme to you
> for being awesome!
>
> https://imgflip.com/i/2aicpi
>
> Thanks,
> Dan
>
> On Thu, May 17, 2018 at 5:40 PM, Jason E Bailey <j...@apache.org> wrote:
>
>> So this is odd, I built the project and checked out the
>> FormAuthenticationHandler.xml that was built in the OSGI-INF directory and
>> it only defined a deactivate method.
>>
>> I added the @Activate annotation and it added the definition that stated
>> the activate method was 'activate'  and it also added all the property
>> defaults.
>>
>> I'm suspecting that the plugin is looking for the activate declaration and
>> if it isn't there it's not defining the properties, even through the OSGi
>> container is properly identifying the activate method.
>>
>> - Jason
>>
>> On Thu, May 17, 2018, at 4:18 PM, Daniel Klco wrote:
>> > Good thought, unfortunately the same result.
>> >
>> > On Thu, May 17, 2018 at 12:40 PM, Jason E Bailey <j...@apache.org> wrote:
>> >
>> > > Your using constants in the default value, have you tried replacing
>> those
>> > > with literals? I believe, as a compile time annotation, the constants
>> > > aren't initialized.
>> > >
>> > > - Jason
>> > >
>> > > On Thu, May 17, 2018, at 1:43 PM, Daniel Klco wrote:
>> > > > Team,
>> > > >
>> > > > I've been trying to figure this out and can't seem to crack it so I
>> was
>> > > > hoping someone might have some insight.
>> > > >
>> > > > I'm trying to update Sling Auth Forms to OSGi R6 as per:
>> > > > https://issues.apache.org/jira/browse/SLING-7671
>> > > >
>> > > > I've got everything converted over and it works if I specify a
>> > > > configuration. However, with the Apache Felix SCR annotations this
>> > > service
>> > > > registered immediately with a configuration with the default values,
>> so
>> > > > there's clearly some difference I'm missing. I've tried changing
>> > > everything
>> > > > I can think of to get the default values from the configuration to be
>> > > > registered when the component is starts, but every time I get
>> something
>> > > > like this:
>> > > >
>> > > > 17.05.2018 10:22:47.084 *INFO* [Background Update
>> > > > org.apache.sling.auth.form (84)] org.apache.sling.auth.form Service
>> > > > [org.apache.sling.auth.form.FormAuthenticationHandler,1169,
>> > > > [org.apache.sling.auth.core.spi.AuthenticationHandler]] ServiceEvent
>> > > > REGISTERED
>> > > > 17.05.2018 10:22:47.085 *DEBUG* [Background Update
>> > > > org.apache.sling.auth.form (84)]
>> > > > org.apache.sling.auth.form.impl.FormAuthenticationHandler Activating
>> > > with
>> > > > configuration
>> > > > org.apache.sling.auth.form.impl.FormAuthenticationHandlerConfig :
>> > > > {jaas_realmName=null, form_onexpire_login=false, jaas_ranking=0,
>> > > > jaas_controlFlag=null, form_auth_storage=null, useInclude=false,
>> > > > annotationType=null, form_credentials_name=null,
>> form_token_file=null,
>> > > > service_ranking=0, path=[Ljava.lang.String;@5b1b6745,
>> > > form_login_form=null,
>> > > > form_token_fastseed=false, hashCode=0, equals=false, toString=null,
>> > > > form_auth_name=null, form_auth_timeout=0,
>> form_default_cookie_domain=nul
>> > > l}
>> > > > and properties {}
>> > > > 17.05.2018 10:22:47.085 *ERROR* [Background Update
>> > > > org.apache.sling.auth.form (84)] org.apache.sling.auth.form bundle
>> > > > org.apache.sling.auth.form:1.0.9.SNAPSHOT
>> > > > (84)[org.apache.sling.auth.form.FormAuthenticationHandler(316)] :
>> The
>> > > > activate method has thrown an exception (java.lang.
>> NullPointerException)
>> > > >
>> > > > It seems like this should work based on other examples I've seen
>> online,
>> > > > specifically:
>> > > >
>> > > > https://github.com/nateyolles/aem-osgi-annotation-demo
>> > > >
>> > > > So far I have tried:
>> > > >
>> > > >    - Specifying the configuration pid
>> > > >    - Trying annotation defaultvalue vs method default
>> > > >    - Changing the start level of the bundle
>> > > >    - Changing to a single activate parameter
>> > > >    - Trying required / optional configuration binding
>> > > >
>> > > > The only thing that did work was specifying a configuration node in
>> the
>> > > > bundle content configuration, but this seems hacky.
>> > > >
>> > > > I've checked the code in to Auth Form:
>> > > > https://github.com/apache/sling-org-apache-sling-auth-form
>> > > >
>> > > > If anyone could take a few minutes to review or has any thoughts /
>> ideas
>> > > /
>> > > > suggestions I'd really appreciate it as I'm at a roadblock.
>> > > >
>> > > > Thanks,
>> > > > Dan
>> > >
>>

Reply via email to