When we update any configuration for a component in the Configurations tab in the Apache Felix Web OSGi Console, where are these configuration settings saved? This is with respect to AEM 6.0 or above.
The manually saved configuration settings are stored in the the crx-quickstart/launchpad/config directory (in your AEM installation folder in the local file system) and, on top of that, as .config files in the Content Respository at /apps/system/config.
For example, if you're looking for the configuration of com.example.MyComponent, you can find it as a text file in crx-quickstart/launchpad/config/com/example/MyComponent.config (in the local file system) and at /apps/system/config/com.example.MyComponent.config inside your Content Repository.
The files at these two locations are updated when you change the settings manually in the OSGi console.
In AEM you can also store configuration in JCR nodes of the type sling:OsgiConfig. These will not be created or updated when you manually save the config but they offer a neat way of managing configuration as content.
When AEM looks for the configuration, the following order of resolution is used:
nodes under /apps/*/config, be it property files or JCR nodes with the node jcr:primaryType of sling:OsgiConfig
nodes with type sling:OsgiConfig under /libs/*/config, these are OOTB definitions for components that come with AEM
.config files from <aem-installation-directory>/crx-quickstart/launchpad/config/ on the local file system.
Depending on the OSGi configuration of Apache Sling JCR Installer, the sling:OsgiConfig nodes can be written back to when you manually change the config. There's also a number of settings affecting the lookup of said configurations so it's a good idea to familiarise oneself with this config.
Please check out the official documentation for more comprehensive information.
If you're trying to get a config stored in a sling:OsgiConfig node to work as expected and you're unsure if another config for the same service has been cached somewhere, here's a sequence of steps that has worked for me consistently in AEM 6.4:
Delete the sling:OsgiConfig node you just created
Go to the Felix console's configMgr, find the relevant service and Delete the configuration.
Recreate the sling:OsgiConfig node (I usually keep those in a CRX package that I can simply reinstall)
The configurations are stored by the felix configadmin bundle inside the felix bundle cache. Not sure where this cache is located in AEM. In Apache Karaf the configs in my case are in:
data/cache/bundle7/date/config
Where bundle id 7 is the id of the configadmin bundle.
Related
We have a config folder structure in apps like this:
config
config.author.test
config.author.stage
These have config.runmode.env values
I wanted to know from where It picks the "env" value.
I thought it is coming from runmodes. but in the instances, stage or test is nowhere.
Can anyone please help me know where does the AEM configs picks the value or where do we define those env value. Is it in some OSGi configuration or from where.
If you are not using the AEM runtime for the AEM Cloud SDK, then the run modes can be set in other ways as well apart from the sling.properties file. So depending on how you are starting your AEM server check if the run modes have been specified using the other options.
If you are using the AEM runtime from the cloud SDK, then check if the Jar file is named as shown in the Quickstart jar startup modes.
I am trying to do a log4j migration for a legacy application. I made the changes to the configuration files and tested it locally with Tomcat, where the logs were displayed correctly. However when I deploy on WAS, the logging stops.
I checked a lot of pages about the necessary dependencies and the possible problems, but now I feel I'm stuck. Here is what I already tried:
Added the log4j jars manually to the lib/ext directory in WAS (together with commons-logging, I read an article where it helped, although all these jar-s were already present in the ear)
Double checked, that the configuration file is on the classpath and that it's syntax is correct
Added logj42-web dependency
Added the necessary filters in web.xml (Spring version is 3.8, so also the config listener with the config name context-param)
Checked classloader in WAS - it's parent first
Am I missing something?
Any ideas are appreciated. Thank you in advance!
WAS includes its own commons-logging API (that does not utilize Log4j), so bringing your own logger requires a bit of extra class-loader-related config. Typically, that would go something like this:
Put your commons-logging and log4j jars, along with your logging properties files, in some directory (not WAS_HOME/lib/ext) readable by the user running the server.
Create a shared library on the server, with that directory as its class path, and select the "use an isolated class loader" option. Associate that shared library with your application or web module.
Ideally, that should be it. Isolated shared libraries search themselves before delegating to the server's loaders, so your application will "see" the commons-logging/log4j classes in the shared library instead of in the server, and likewise, it should pick up the configuration files from that directory instead of the ones found in the server.
You can also accomplish this same basic thing by leaving all the logging stuff in your WAR or EAR and setting its class loader to parent-last (which causes the class loader to search locally before delegating to the server-level loaders), but that is a bit riskier configuration - if your application includes APIs that are also provided by the server, parent-last class loading increases the possibility of ClassCastExceptions or LinkageErrors.
Am trying to make the sling:OsgiConfig nodes as per this link for Apache Sling Service User Mapper and Apache Sling Service User Mapper Service Amendment Felix configuration, But those are not reflecting into Felix console, is there anything am missing for these nodes.?
Note : below node changes are reflecting for the as per the link.
org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler.config
Nodes which are not reflecting into Felix configuration.
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended.config
The thing you need to do is give the multibound config item a specific unique name.
e.g.
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-custom
mind the "custom" part.. this one has to be a unique string.
you'd see that happening if you only added your custom ammended config entry through the /system/console/configMgr
in Sling, configuration can be deployed either via a sling:osgiConfig node and via a nt:file node having the configuration values.
When i make some changes in Felix Console in some configuration deployed via sling:osgiConfig node, it gets converted to nt:file format.
Why there are these two different formats for configurations in Sling. is there any significant difference between the two?
I'd say this is mostly for historical reasons, in some cases it's more convenient to provide configurations as hierarchical resources (sling:OsgiConfig) and if the config is coming from a filesystem for example, files are more convenient.
#Shashi sling:osgiConfig changing to nt:file when you make changes in felix console is expected behaviour. This will not cause any issue when you try to read the config value from java class. You will just not be able to edit the run mode config via crxde when it has changed to nt:file as it stores data as binary content.
However there is a way to disable this behaviour, you will have to uncheck "Enable Write Back" at /system/console/configMgr/org.apache.sling.installer.provider.jcr.impl.JcrInstaller as mentioned in this thread.
OSGi config best practices
I try to use the "Apache Felix" implementation of OSGi for my project, I launch the framework from the distributable jar (/bin /felix.jar). I have created simple example bundles to register or consume services in the registry.
I want to use a configuration management service so I installed the bundle "org.apache.felix.configadmin" felix in the framework, and then I do not know how and where to put the configuration file of another bundle, for example I want to install the bundle "org.apache.felix.http.jetty" and then I want to configure this bundle through the configAdmin, so how I rename my config file, and where to put it?
Another question, what is the difference between setting, for example, the property "org.osgi.service.http.port" of the jetty bundle using the framework properties(conf/config.properties) or configure it through the bundle of configuration admin service.
Best regards,
You probably also need the file-installer from felix for it to pick up the config files.
If you want to see a working example of this take a look at Apache Karaf. It's a OSGi Container with lots of nice preconfigured features. The config admin service works out of the box.
Normally you use the felix config admin service together with the felix fileinstall. So fileinstall takes care of the directory to be monitored for config files and hands over to config admin to make it available as configs in OSGi.
For a fully working example take a look at Apache Karaf. There you can see the configs you need for it to work together. You might also consider to simply install your own bundles into karaf as it makes managing the felix framework a lot easier.