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

Setting OSGi config for LinkInfoStorageImpl via source package does not work

Avatar

Level 3

Hi folks

I am currently trying to set the OSGi configuration for com.day.cq.rewriter.linkchecker.impl.LinkInfoStorageImpl via a source content package (/apps/.../config/...) in AEM6. My XML looks like this:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="sling:OsgiConfig" service.max_links_per_host="{Long}500" service.save_external_link_references="{Boolean}false" />

As soon as I deploy such a content package with the above content the publish instance does not work anymore and I can see a lot of error messages like the following:

11.06.2015 14:21:52.170 *ERROR* [pool-5-thread-5] com.day.cq.cq-rewriter [com.day.cq.rewriter.linkchecker.impl.LinkInfoStorageImpl(1170)] The activate method has thrown an exception (java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer) java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer

Next I checked /crx-quickstart/launchpad/config/com/day/cq/rewriter/linkchecker/impl/LinkInfoStorageImpl.config and observed the following:

When setting the max links setting via web console the following gets written to the file.

service.save_external_link_references=B"false" service.pid="com.day.cq.rewriter.linkchecker.impl.LinkInfoStorageImpl" service.max_links_per_host=I"500"

When setting the max links value via a source package with the above XML snippet the following gets written to the file.

service.pid="com.day.cq.rewriter.linkchecker.impl.LinkInfoStorageImpl" service.save_external_link_references=B"false" service.max_links_per_host=L"500"

So apparently the configuration of the max links setting must be an integer value. However I don't know how to set an integer value via XML configuration. Am I missing something here? I thought that {Long} is the only possibility to define a number value. I also tried {Integer} just to be sure but that did not work either (in fact it prevents the config file from getting created). Did anybody else have this kind of problem and has a solution for it? I thought I ask here first before opening a daycare ticket. Any help is appreciated.

Cheers

1 Reply

Avatar

Level 1

Running into the same issue with Adobe Granite Workflow Service! (com.adobe.granite.workflow.core.WorkflowSessionFactory)

Either "cq.workflow.job.retry" or "granite.workflow.inboxQuerySize" require to be set as integers but any attempt to use {Long} would end up with the same error described above

java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer

In my case and on AEM 6.1 , it will actually completely break the touch UI by throwing a 500 response in the JS console...

Is there a way to make attributes of sling:OsgiConfig node via XML use Integer like {Long} or {Boolean} are used?

Thanks!

Avatar

Level 1

Just sharing my findings here.

This happens only if the @property SRC annotation uses "intValue".

It may simply be not supported at the Sling level with the Jcr Installer not supporting all types (https://issues.apache.org/jira/browse/SLING-2477) ?

There are several options I could think of that I will explore:

1) left out the integer values from the xml config file and let the default be use for these. Luckily, I don't need to override the default for these attributes. @smacdonald2008, does that sound weird / not recommended?

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="sling:OsgiConfig" adapter.condition="If the ResourceResolver is a JcrResourceResolver or a Session." cq.workflow.models="/etc/workflow/models" cq.workflow.instances="/etc/workflow/instances" cq.workflow.workspace="crx.default" cq.workflow.superuser="[admin,administrators,some-user]"/>

instead of 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="sling:OsgiConfig" adapter.condition="If the ResourceResolver is a JcrResourceResolver or a Session." cq.workflow.models="/etc/workflow/models" cq.workflow.instances="/etc/workflow/instances" cq.workflow.workspace="crx.default"cq.workflow.job.retry="3"cq.workflow.superuser="[admin,administrators,some-user]"granite.workflow.inboxQuerySize="2000"/>

2) Try to serve a nt:file based osgi config that could be picked up by the JCR Installer and be "type friendly" like this:

# Configuration created by Apache Sling JCR Installer cq.workflow.superuser=["admin","administrators","other-user"] cq.workflow.workspace="crx.default" adapter.condition="If\ the\ ResourceResolver\ is\ a\ JcrResourceResolver\ or\ a\ Session." cq.workflow.models="/etc/workflow/models" cq.workflow.instances="/etc/workflow/instances" cq.workflow.job.retry=I"3" granite.workflow.inboxQuerySize=I"2000"

 

Not sure if that is even possible, just throwing things and see if they stick.

Basically, from an XML file defining a sling:OsgiConfig node (i.e /apps/thing/config/some.pid.config.xml), what would be the best practice to set values of "intValue" defined in SCR annotations?

@Property(intValue={42}, name="answer", label="Answer to life")

-->

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="sling:OsgiConfig" answer="42"/>

Thanks!

Avatar

Level 10

"I thought that {Long} is the only possibility to define a number value."

What give you that impression - did you read an online doc that stated this?