Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Configuration binding to launchpad:resources/install/0/org.apache.sling.scripting.core-2.0.44.jar

chinnainturi
Level 2
Level 2

Hi All,

We are using AEM 6.3 and created a custom configurable workflow process. Whenever process step loads,On Configuration manager tab, bundle column has launchpad:resources/install/0/org.apache.sling.scripting.core-2.0.44.jar and its stops working. We need to delete the binding and restart the bundle to proceed furthur. This is happening everytime it loads the custom process step.

Any idea on this issue?

1 Accepted Solution
chinnainturi
Correct answer by
Level 2
Level 2

Sorry for misleading. Actually in workflow process we have a Dialog participant step which populate data from Configuration. We have used Datasource to read configuration values, while reading configuration service configuration binding is automatically updated as  launchpad:resources/install/0/org.apache.sling.scripting.core-2.0.44.jar and hence Service stopped working.

import com.adobe.cq.sightly.WCMUsePojo;

import com.adobe.granite.ui.components.ds.DataSource;

import com.adobe.granite.ui.components.ds.EmptyDataSource;

import org.apache.commons.lang.StringUtils;

import org.apache.sling.api.resource.Resource;

import org.apache.sling.api.resource.ResourceResolver;

import org.apache.sling.commons.osgi.PropertiesUtil;

import org.osgi.service.cm.Configuration;

import org.osgi.service.cm.ConfigurationAdmin;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import java.util.ArrayList;

import java.util.Dictionary;

import java.util.List;

public class SampleValuesModel  extends WCMUsePojo{

   private static Logger log = LoggerFactory.getLogger(SampleValuesModel.class);

   private final static String VAR_PID = "pid";

   private final static String VAR_PROPERTY_1 = "prop_1";

   private ConfigurationAdmin configAdmin;

   private List<String> folderValues = new ArrayList<String>();

   @Override
   public void activate() throws Exception {

   final ResourceResolver resolver = getResource().getResourceResolver();

   //Use getSlingScriptHelper().getService() to get an instance of the ConfigurationAdmin
   configAdmin = getSlingScriptHelper().getService(ConfigurationAdmin.class);

   // config path passed as datasource parameter
   String configPath = get(VAR_PID, String.class);

   // property which we need to read from config service
   String propertyName = get(VAR_PROPERTY_1, String.class);

   log.info("--------PID Value DPM --------"+configPath);

   log.info("----------Property Value DPM-------"+propertyName);

  Configuration conf = configAdmin.getConfiguration(configPath);

  //BELOW CODE FIXED MY ISSUE

   if (null != conf) {

  conf.setBundleLocation(null);

  }

View solution in original post

10 Replies
smacdonald2008
Level 10
Level 10

What APIs are  you using to build the process.

chinnainturi
Level 2
Level 2

PF below to create the process

import com.adobe.granite.workflow.WorkflowException;

import com.adobe.granite.workflow.WorkflowSession;

import com.adobe.granite.workflow.exec.WorkItem;

import com.adobe.granite.workflow.exec.WorkflowData;

import com.adobe.granite.workflow.exec.WorkflowProcess;

import com.adobe.granite.workflow.metadata.MetaDataMap;

import com.adobe.granite.workflow.model.WorkflowModel;

import com.day.cq.wcm.api.*;

import org.apache.commons.lang3.StringUtils;

import org.apache.felix.scr.annotations.*;

import org.apache.felix.scr.annotations.Properties;

import org.apache.sling.api.resource.ResourceResolver;

import org.apache.sling.api.resource.ValueMap;

import org.apache.sling.commons.osgi.PropertiesUtil;

import org.osgi.framework.Constants;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import javax.jcr.Session;

import java.util.*;

@Component(immediate = true,

        label = "Sample Service",

        metatype = true)

@Properties({

        @Property(label = "Sample Process",name = "process.label",value = "Sample Workflow Process",propertyPrivate = true),

        @Property(name = Constants.SERVICE_DESCRIPTION,

                value = "Sample implementation.",

                propertyPrivate = true

        )

})

@Service

public class SampleProcess implements WorkflowProcess {

    @Property(unbounded= PropertyUnbounded.ARRAY,label = "Mapping")

    private static final String SAMPLE_MAPPING_VALUES = "sample.page.mapping";

    @Property(unbounded= PropertyUnbounded.DEFAULT, label = "Page Naming Format")

    private static final String NAMING_FORMAT = "naming.format";

    private static final Logger log = LoggerFactory.getLogger(SampleProcess.class);

    private ResourceResolver resolverGlobal = null;

    private Map<String, String> properties = Collections.emptyMap();

    private String[] sampleMappingValues;

    private String namingFormat;

    public String[] getSampleValue()

    {

        return this.sampleMappingValues;

    }

    public String getNamingFormat()

    {

        return this.namingFormat;

    }

smacdonald2008
Level 10
Level 10

Kunwar​ has this issue been seen before? I have never heard of this.

chinnainturi
Level 2
Level 2

I see a similar issue was posted earlier but its not related to Workflow process.

Re: AEM 6.3 Scr annotation issue while upgrade (Scroll to last comments)

Jörg_Hoh
Employee
Employee

Your workflow step does not have any dependency to the Sling Scripting Core bundle, so it shouldn't be related. Of course other components in your bundle might have these dependency, so it still can.

What does "it stops working" mean? Is your bundle active? Is your workflow step service running? Where exactly can you see this dependency to "launchpad:resources/install/0/org.apache.sling.scripting.core-2.0.44.jar"?

Can you provide some more information about the problem and steps you do to resolve it?

Jörg

chinnainturi
Correct answer by
Level 2
Level 2

Sorry for misleading. Actually in workflow process we have a Dialog participant step which populate data from Configuration. We have used Datasource to read configuration values, while reading configuration service configuration binding is automatically updated as  launchpad:resources/install/0/org.apache.sling.scripting.core-2.0.44.jar and hence Service stopped working.

import com.adobe.cq.sightly.WCMUsePojo;

import com.adobe.granite.ui.components.ds.DataSource;

import com.adobe.granite.ui.components.ds.EmptyDataSource;

import org.apache.commons.lang.StringUtils;

import org.apache.sling.api.resource.Resource;

import org.apache.sling.api.resource.ResourceResolver;

import org.apache.sling.commons.osgi.PropertiesUtil;

import org.osgi.service.cm.Configuration;

import org.osgi.service.cm.ConfigurationAdmin;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import java.util.ArrayList;

import java.util.Dictionary;

import java.util.List;

public class SampleValuesModel  extends WCMUsePojo{

   private static Logger log = LoggerFactory.getLogger(SampleValuesModel.class);

   private final static String VAR_PID = "pid";

   private final static String VAR_PROPERTY_1 = "prop_1";

   private ConfigurationAdmin configAdmin;

   private List<String> folderValues = new ArrayList<String>();

   @Override
   public void activate() throws Exception {

   final ResourceResolver resolver = getResource().getResourceResolver();

   //Use getSlingScriptHelper().getService() to get an instance of the ConfigurationAdmin
   configAdmin = getSlingScriptHelper().getService(ConfigurationAdmin.class);

   // config path passed as datasource parameter
   String configPath = get(VAR_PID, String.class);

   // property which we need to read from config service
   String propertyName = get(VAR_PROPERTY_1, String.class);

   log.info("--------PID Value DPM --------"+configPath);

   log.info("----------Property Value DPM-------"+propertyName);

  Configuration conf = configAdmin.getConfiguration(configPath);

  //BELOW CODE FIXED MY ISSUE

   if (null != conf) {

  conf.setBundleLocation(null);

  }

Jörg_Hoh
Employee
Employee

Hi,

thanks for the explanation, I understand now more of your problem.

The code you use doesn't really make sense to me. First of all, the use of the ConfigAdmin is not encouraged, you should use the OSGI anotations to read the properties. If you refactor your WcmUsePojo into a SlingModel, you can do that easily without on relying on the ConfigAdmin service. Rebinding the service is a really ugly workaround.

Having said that I wonder that it doesn't work. Feels like an issue, because it should work ...

I would first refactor it into a Sling Model and then check if that error is persisting.

Jörg

chinnainturi
Level 2
Level 2

Hi,

We are using sling models only for components and I tried to do this also using Sling Model, But since its just a dialog within dialog participant step postContruct method is never called and i couldnt populate the datasource. Can you please point me to some references.

VarunV
Employee
Employee

The API call [1] you mentioned is not recommended to be used for the use case you are after.

The call [1] gets bound to the bundle performing the call (the scripting bundle in this case).

So, you have two options

  1. Use getConfiguration(configName, null) - this way you're only getting the configuration without binding it. However, this call will create the configuration if it doesn't exist, which is not what you want (I assume !).
  2. Therefore, use ConfigurationAdmin.listConfiguations instead for a cleaner way to access configuration.

In general, read the configuration admin spec, especially

https://osgi.org/specification/osgi.cmpn/7.0.0/service.cm.html#service.cm-location.binding

[1] Configuration conf = configAdmin.getConfiguration(configPath);