{"record":{"id":"d4a60012c6542a24","repo":"apache/maven","slug":"goal-requires-online-mode-for-execution-but-maven","errorCode":null,"errorMessage":"Goal requires online mode for execution but Maven is currently offline.","messagePattern":"Goal requires online mode for execution but Maven is currently offline\\.","errorType":"exception","errorClass":"LifecycleExecutionException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java","lineNumber":205,"sourceCode":"        try {\n            mavenPluginManager.checkPrerequisites(mojoDescriptor.getPluginDescriptor());\n        } catch (PluginIncompatibleException e) {\n            throw new LifecycleExecutionException(messageBuilderFactory, mojoExecution, session.getCurrentProject(), e);\n        }\n\n        if (mojoDescriptor.isProjectRequired() && !session.getRequest().isProjectPresent()) {\n            Throwable cause = new MissingProjectException(\n                    \"Goal requires a project to execute\" + \" but there is no POM in this directory (\"\n                            + session.getExecutionRootDirectory() + \").\"\n                            + \" Please verify you invoked Maven from the correct directory.\");\n            throw new LifecycleExecutionException(messageBuilderFactory, mojoExecution, null, cause);\n        }\n\n        if (mojoDescriptor.isOnlineRequired() && session.isOffline()) {\n            if (MojoExecution.Source.CLI.equals(mojoExecution.getSource())) {\n                Throwable cause = new IllegalStateException(\n                        \"Goal requires online mode for execution\" + \" but Maven is currently offline.\");\n                throw new LifecycleExecutionException(\n                        messageBuilderFactory, mojoExecution, session.getCurrentProject(), cause);\n            } else {\n                eventCatapult.fire(ExecutionEvent.Type.MojoSkipped, session, mojoExecution);\n\n                return;\n            }\n        }\n\n        doExecute(session, mojoExecution, dependencyContext);\n    }\n\n    protected static class NoLock implements NoExceptionCloseable {\n        public NoLock() {}\n\n        @Override\n        public void close() {}\n    }\n","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java#L187-L223","documentation":"Before executing a mojo, MojoExecutor checks the descriptor's requiresOnline flag against the session: if the goal needs network access but Maven runs with -o/--offline, the behavior splits by source. For a CLI-invoked goal (MojoExecution.Source.CLI) Maven throws LifecycleExecutionException wrapping this IllegalStateException; for lifecycle-bound executions it fires a MojoSkipped event instead and silently skips.","triggerScenarios":"Running a requiresOnline=true goal (e.g. goals that download remote metadata or hit remote services) with mvn -o or --offline-mode configured; a CLI goal like versions:display-dependency-updates in offline mode fails here, while the same goal bound to a lifecycle phase would just be skipped.","commonSituations":"Air-gapped CI builds forcing -o for reproducibility and then calling a goal that must reach remotes; developers enabling offline to speed builds and forgetting a specific goal needs the network; proxies mirroring everything but leaving offline on.","solutions":["Drop -o/--offline for that invocation (e.g. mvn versions:display-plugin-updates) since the goal genuinely needs remotes","Pre-populate the local repository first (run once online, or copy the repo) and keep offline for the rest of the build","If the goal is lifecycle-bound, be aware it will be silently skipped offline — check build logs for MojoSkipped instead of failures","Pin plugin/goal choices in offline pipelines to goals that do not require online"],"exampleFix":"# before\nmvn -o versions:display-dependency-updates   # goal requires online\n\n# after\nmvn versions:display-dependency-updates\n# or stay offline but accept the skip for lifecycle-bound executions","handlingStrategy":"validation","validationCode":"// before invoking a goal in an offline-capable pipeline\nif (mojoDescriptor.isOnlineRequired() && session.isOffline()) {\n    throw new IllegalStateException(\"Goal \" + goal + \" requires online mode; disable -o or pre-seed the local repo\");\n}","typeGuard":null,"tryCatchPattern":"catch (LifecycleExecutionException e) {\n    if (e.getCause() instanceof IllegalStateException ise\n            && ise.getMessage().contains(\"offline\")) {\n        // rerun online: remove -o from the invocation\n    }\n}","preventionTips":["Split builds: offline for compile/test, online for goals that need remotes","Pre-warm the local repository once online so offline runs succeed","Audit requiresOnline goals before enabling -o in CI templates"],"tags":["maven","offline","requires-online","mojo","network"],"backgroundTag":"offline-mode-goal-conflict","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}