{"record":{"id":"cc6f847a4dd3351e","repo":"apache/maven","slug":"the-token-s-at-position-d-refers-to-a-java-u-cc6f84","errorCode":null,"errorMessage":"The token '%s' at position '%d' refers to a java.util.List or an array, but the value seems is an instance of '%s'","messagePattern":"The token '(.+?)' at position '(.+?)' refers to a java\\.util\\.List or an array, but the value seems is an instance of '(.+?)'","errorType":"exception","errorClass":"IntrospectionException","httpStatus":null,"severity":"error","filePath":"compat/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/reflection/ReflectionValueExtractor.java","lineNumber":267,"sourceCode":"            int index = Integer.parseInt(indexStr);\n\n            if (value.getClass().isArray()) {\n                return Array.get(value, index);\n            }\n\n            if (value instanceof List list) {\n                return list.get(index);\n            }\n        } catch (NumberFormatException | IndexOutOfBoundsException e) {\n            return null;\n        }\n\n        final String message = String.format(\n                \"The token '%s' at position '%d' refers to a java.util.List or an array, but the value \"\n                        + \"seems is an instance of '%s'\",\n                expression.subSequence(from, to), from, value.getClass());\n\n        throw new IntrospectionException(message);\n    }\n\n    private static Object getPropertyValue(Object value, String property) throws IntrospectionException {\n        if (value == null || property == null || property.isEmpty()) {\n            return null;\n        }\n\n        ClassMap classMap = getClassMap(value.getClass());\n        String methodBase = Character.toTitleCase(property.charAt(0)) + property.substring(1);\n        try {\n            for (String prefix : Arrays.asList(\"get\", \"is\", \"to\", \"as\")) {\n                Method method = classMap.findMethod(prefix + methodBase);\n                if (method != null) {\n                    return method.invoke(value, OBJECT_ARGS);\n                }\n            }\n            return null;\n        } catch (InvocationTargetException e) {","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-model-builder/src/main/java/org/apache/maven/model/interpolation/reflection/ReflectionValueExtractor.java#L249-L285","documentation":"Companion of the Map error: an expression token indexes into what should be a List or array, but the value at that position is neither, or the bracketed token is not a valid list index. IntrospectionException reports the token, its position, and the actual class, aborting interpolation of the whole expression.","triggerScenarios":"Expressions such as ${project.artifactId[0]} or ${something.field[0]} where the indexed value is not a List or array; note that a non-numeric bracket token on a List also swallows into this path before the throw.","commonSituations":"Indexing expressions against fields whose type changed between versions; ${project.repositories[0].url}-style paths copied onto non-list values; stale plugin documentation showing bracket syntax.","solutions":["Check the actual type at the failing position (named in the message) and use plain property access for beans","Use bracket indexing only on documented List/array values such as ${project.repositories[0].url}","Fix or remove stale expressions copied from other projects","Validate interpolated expressions after model or plugin upgrades with help:effective-pom"],"exampleFix":"<!-- before: index applied to a non-list value -->\n<name>${project.artifactId[0]}</name>\n\n<!-- after: index only List/array-valued paths -->\n<url>${project.repositories[0].url}</url>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static boolean isIndexablePath(Object node) {\n    return node != null && (node instanceof List<?> || node.getClass().isArray());\n}","tryCatchPattern":"try {\n    Object v = ReflectionValueExtractor.evaluate(expr, model);\n} catch (IntrospectionException e) {\n    // token expected a List/array but found another type: fix the expression\n    log.warn(\"Bad indexed expression {}: {}\", expr, e.getMessage());\n    return defaultValue; // or surface to the user\n}","preventionTips":["Use [n] indexing only on documented List/array fields (e.g. project.repositories)","Prefer explicit <properties> over deep object-path expressions","Validate interpolated expressions with an effective-pom check after model changes"],"tags":["maven","interpolation","reflection","pom-expression","indexing"],"backgroundTag":"expression-interpolation-failure","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}