Skip to content

Conversation

@lukaszlenart
Copy link
Member

Summary

Fixes WW-5593

  • Add NoClassDefFoundError to the catch block in PackageBasedActionConfigBuilder.getActionClassTest()
  • Improve error message to help users understand missing dependency issues
  • Add unit tests for both NoClassDefFoundError and ClassNotFoundException handling

Problem

The convention plugin's PackageBasedActionConfigBuilder only caught ClassNotFoundException but not NoClassDefFoundError when scanning for action classes. This caused complete application startup failure when:

  • struts.convention.action.includeJars is configured
  • Scanned JARs contain classes with missing optional dependencies (e.g., test classes depending on JUnit)

Solution

Use multi-catch to handle both exception types:

} catch (ClassNotFoundException | NoClassDefFoundError ex) {
    LOG.error("Unable to load class [{}]. Perhaps it exists but certain dependencies are not available?",
            classInfo.getName(), ex);
    return false;
}

Test plan

  • New unit test testNoClassDefFoundErrorHandling() verifies NoClassDefFoundError is caught
  • New unit test testClassNotFoundExceptionHandling() verifies existing behavior preserved
  • All 8 tests in PackageBasedActionConfigBuilderTest pass

🤖 Generated with Claude Code

…scanning

The PackageBasedActionConfigBuilder now catches NoClassDefFoundError in
addition to ClassNotFoundException when scanning for action classes.
This prevents application startup failures when classes have missing
optional dependencies (e.g., test classes depending on JUnit).

Changes:
- Add NoClassDefFoundError to catch block in getActionClassTest()
- Improve error message to suggest missing dependencies
- Add unit tests for both exception types

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@lukaszlenart lukaszlenart force-pushed the feat/WW-5593-convention-plugin-noclass-exception branch from 0cb91de to 4a53c90 Compare December 14, 2025 18:44
@sonarqubecloud
Copy link

@lukaszlenart lukaszlenart merged commit 1fef0e1 into main Dec 14, 2025
11 checks passed
@lukaszlenart lukaszlenart deleted the feat/WW-5593-convention-plugin-noclass-exception branch December 14, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants