Legacy Knowledge Base
Published Jul. 2, 2025

ClassCastException when using Elasticsearch 7

Written By

Michael Warren Young

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • After installing the Elasticsearch 7 plugin and connecting Liferay DXP to an Elasticsearch 7 server, errors like this are thrown on startup:

    ERROR [liferay/scheduler_dispatch-4][ElasticsearchIndexSearcher:169] java.lang.ClassCastException: org.elasticsearch.search.sort.FieldSortBuilder cannot be cast to org.elasticsearch.search.sort.SortBuilder

    java.lang.ClassCastException: org.elasticsearch.search.sort.FieldSortBuilder cannot be cast to org.elasticsearch.search.sort.SortBuilder

Environment

  • Liferay DXP 7.2 (with fix pack DXP-2+)
  • Elasticsearch 7

Resolution

  • A ClassCastException can be thrown when multiple versions of the Elasticsearch plugin are running at the same time.
  • After deploying the Elasticsearch 7 module, it's necessary to add the Elasticsearch 6 module to the blacklist by creating a config file named
    com.liferay.portal.bundle.blacklist.internal.BundleBlacklistConfiguration.config
    With the following content:


  • blacklistBundleSymbolicNames=[ \
        "com.liferay.portal.search.elasticsearch6.api", \
        "com.liferay.portal.search.elasticsearch6.impl", \
        "com.liferay.portal.search.elasticsearch6.spi", \
        "com.liferay.portal.search.elasticsearch6.xpack.security.impl", \
        "Liferay Connector to X-Pack Security [Elastic Stack 6.x] - Impl" \
    ]
    

Additional Information

 

Did this article resolve your issue ?

Legacy Knowledge Base