apache/maven · error · IllegalArgumentException
path, url, reader or inputStream must be non null
Error message
path, url, reader or inputStream must be non null
What it means
Thrown by DefaultPluginXmlFactory.read(XmlReaderRequest) when the request names no input: path, url, reader and inputStream are all null. The factory checks all four sources before parsing a PluginDescriptor (plugin.xml) and rejects the call immediately. This is a caller-contract violation.
Source
Thrown at impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java:56
import org.apache.maven.plugin.descriptor.io.PluginDescriptorStaxReader;
import org.apache.maven.plugin.descriptor.io.PluginDescriptorStaxWriter;
import static java.util.Objects.requireNonNull;
import static org.apache.maven.impl.StaxLocation.getLocation;
import static org.apache.maven.impl.StaxLocation.getMessage;
@Named
@Singleton
public class DefaultPluginXmlFactory implements PluginXmlFactory {
@Override
public PluginDescriptor read(@Nonnull XmlReaderRequest request) throws XmlReaderException {
requireNonNull(request, "request");
Path path = request.getPath();
URL url = request.getURL();
Reader reader = request.getReader();
InputStream inputStream = request.getInputStream();
if (path == null && url == null && reader == null && inputStream == null) {
throw new IllegalArgumentException("path, url, reader or inputStream must be non null");
}
try {
PluginDescriptorStaxReader xml = request.getTransformer() != null
? new PluginDescriptorStaxReader(request.getTransformer()::transform)
: new PluginDescriptorStaxReader();
xml.setAddDefaultEntities(request.isAddDefaultEntities());
if (inputStream != null) {
return xml.read(inputStream, request.isStrict());
} else if (reader != null) {
return xml.read(reader, request.isStrict());
} else if (path != null) {
try (InputStream is = Files.newInputStream(path)) {
return xml.read(is, request.isStrict());
}
} else {
try (InputStream is = url.openStream()) {
return xml.read(is, request.isStrict());
}View on GitHub (pinned to e4093d4e12)
Solutions
- Set exactly one input on the request: .inputStream(is), .reader(r), .path(p) or .url(u)
- If the source is dynamic, check the four getters for null before calling read
- Prefer .path or .url so the factory owns opening and closing the stream
Example fix
// before
PluginDescriptor pd = pluginXmlFactory.read(XmlReaderRequest.builder()
.modelId("my.plugin:my-plugin:1.0")
.build()); // throws: no input source
// after
PluginDescriptor pd = pluginXmlFactory.read(XmlReaderRequest.builder()
.modelId("my.plugin:my-plugin:1.0")
.path(pluginXmlPath)
.build()); Defensive patterns
Strategy: validation
Validate before calling
XmlReaderRequest req = XmlReaderRequest.builder()
.modelId("g:a:v")
.build();
if (req.getPath() == null && req.getURL() == null
&& req.getReader() == null && req.getInputStream() == null) {
throw new IllegalStateException("plugin descriptor read request has no input source");
}
pluginXmlFactory.read(req); Prevention
- Set the input source in the same builder chain as modelId so it cannot be forgotten
- Prefer path or url sources so the factory handles stream closing
When it happens
Trigger: Building a XmlReaderRequest intended for a plugin descriptor without .path(...), .url(...), .reader(...) or .inputStream(...); setting only modelId, location or strict and forgetting the actual source.
Common situations: Copy-pasting request builders between the different XML factories; loading plugin.xml through a variable that turns out null; migrating code that opened the stream manually and lost that line in the port.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- writer, outputStream or path must be non null
- reader or inputStream must be non null
- reader or inputStream must be non null
- writer, outputStream or path must be non null
- Unable to read plugin:
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/c2d63e864b1eb895.
Report an issue: GitHub.