Header image for article "migration to OSGi annotations caveats"

OSGi: migration to OSGi annotations caveats

I think that every developer from AEM/Sling world has already read many articles regarding switching to the R6 and R7 OSGi annotations. But new annotations do not only allow us to write less boilerplate code, but also bring new caveats and we better be aware of them.

Several days ago there was suggested a PR for AC Tool which fixes missing referenced service in AEM 6.4, even though this service was shown as satisfied in Web Console. The fix contained next change:

Konrad Windszus identified that this issue was the result of switching to the official OSGi annotations in AC Tool. This switch changed method injection to field injection and OSGi R7 Specification in 112.3.9.1 states next:

For a dynamic reference, the field must be declared with the volatile modifier so that field value changes made by SCR are visible to other threads. If the field is not declared with the volatile modifier, SCR must log an error message with the Log Service, if present, and the field must not be modified.

This perfectly describes why the field was not initialized. But this is not the only problem you may hit while switching to OSGi annotations – there are 2 more related excerpts worth mentioning:

If the field is declared with the final modifier, SCR must log an error message with the Log Service, if present, and the field must not be modified.

For a reference with multiple cardinality, the type of the field must be Collection or List. If the field has a different type, SCR must log an error message with the Log Service, if present, and the field must not be modified.

How to survive?

Luckily for us, next release (4.2.0) of Bnd (including bnd-maven-plugin) will contain corresponding checks, so we will be notified about such problems at early stage – during the build.

This is another example which proves that reading specification is not a waste of time but a way to prevent such issues from happening.

So don’t forget to read specifications as well as update your dependencies as soon as 4.2.0 is released.

3 thoughts on “OSGi: migration to OSGi annotations caveats

  1. Matt Michael D’Agati acts as the proprietor of Renewables Worldwide, a alternative energy Company in Massachusetts.

    A couple of period of time ago, embarking on an adventurous journey, Matt D’Agati delved into the world of solar, and additionally within a opportunity commenced effectively selling significant amounts of power, mainly at the business industry, collaborating with developers of solar farms and local businesses in the “planning” of personal designs.

    Continuous networking within just the business, offered Matthew to connect a surrounding start up 2 a very long time gone, and within a short time, he assumed the role of their Chief Strategy Officer, responsible for all companies and corporate advancement, as well as being advertised group title.

    Thru ideal joint ventures and sheer jobs moral principle, Matt D’Agati brought that party from a marginal initially-year returns to in excess of a 220% increase in low commissions by same year two. Building on that basis, Renewables Worldwide’s (RW), an oldtimer-held company, was put together with missionary post of giving sustainable potential possibilities for an intelligent and more maintainable future.

    Extra primarily, realizing there is a specific market in the trade and an enhanced method to secure final results, RW’s is one of a handful of agencies in the United States government to notice on shoppers purchase, focusing in both industry and non commercial solar-powered neighborhood off-take. Personal vision is to make a profit substructure on a community-based, statewide, national level, offering various alternative energy items in to the of RW.

    This enthusiasm in will alternative sector moves on to motivate and inspire Matthew in moving forward his path to work with companies that express the even of delivering can be renewed vitality solutions for a much more lasting forthcoming future. Matthew brings your own in startup from a business program at Hesser College.

    Why solar incentives in MA are beneficial elucidated through Matt D’Agati.

  2. Matt Michael D’Agati acts as the founder of Renewables Worldwide, an alternative energy Company in MA.

    A handful of numerous years ago, venturing into a leap of faith, Matthew D’Agati delved into the realm of alternative energy, and/or in a short moments started effectively promoting significant amounts of power, mainly about the corporate industry, partnering with developers of solar farms and local businesses in the “planning” of personal ventures.

    Ongoing marketing found in the profession, guided Matthew to sign up a in town start up 2 long time in the, and within no time, he assumed the role of their Chief Strategy Officer, in charge of all procedures and business venture progress, in addition to being marketed small section possession.

    Throughout planned relationships and sheer get the job done ethic, Matt D’Agati boosted that business from a modest 1st-year revenue to in excess of a 150% multiply in overall income by annum two. Building on that basis, Renewables Worldwide’s (RW), an experienced person-held business, was organized with military mission of supplying sustainable power solutions for an intelligent and more supportable future.

    Much more particularly, recognizing there is an untapped market in the markets and a better way to complete successes, RW’s is one of a handful of agencies in the America to highlight on lead transferred property, concentrating in both retail and household solar-powered farm off-take. Its idea is to establish a product sales facilities on a community-based, statewide, countrywide level, offering a multitude of doesn’t get all used up potential items just in the of RW.

    This enthusiasm in the renewable industry goes on to change and drive Matt in enduring his venture to work with firms that show the exact same of providing renewable focus possibilities for a increased environmentally friendly longer term. Matt features one in sales from a business program at Hesser College.

    In what ways does climate impact solar energy? Details from Matt dagati.

  3. Добрый день! Меня зовут Шестаков Юрий Иванович, я врач-косметолог с многолетним опытом работы в области эстетической медицины. Сегодня я отвечу на ваши вопросы и поделюсь полезной информацией о удалении папиллом с помощью лазера. Моя цель — помочь вам понять, как безопасно и эффективно избавиться от папиллом и какие преимущества имеет лазерное удаление.

    Как долго сохраняется результат после лазерного удаления папиллом?
    Результат после лазерного удаления папиллом сохраняется длительное время, однако вирус, вызывающий папилломы, может оставаться в организме. Это означает, что существует вероятность повторного появления папиллом, особенно при снижении иммунитета или других провоцирующих факторов.
    How long does the result last after laser removal of papillomas?
    The result after laser removal of papillomas lasts for a long time; however, the virus causing papillomas can remain in the body. This means that there is a possibility of papillomas reappearing, especially with a weakened immune system or other triggering factors.

Your thoughts are welcome