{"record":{"id":"752fb5d11c311bc0","repo":"apache/maven","slug":"cannot-find-artifactrepositorylayout-instance-for-752fb5","errorCode":null,"errorMessage":"Cannot find ArtifactRepositoryLayout instance for: %s %s","messagePattern":"Cannot find ArtifactRepositoryLayout instance for: (.+?) (.+?)","errorType":"exception","errorClass":"InvalidRepositoryException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java","lineNumber":393,"sourceCode":"\n    public ArtifactRepository createArtifactRepository(\n            String id,\n            String url,\n            String layoutId,\n            ArtifactRepositoryPolicy snapshots,\n            ArtifactRepositoryPolicy releases)\n            throws InvalidRepositoryException {\n        ArtifactRepositoryLayout layout = layouts.get(layoutId);\n\n        checkLayout(id, layoutId, layout);\n\n        return createArtifactRepository(id, url, layout, snapshots, releases);\n    }\n\n    private void checkLayout(String repositoryId, String layoutId, ArtifactRepositoryLayout layout)\n            throws InvalidRepositoryException {\n        if (layout == null) {\n            throw new InvalidRepositoryException(\n                    String.format(\"Cannot find ArtifactRepositoryLayout instance for: %s %s\", layoutId, repositoryId),\n                    repositoryId);\n        }\n    }\n\n    public static ArtifactRepository createArtifactRepository(\n            String id,\n            String url,\n            ArtifactRepositoryLayout repositoryLayout,\n            ArtifactRepositoryPolicy snapshots,\n            ArtifactRepositoryPolicy releases) {\n        if (snapshots == null) {\n            snapshots = new ArtifactRepositoryPolicy();\n        }\n\n        if (releases == null) {\n            releases = new ArtifactRepositoryPolicy();\n        }","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java#L375-L411","documentation":"When a repository is created with an explicit layout id, MavenRepositorySystem looks the id up in the injected map of ArtifactRepositoryLayout components and checkLayout throws InvalidRepositoryException 'Cannot find ArtifactRepositoryLayout instance for: <layoutId> <repositoryId>' if none is registered. Out of the box essentially only the 'default' layout exists; any other id must be contributed by a build extension.","triggerScenarios":"`<layout>legacy</layout>` (the old Maven-1-era layout, absent from modern Maven) or a typo like `<layout>defualt</layout>` in a POM/settings repository; a custom corporate layout whose providing extension is not on the classpath.","commonSituations":"POMs ported forward from the Maven 1/2 era; corporate repository layouts whose extension dependency was dropped during upgrades; misspelled layout ids.","solutions":["Remove the `<layout>` element - 'default' is used when omitted and is correct for all modern repositories.","If spelled explicitly, correct it to `default`.","For genuinely custom layouts, declare the extension that registers the layout as a build extension in the same POM."],"exampleFix":"<!-- before -->\n<repository>\n  <id>corp</id>\n  <url>https://repo.corp/m2</url>\n  <layout>legacy</layout>\n</repository>\n\n<!-- after -->\n<repository>\n  <id>corp</id>\n  <url>https://repo.corp/m2</url>\n</repository>","handlingStrategy":"validation","validationCode":"Set<String> knownLayouts = Set.of(\"default\"); // layouts registered by build extensions may add more\nfor (org.apache.maven.model.Repository r : model.getRepositories()) {\n    String layout = r.getLayout();\n    if (layout != null && !knownLayouts.contains(layout)) {\n        throw new IllegalArgumentException(\"Unknown <layout> \" + layout + \" on repository \" + r.getId());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit `<layout>` for standard Maven 2/3 repositories.","When using a custom layout, declare its provider extension in the same POM."],"tags":["maven","pom","repository","layout","validation"],"backgroundTag":"maven-repository-misconfigured","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}