Service config property values reverting to defaults

Avatar

Avatar
Ignite 1
Employee
sean_gubler
Employee

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
View profile

Avatar
Ignite 1
Employee
sean_gubler
Employee

Likes

0 likes

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Ignite 1
View profile
sean_gubler
Employee

08-05-2019

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?

Replies

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

09-05-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.htm...

@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.

Avatar

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile
sagarneelbiswas
Level 1

28-05-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);

    }

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

28-05-2019

I would recommend for 6.3, you should use osgi r6 annotations instead of felix scr annotations.

Avatar

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile
sagarneelbiswas
Level 1

28-05-2019

I found this, somewhat related to my problem,

AEM 6.3 Configuration bound to wrong bundle launchpad:resources/install/0/org.apache.sling.scriptin...

OSGI R6 annotation - can I get sample code (s)/ good documentation somewhere?

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,318 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

28-05-2019

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,134 likes

Total Posts

3,161 posts

Correct reply

1,079 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

28-05-2019

Switching the way how the metatype XML files are created do not make the problem go away. These annotations are build-time annotations and not evaluated during runtime.

The default value is a metatype default value, and the fact that it is getting picked up shows that this configuration is not found. An incorrect binding of the config (as you already found) can indeed be the problem.

Avatar

Avatar
Level 1
sushantrao
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
sushantrao
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
sushantrao
Level 1

11-06-2019

OSGI R6 implementation did not help. the problem persists, the exact problem.

Avatar

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile
sagarneelbiswas
Level 1

11-06-2019

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

Avatar

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile

Avatar
Give Back 5
Level 1
sagarneelbiswas
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
View profile
sagarneelbiswas
Level 1

11-06-2019

Thanks for your response, could you please suggest me something more, how can I fix the issue, progress further.