Skip to content

Improve error message: misconfigured neighborhood feature. #2287

@TomCools

Description

@TomCools

Describe the bug
When configuring the feature as in our docs:

<?xml version="1.0" encoding="UTF-8"?>
<solver xmlns="https://timefold.ai/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="https://timefold.ai/xsd/solver https://timefold.ai/xsd/solver/solver.xsd">
    <enablePreviewFeature>NEIGHBORHOODS</enablePreviewFeature>
    <localSearch>
        <neighborhoodProviderClass>com.acme.MyNeighborhoodProvider</neighborhoodProviderClass>
    </localSearch>
</solver>

But the class com.acme.MyNeighborhoodProvider doesn't exist, I get a vague error.

Expected behavior
Better error message: something like "configured Neighborhood Provider could not be found?"

Actual behavior

On first solve attempt:

2026-05-05 15:13:35,556 ERROR [org.acme.vehiclerouting.rest.VehicleRoutePlanResource] (pool-8-thread-1) Failed solving jobId (6e571640-8e92-41d3-afbf-ac9e59d0435e).: java.lang.IndexOutOfBoundsException: Index 11 out of bounds for length 9
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
        at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
        at java.base/java.util.Objects.checkIndex(Objects.java:365)
        at java.base/java.util.ArrayList.get(ArrayList.java:428)
        at ai.timefold.solver.core.impl.util.ElementAwareArrayList.get(ElementAwareArrayList.java:49)
        at ai.timefold.solver.core.impl.bavet.common.index.DefaultUniqueRandomIterator.hasNext(DefaultUniqueRandomIterator.java:62)
        at ai.timefold.solver.core.impl.bavet.common.index.FilteredUniqueRandomIterator.hasNext(FilteredUniqueRandomIterator.java:40)
        at ai.timefold.solver.core.impl.neighborhood.stream.BiRandomMoveIterator.pickNextMove(BiRandomMoveIterator.java:109)
        at ai.timefold.solver.core.impl.neighborhood.stream.BiRandomMoveIterator.hasNext(BiRandomMoveIterator.java:85)
        at ai.timefold.solver.core.impl.neighborhood.RandomOrderNeighborhoodIterator.hasNext(RandomOrderNeighborhoodIterator.java:32)
        at ai.timefold.solver.core.impl.localsearch.decider.LocalSearchDecider.decideNextStep(LocalSearchDecider.java:93)
        at ai.timefold.solver.core.impl.localsearch.DefaultLocalSearchPhase.solve(DefaultLocalSearchPhase.java:89)

To Reproduce
Add the xml above in a solverconfig.xml to any project.

Environment

Timefold Solver Version or Git ref: Using Timefold Solver Community Edition v2.0.0.

Output of java -version: 21

Metadata

Metadata

Assignees

Labels

component/docsImprovements or additions to documentation

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions