Expand my Community achievements bar.

RepoInitParsingException while setting property value with space in AEM

Avatar

Level 9

I am trying to add jcr:title property using SlingRepositoryInitializer (RepoInit) but getting below error. 

 

 

#Root folder creation
create path /content/dam/my-site(sling:OrderedFolder mixin rep:AccessControllable)
create path /content/dam/my-site/jcr:content(nt:unstructured)

# Set properties
set properties on /content/dam/my-site/jcr:content
set jcr:title{String} to Hello Test
end

 

 

Error Log:-

 

13.03.2023 20:13:04.734 *ERROR* [CM Event Dispatcher (Fire ConfigurationEvent: pid=org.apache.sling.jcr.repoinit.RepositoryInitializer~my-site)] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer: RepositoryInitializerFactory, references=[], scripts=1

org.apache.sling.repoinit.parser.RepoInitParsingException: Encountered " <STRING> "Test "" at line 19, column 44._Was expecting:_    "\n" ..._    

at org.apache.sling.repoinit.parser.impl.RepoInitParserService.parse(RepoInitParserService.java:45) [org.apache.sling.repoinit.parser:1.6.14]

at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.processRepository(RepositoryInitializerFactory.java:127) [org.apache.sling.jcr.repoinit:1.1.39.T20220426093723-a4cd7db]

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$2.addingService(AbstractSlingRepositoryManager.java:490) [org.apache.sling.jcr.base:3.1.10]

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$2.addingService(AbstractSlingRepositoryManager.java:479) [org.apache.sling.jcr.base:3.1.10]

 

The property is set when I tried with space but I wanted to have space(usually jcr:title may have content with space). I tried with with single/double  quotes and baclslash(\) but it is working. Is there any other way to handle this usecase?

7 Replies

Avatar

Community Advisor

Hi @Mario248 ,

Can you try this?

 

# Set properties
set properties on /content/dam/my-site/jcr:content
set jcr:title{String} to "Hello Test"
end

 

If it's cfg.json try this

 

"set properties on /content/dam/my-site/jcr:content",
"set jcr:title{String} to \"Hello Test\"\nend"

 

Hope that helps!

Regards,

Santosh

Avatar

Level 9

I already tried with single and double quotes. I get below error when I use single quotes. Note I am using org.apache.sling.jcr.repoinit.RepositoryInitializer-my-site.config

 

set properties on /content/dam/my-site/jcr:content
set jcr:title{String} to "Hello Test"
end

 

Error

java.io.IOException: Unable to read dictionary from input stream: /apps/njcourts/osgiconfig/config.author/org.apache.sling.jcr.repoinit.RepositoryInitializer-my-site.config

at org.apache.sling.installer.core.impl.InternalResource.create(InternalResource.java:105) [org.apache.sling.installer.core:3.12.0]

at org.apache.sling.installer.core.impl.OsgiInstallerImpl.createResources(OsgiInstallerImpl.java:390) [org.apache.sling.installer.core:3.12.0]

at org.apache.sling.installer.core.impl.OsgiInstallerImpl.updateResources(OsgiInstallerImpl.java:430) [org.apache.sling.installer.core:3.12.0]

at org.apache.sling.installer.provider.jcr.impl.JcrInstaller.runOneCycle(JcrInstaller.java:465) [org.apache.sling.installer.provider.jcr:3.2.2]

at org.apache.sling.installer.provider.jcr.impl.JcrInstaller$StoppableThread.run(JcrInstaller.java:287) [org.apache.sling.installer.provider.jcr:3.2.2]

Caused by: java.io.IOException: Unexpected token 34; expected: 61 (line=19, pos=52)

at org.apache.sling.installer.core.impl.felix.cm.ConfigurationHandler.readFailure(ConfigurationHandler.java:698)

at org.apache.sling.installer.core.impl.felix.cm.ConfigurationHandler.readInternal(ConfigurationHandler.java:302)

at org.apache.sling.installer.core.impl.felix.cm.ConfigurationHandler.read(ConfigurationHandler.java:265)

at org.apache.sling.installer.core.impl.InternalResource.readDictionary(InternalResource.java:271) [org.apache.sling.installer.core:3.12.0]

at org.apache.sling.installer.core.impl.InternalResource.create(InternalResource.java:103) [org.apache.sling.installer.core:3.12.0]

... 4 common frames omitted

Avatar

Community Advisor

@Mario248 Below is one good example which is working for us

 

{
"scripts": [
"create path (sling:OrderedFolder) /content/dam/xyz",
"create path (nt:unstructured) /content/dam/xyz/jcr:content",
"set properties on /content/dam/xyz/jcr:content",
"set cq:conf{String} to /conf/xyz",
"set jcr:title{String} to \"xyz\"",
"end"
]
}

Avatar

Level 9

I just copied your script and tried but getting below error. I have changed the name of file to org.apache.sling.jcr.repoinit.RepositoryInitializer-mysite.cfg.json. I guess it is related syntax. I have also valided the json to check if there is any syntax but the json is valid. I am trying this in AEM SDK. Can you tell me where you tried this script? Can you tell how to debug this issue further ? 

 

Error

14.03.2023 15:20:47.930 *ERROR* [CM Event Dispatcher (Fire ConfigurationEvent: pid=org.apache.sling.jcr.repoinit.RepositoryInitializer~mysite)] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer: RepositoryInitializerFactory, references=[], scripts=6

org.apache.sling.repoinit.parser.RepoInitParsingException: Encountered "" at line 1, column 47._Was expecting one of:_    

at org.apache.sling.repoinit.parser.impl.RepoInitParserService.parse(RepoInitParserService.java:45) [org.apache.sling.repoinit.parser:1.6.14]

at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.processRepository(RepositoryInitializerFactory.java:127) [org.apache.sling.jcr.repoinit:1.1.39.T20220426093723-a4cd7db]

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$2.addingService(AbstractSlingRepositoryManager.java:490) [org.apache.sling.jcr.base:3.1.10]

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$2.addingService(AbstractSlingRepositoryManager.java:479) [org.apache.sling.jcr.base:3.1.10]

at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:944)

at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:872)

at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)

at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)

at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:904)

at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990)

at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838)

at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545)

at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4863)

at org.apache.felix.framework.Felix.registerService(Felix.java:3834)

at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:328)

at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:929) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:915) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:984) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:752) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:752) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.SingleComponentManager.reconfigure(SingleComponentManager.java:686) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.configurationUpdated(ConfigurableComponentHolder.java:440) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.RegionConfigurationSupport.configurationEvent(RegionConfigurationSupport.java:347) [org.apache.felix.scr:2.2.0]

at org.apache.felix.scr.impl.manager.RegionConfigurationSupport$2.configurationEvent(RegionConfigurationSupport.java:115) [org.apache.felix.scr:2.2.0]

at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.sendEvent(ConfigurationManager.java:1721) [org.apache.felix.configadmin:1.9.24]

at org.apache.felix.cm.impl.ConfigurationManager$FireConfigurationEvent.run(ConfigurationManager.java:1662) [org.apache.felix.configadmin:1.9.24]

at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:122) [org.apache.felix.configadmin:1.9.24]

at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:84) [org.apache.felix.configadmin:1.9.24]

at java.base/java.lang.Thread.run(Thread.java:834)

Caused by: org.apache.sling.repoinit.parser.impl.ParseException: Encountered "" at line 1, column 47._Was expecting one of:_    

at org.apache.sling.repoinit.parser.impl.RepoInitParserImpl.generateParseException(RepoInitParserImpl.java:4888) [org.apache.sling.repoinit.parser:1.6.14]

at org.apache.sling.repoinit.parser.impl.RepoInitParserImpl.jj_consume_token(RepoInitParserImpl.java:4770) [org.apache.sling.repoinit.parser:1.6.14]

at org.apache.sling.repoinit.parser.impl.RepoInitParserImpl.setPropertiesStatement(RepoInitParserImpl.java:2241) [org.apache.sling.repoinit.parser:1.6.14]

at org.apache.sling.repoinit.parser.impl.RepoInitParserImpl.parse(RepoInitParserImpl.java:89) [org.apache.sling.repoinit.parser:1.6.14]

at org.apache.sling.repoinit.parser.impl.RepoInitParserService.parse(RepoInitParserService.java:43) [org.apache.sling.repoinit.parser:1.6.14]

... 29 common frames omitted

Avatar

Community Advisor

@Mario248  above solution worked for me. But you can try below script as well

 

filename: org.apache.sling.jcr.repoinit.RepositoryInitializer-xxxxx-sites-acls.config

 

# Configuration created for ACLs for user permissions
scripts=["
create path /content/dam/xxxxxx/us-marketing-team(sling:Folder)/jcr:content(nt:unstructured)
set properties on /content/dam/xxxxx/xxxxxxx/jcr:content
set jcr:title{String} to \"Test title\"
end
"]