Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Operands are not of the same type: the equality operator can only be applied to String, Number and Boolean types.

Avatar

Level 4

Hi,

Need your hep in resolving below exceptions: getting below exception post migration from AEM 6.1 to AEM 6.3

All bundles are in active state.

27.09.2017 10:15:31.272 *ERROR* [10.5.2.154 [1506500131064] GET /content/suninternational/properties/table-bay.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException org.apache.sling.scripting.sightly.compiler.SightlyCompilerException: Operands are not of the same type: the equality operator can only be applied to String, Number and Boolean types.

1 Accepted Solution

Avatar

Correct answer by
Administrator

This happens when you're doing a comparison between un-suited date types like String vs. Number etc.

Can you please share the full error so that we may know the component having an issue. Then just share the code line having the issue.

Similar issue reported here:-

SightlyCompilerException: BinaryOperator.strictEq(BinaryOperator.java:238)

// Issue was because of data-sly-test="${list[0] !=null}"

   [solution] data-sly-test="${list}"

Sightly comparison expression

//  <sly data-sly-test="${itemList.index == ${properties.getvalue} }">

     [Solution] data-sly-test.stringIndex="${'{0}' @ format=[itemList.index]}"

I hope you can get some help from here.

~kautuk



Kautuk Sahni

View solution in original post

4 Replies

Avatar

Administrator

Veena_07 Any thought here?



Kautuk Sahni

Avatar

Correct answer by
Administrator

This happens when you're doing a comparison between un-suited date types like String vs. Number etc.

Can you please share the full error so that we may know the component having an issue. Then just share the code line having the issue.

Similar issue reported here:-

SightlyCompilerException: BinaryOperator.strictEq(BinaryOperator.java:238)

// Issue was because of data-sly-test="${list[0] !=null}"

   [solution] data-sly-test="${list}"

Sightly comparison expression

//  <sly data-sly-test="${itemList.index == ${properties.getvalue} }">

     [Solution] data-sly-test.stringIndex="${'{0}' @ format=[itemList.index]}"

I hope you can get some help from here.

~kautuk



Kautuk Sahni

Avatar

Level 10

Hi anelem1760873

There exist a property in which you are performing equality operator. Now the type of this property has been changed.

I not sure if this is a bug in 6.3 but I have seen same while 6.1 - > 6.3 upgrade.

Check the property in CRX and changed its type to original (it should be one of String, Number, boolean I guess)

Thanks

Avatar

Level 1

Hi,

I too have seen this below exception once while working.

Caused by: org.apache.sling.scripting.sightly.compiler.SightlyCompilerException: Operands are not of the same type: the equality operator can only be applied to String, Number and Boolean types.

I feel like the issue might also occur due to pom.xml - where we try to include sling models using <Sling-Model-Packages>

So, the value within the <Sling-Model-Packages></Sling-Model-Packages> should be specified properly. Otherwise, the classes wont work as models.To check whether your classes are working as models or not, you can access and check within your instance by visitng http://localhost:4502/system/console/adapters and search for your class. If it exists, your classes having @Model annotation will be identified as models.

Lets imagine you have two model classes in two different packages,
1. com.example.core.SampleModel.java
2. com.example.core.models.MyModel.java


Consider these below things:

While using maven pom configuration, make sure that it includes both the packages as shown below:
<Sling-Model-Packages>com.example.core, com.example.core.*</Sling-Model-Packages>

1. com.example.core is required and can load the Model classes in that package only.

2. com.example.core.* can load the model classes in all packages which are under core. But not core package.

    Here MyModel.java which is under com.example.core.models can be represented using com.example.core.*

I think this overview might be helpful and provides solution for most of you.

Regards,
Srikanth Popuri