coerceToString is an internal method | Community
Skip to main content
New Participant
October 21, 2016
Solved

coerceToString is an internal method

  • October 21, 2016
  • 5 replies
  • 1575 views

Hi 

        I am getting the below error in my pages from my page.html. Does anyone already faced this issue before ?

HTML

<!doctype html>
<html lang="en" class="js csscolumns svg">
    <head>
        <sly data-sly-include="partials/head.html" data-sly-unwrap/>
        <sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>
    </head>
    <body class="page ${currentPage.template.name}">
        <sly data-sly-include="partials/main.html" data-sly-unwrap/>
        <sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>
    </body>
</html>

Exception:

org.apache.sling.scripting.sightly.SightlyException: coerceToString is an internal method at io.sightly.java.impl.slingAdapter.ObjectModelAdapter.coerceToString(ObjectModelAdapter.java:43) at com.adobe.cq.sightly.internal.extensions.IncludeExtension$1.call(IncludeExtension.java:63) at io.sightly.java.impl.graniteAdapter.RuntimeExtensionAdapter.call(RuntimeExtensionAdapter.java:37) at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:89)

 

TIA

Veena

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

${currentPage.template} only works with the right permissions, nothing to do with the dispatcher.

Basically: never use getTemplate() :-)

5 replies

Feike_Visser1
Feike_Visser1Accepted solution
Employee
October 22, 2016

${currentPage.template} only works with the right permissions, nothing to do with the dispatcher.

Basically: never use getTemplate() :-)

New Participant
October 21, 2016

Also you shouldn't use $[currentPage.template} - it'll be blocked on the dispatcher due to permissions.

smacdonald2008
New Participant
October 21, 2016

Could have been an outdated file or something. Glad its working. 

New Participant
October 21, 2016

Thanks for the quick response scott. I installed the package in a fresh instance and all started working fine. I am not sure what has happened to the instance before

smacdonald2008
New Participant
October 21, 2016

Create a new project using Maven 10 project. 

https://helpx.adobe.com/experience-manager/using/first-arch10.html

Take a look at some of the default HTML pages -- for example:

<html lang="en">
    <head>
        <sly data-sly-include="partials/head.html" data-sly-unwrap/>
        <sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>
    </head>
    <body class="page ${currentPage.template.name}">
        <sly data-sly-include="partials/main.html" data-sly-unwrap/>
        <sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>
    </body>
</html>

You should not be seeing that error. Compare the code on that project with yours.