{"record":{"id":"1222a0de282d29dd","repo":"GoogleContainerTools/jib","slug":"mainclass-configured-in-jarpluginname-is-not","errorCode":null,"errorMessage":"'mainClass' configured in ${jarPluginName} is not a valid Java class: ${mainClass}","messagePattern":"'mainClass' configured in (.+?) is not a valid Java class: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/MainClassResolver.java","lineNumber":78,"sourceCode":"                  + \" is not a valid Java class: \"\n                  + configuredMainClass,\n              projectProperties.getPluginName()));\n    }\n\n    projectProperties.log(\n        LogEvent.info(\n            \"Searching for main class... Add a 'mainClass' configuration to '\"\n                + projectProperties.getPluginName()\n                + \"' to improve build speed.\"));\n\n    String mainClassFromJarPlugin = projectProperties.getMainClassFromJarPlugin();\n    if (mainClassFromJarPlugin != null && isValidJavaClass(mainClassFromJarPlugin)) {\n      return mainClassFromJarPlugin;\n    }\n\n    if (mainClassFromJarPlugin != null) {\n      projectProperties.log(\n          LogEvent.warn(\n              \"'mainClass' configured in \"\n                  + projectProperties.getJarPluginName()\n                  + \" is not a valid Java class: \"\n                  + mainClassFromJarPlugin));\n    }\n    projectProperties.log(\n        LogEvent.info(\n            \"Could not find a valid main class from \"\n                + projectProperties.getJarPluginName()\n                + \"; looking into all class files to infer main class.\"));\n\n    MainClassFinder.Result mainClassFinderResult =\n        MainClassFinder.find(projectProperties.getClassFiles(), projectProperties::log);\n    switch (mainClassFinderResult.getType()) {\n      case MAIN_CLASS_FOUND:\n        return mainClassFinderResult.getFoundMainClass();\n\n      case MAIN_CLASS_NOT_FOUND:","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/MainClassResolver.java#L60-L96","documentation":"Jib warns that the mainClass property configured in the JAR plugin (maven-jar-plugin or similar) is not a valid Java class name. The plugin validates the class name shape (and optionally that the class exists) before using it; if invalid, it falls back to other mainClass sources and emits this warning.","triggerScenarios":"The mainClass element in the jar plugin configuration (e.g. maven-jar-plugin's archive manifest mainClass) is empty, misspelled, does not look like a valid class name (no valid Java identifier segments), or points to a class that cannot be resolved.","commonSituations":"Typo in the package/class name in pom.xml; class removed after refactoring; setting mainClass in the jar plugin instead of the Jib plugin configuration; using a non-class value like a script name.","solutions":["Set mainClass directly in the Jib plugin configuration (jib.mainClass in Maven or jib.mainClass in Gradle) with a fully qualified valid class name","Fix the mainClass value in the jar plugin configuration so it is a valid, existing Java class (e.g. com.example.Main)","Remove the invalid mainClass from the jar plugin configuration if Jib should infer or use another source","Run with debug/verbose logging to see which mainClass Jib ultimately resolved"],"exampleFix":"// before (pom.xml)\n<plugin>\n  <artifactId>maven-jar-plugin</artifactId>\n  <configuration><archive><manifest><mainClass>com.exmaple.Main</mainClass></manifest></archive></configuration>\n</plugin>\n// after\n<plugin>\n  <groupId>com.google.cloud.tools</groupId>\n  <artifactId>jib-maven-plugin</artifactId>\n  <configuration><mainClass>com.example.Main</mainClass></configuration>\n</plugin>","handlingStrategy":"validation","validationCode":"String mc = jarPluginMainClass;\nif (mc == null || !mc.matches(\"[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*\")) {\n  throw new IllegalArgumentException(\"Invalid mainClass in jar plugin config: \" + mc);\n}","typeGuard":"boolean isValidJavaClass(String name) {\n  return name != null && name.matches(\"[a-zA-Z_$][a-zA-Z0-9_$]*(\\\\.[a-zA-Z_$][a-zA-Z0-9_$]*)*\");\n}","tryCatchPattern":null,"preventionTips":["Set mainClass in the Jib plugin configuration, not the jar plugin","Keep a build check that the mainClass exists on the compile classpath","Use fully qualified class names generated from the project's groupId/artifactId conventions"],"tags":["java","jib","config","main-class"],"backgroundTag":"invalid-config-value","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}