GoogleContainerTools/jib · error · MainClassInferenceException
'mainClass' configured in ${projectProperties.getPluginName(
Error message
'mainClass' configured in ${projectProperties.getPluginName()} is not a valid Java class: ${configuredMainClass} What it means
MainClassInferenceException thrown by MainClassResolver.resolveMainClass() when the explicitly configured mainClass value fails isValidJavaClass(): at least one dot-separated segment is not a valid Java identifier. This is a validation guard on the user-supplied input 'configuredMainClass' — e.g. it contains illegal characters, spaces, or is a path rather than a fully qualified class name — so the entrypoint cannot be built from it.
Source
Thrown at jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/MainClassResolver.java:56
*
* <p>Warns if main class provided by {@code projectProperties} is not valid, or throws an error
* if no valid main class is found.
*
* @param configuredMainClass the explicitly configured main class ({@code null} if not
* configured)
* @param projectProperties properties containing plugin information and help messages
* @return the name of the main class to be used for the container entrypoint
* @throws MainClassInferenceException if no valid main class is configured or discovered
* @throws IOException if getting the class files from {@code projectProperties} fails
*/
public static String resolveMainClass(
@Nullable String configuredMainClass, ProjectProperties projectProperties)
throws MainClassInferenceException, IOException {
if (configuredMainClass != null) {
if (isValidJavaClass(configuredMainClass)) {
return configuredMainClass;
}
throw new MainClassInferenceException(
HelpfulSuggestions.forMainClassNotFound(
"'mainClass' configured in "
+ projectProperties.getPluginName()
+ " is not a valid Java class: "
+ configuredMainClass,
projectProperties.getPluginName()));
}
projectProperties.log(
LogEvent.info(
"Searching for main class... Add a 'mainClass' configuration to '"
+ projectProperties.getPluginName()
+ "' to improve build speed."));
String mainClassFromJarPlugin = projectProperties.getMainClassFromJarPlugin();
if (mainClassFromJarPlugin != null && isValidJavaClass(mainClassFromJarPlugin)) {
return mainClassFromJarPlugin;
}View on GitHub (pinned to fb949e2676)
Solutions
- Set <mainClass> (Maven) or the jib/mainClass convention (Gradle) to a fully qualified class name like com.example.Main
- Remove invalid characters (spaces, slashes, $ quirks) or a file path from the configured value
- If the class genuinely exists, confirm the name including package segments is correct
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/MainClassResolver.java:56 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of GoogleContainerTools/jib@fb949e2676 (2026-09-06).
Data as JSON: /api/errors/08780bb96e131208.
Report an issue: GitHub.