Service config property values reverting to defaults | Community
Skip to main content
Adobe Employee
May 8, 2019

Service config property values reverting to defaults

  • May 8, 2019
  • 3 replies
  • 6472 views

The following issue was raised by an Adobe partner...

We are facing an strange problem post AEM upgrade to 6.3.

We have OSGI service configurations, that has a default value in the code (usual implementation). The service config property values are of course modified in the environment from OSGI console (http://<HOST>:4503/system/console/config). This was working in AEM 6.1. After the upgrade to AEM 6.3, we have noticed sometime in some of the environments, the modified values are not getting picked up and instead the default value from the code is getting picked up. While investigating, I don’t see anything unusual. Like the modified configurations are present under /apps/system/config. Also, I have noticed, if I rename the file.config (just an example) to file1.config and then rename back to file.config, the modified configurations are getting picked up.

Could you please help us on this problem to fix it permanently?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

arunpatidar
Community Advisor
Community Advisor
May 9, 2019

HI,

Can you let us know how you are setting default property in java code.

There are 2 ways to do it, using defaultValue attribute or using default marker.

https://osgi.org/javadoc/r6/enterprise/org/osgi/service/metatype/annotations/AttributeDefinition.html#defaultValue()

@AttributeDefinition(name = "user.name", description = "User Name")

String getUserName() default "AEM";

@AttributeDefinition(name = "user.name", description = "User Name", defaultValue="AEM")

String getUserName();

I am not sure if this is gonna help or not.

Arun Patidar
May 28, 2019

It is done in the recommended way and was working fine, with AEM 6.1 for ages. The issues we started noticing right after the in-place AEM upgrade to AEM 6.3,

Code snippets,

@Component(immediate = true, label = "ABC Service Config", description = "ABC Service Config", metatype = true)

@Properties({

        @Property(name = Constants.SERVICE_DESCRIPTION, value = "ABCServiceConfig"),

        @Property(name = Constants.SERVICE_VENDOR, value = "ABC") })

@Service(value = ABCServiceConfig.class)

public class ABCServiceConfig {

    @Property(label = "Display TripPlan Servlet", value = "DisplayTripPlanServlet", description = "Servlet for Display Trip Plan")

    public static final String DISPLAY_TRIP_PLAN_SERVLET = "displayTripPlanServlet";

     .

     .

     .

     .

protected void activate(ComponentContext context) {

        this.context = context;

        siteConfigConstants = getAllPropertiesAsJSON();

    }


    /**

     * This method is used to get configuration value configured for respective

     * key on System console.

     *

     * @param key

     * - Property key

     * @return value

     */

    public static String getPropertyValue(String key) {

        return (String) context.getProperties().get(key);

    }


    /**

     *

     * @return

     */


    /**

     * This method is used to get configuration values configured for respective

     * key on System console.

     *

     * @param key

     * - Property key

     * @return values

     */

    public static String[] getPropertyValues(String key) {

        return (String[]) context.getProperties().get(key);

    }

June 11, 2019

Hi,

Please find docs for Felix SCR to OSGI annotations migration

AEM Developer Learning : Migration of SCR annotations to OSGi R6 annotations in AEM 6.3

https://www.argildx.com/migration-of-scr-annotations-to-ds-annotations/


R6 implementation did not help. the exact problem is still there

June 12, 2019

updating the version worked of the dependency worked for me,

this is what I have in core pom

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.core</artifactId>

<version>6.0.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.cmpn</artifactId>

<version>6.0.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.annotation</artifactId>

<version>6.0.1</version>

<scope>provided</scope>

</dependency>

<dependency>

                <groupId>org.osgi</groupId>

                <artifactId>osgi.core</artifactId>

                <version>6.0.0</version>

                <scope>provided</scope>

            </dependency>

            <dependency>

                <groupId>org.osgi</groupId>

                <artifactId>osgi.cmpn</artifactId>

                <version>6.0.0</version>

                <scope>provided</scope>

            </dependency>

            <dependency>

                <groupId>org.osgi</groupId>

                <artifactId>osgi.annotation</artifactId>

                <version>6.0.1</version>

                <scope>provided</scope>

            </dependency>

Ankur_Khare
Community Advisor
Community Advisor
October 30, 2019

Did you changed all the scr annotations to OSGI and that worked?

August 20, 2021

Hey @seangubler ,
Did you get any fix for this?
I am working with 6.5.8 and see similar issue, the code worked fine with 6.4.8 but as we upgraded we are observing this issue where configuration value fallback to default value intermittently.