Expand my Community achievements bar.

SOLVED

Repoinit frequently giving issues on server restart

Avatar

Level 8

Hi All,

Some time ago, we started using Repository Initializer from Sling to perform some initial setup of eg paths and permissions:

https://sling.apache.org/documentation/bundles/repository-initialization.html

 

What we're seeing is that these frequently give issues on a server restart, also in UAT / PROD.

In case such a repo init script fails at package installation time, an exception is logged to the error.log file but nothing obvious happens. In case such an exception happens on server startup, the JCR repository doesn't get initialized and AEM won't start up at all. To remedy this, manual actions are needed every restart to remove the config file from disk and allow AEM to start up normally.

 

To remedy this, a few actions are needed:

  1. As this is quite inconvenient and we lose quite a lot of time on this, we should review the existing repo init scripts and ensure they run properly in all cases. For example, the script should still run OK in case some repository paths are missing, in case some of the properties already have some value (single value / multi-value), etc.
  2. We should also come up with some guidelines or best practices during development time to ensure these scripts are as stable as they can be and will never block the server startup due to some exceptions.

Can you take a look at the suggestions above and ensure the config files are improved and that we have some guidelines to avoid similar issues in the future? Thanks!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Vani1012 

set properties on /endkeyword
  # using "end" instead of "endS" below causes parsing to fail
  set endS to one
  set two to endS
end

set properties on /forcedMultiValue
  set singleMultiValue{String[]} to "single"
  set singleLongMultiValue{Long[]} to 1243
end

 

The documentation shares 2 ways, in which we can set property.

  • "set endS to one" this give us result

aanchalsikka_0-1694452251444.png

  • set singleMultiValue{String[]} to "single" to a String[]. But, what we are getting is a String.

aanchalsikka_1-1694452664908.png

 

 

 

There is a discrepancy in forcibly using Arrays for a Single value.


Aanchal Sikka

View solution in original post

10 Replies

Avatar

Community Advisor

Hello @Vani1012 

 

Thanks for sharing your insights. It would definitely be a good improvement.

Since, this is a suggestion and not a question, requesting you to please post it as an idea, in "Ideas" Tab.

 


Aanchal Sikka

Avatar

Level 8

@aanchal-sikka Can you please share some inputs how we can improve config files and provide some best practices

Avatar

Community Advisor

Hello @Vani1012 

 

The repo-init scripts are meant to work during server start. If you are noticing error, you would need to fix them.

We shouldn't need to remove and put them back in.

 

- Arre these custom scripts?

- If yes, please share the errors logs.

-Why do we need to alter values with repo-init? (Single->Multi)

 

For now, we need to make sure, paths are available, before setting ACL or adding property.

The proper jcr:primaryType need to be used for creating nodes, as these can't be altered later

 


Aanchal Sikka

Avatar

Level 8

@aanchal-sikka This is what we defined in repoinit osgi config

Vani1012_0-1694429182038.png

Vani1012_1-1694429299892.png

 

 

Nothing specific in logs

Avatar

Community Advisor

@Vani1012 

 

It will be difficult to debug with only configs. In original post you mentioned about exceptions, can you possibly share the same?


Aanchal Sikka

Avatar

Level 8

04.08.2023 07:28:24.378 *ERROR* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer, SlingRepository service registration aborted javax.jcr.RepositoryException: Applying repoinit operation failed despite retry; set loglevel to DEBUG to see all exceptions. Last exception message was: Failed to set ACL (javax.jcr.PathNotFoundException: Cannot set ACL on non-existent path /conf/brandsv2/ceccatocluster) AclLine ALLOW {paths=[/conf/brandsv2/ceccatocluster], privileges=[jcr:all]}
07.09.2023 10:43:38.612 *INFO* [Apache Sling Repository Startup Thread #1] org.apache.sling.jcr.repoinit.impl.NodePropertiesVisitor Setting properties on nodePath '/content/brands/isravision/jcr:content'
07.09.2023 10:43:38.621 *ERROR* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer, SlingRepository service registration aborted
javax.jcr.RepositoryException: Applying repoinit operation failed despite retry; set loglevel to DEBUG to see all exceptions. Last exception message was: Unable to set properties on path [/content/brands/isravision/jcr:content]:javax.jcr.ValueFormatException: Can not assign a single value to multi-valued property: cq:allowedTemplates = /conf/brandsv2/isravision/settings/wcm/templates/(?!xf-).*
        at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.applyOperations(RepositoryInitializerFactory.java:176) [org.apache.sling.jcr.repoinit:1.1.38]
        at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.processRepository(RepositoryInitializerFactory.java:129)  

@aanchal-sikka is there a possibility even though we pass single value to multi valued property  it should run the script without interruption

Avatar

Community Advisor

Hello @Vani1012 

 

You should raise the bug for that array enforcement is not happening for single values.

 

set properties on /content/dam/techrevelaemsite/jcr:content
  set cq:conf{String} to /conf/techrevelaemsite
  set jcr:title{String} to "Techrevel AEM Site"
  set test4{String[]} to "Techrevel AEM Site"
end

 

 

As per [0], following should create forced multi values.

set properties on /forcedMultiValue
  set singleMultiValue{String[]} to "single"
  set emptyMultiValue{String[]} to
  set singleLongMultiValue{Long[]} to 1243
  set emptyLongMultiValue{Long[]} to
end

 

[0]: https://sling.apache.org/documentation/bundles/repository-initialization.html

 

This would have avoided the exception in first place.

 

Which version of AEM are you using currently? Can you possibly try with latest Service pack?


Aanchal Sikka

Avatar

Level 8

I am using 6.5.16 service pack,

Can you please explain a bit more the second point

As per [0], following should create forced multi values.

set properties on /forcedMultiValue
  set singleMultiValue{String[]} to "single"
  set emptyMultiValue{String[]} to
  set singleLongMultiValue{Long[]} to 1243
  set emptyLongMultiValue{Long[]} to
end

 

 

Avatar

Correct answer by
Community Advisor

@Vani1012 

set properties on /endkeyword
  # using "end" instead of "endS" below causes parsing to fail
  set endS to one
  set two to endS
end

set properties on /forcedMultiValue
  set singleMultiValue{String[]} to "single"
  set singleLongMultiValue{Long[]} to 1243
end

 

The documentation shares 2 ways, in which we can set property.

  • "set endS to one" this give us result

aanchalsikka_0-1694452251444.png

  • set singleMultiValue{String[]} to "single" to a String[]. But, what we are getting is a String.

aanchalsikka_1-1694452664908.png

 

 

 

There is a discrepancy in forcibly using Arrays for a Single value.


Aanchal Sikka

Avatar

Administrator

@Vani1012 Do you find the suggestions from users useful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. 



Kautuk Sahni