[
https://issues.apache.org/jira/browse/WW-5593?focusedWorklogId=996082&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-996082
]
ASF GitHub Bot logged work on WW-5593:
--------------------------------------
Author: ASF GitHub Bot
Created on: 13/Dec/25 20:23
Start Date: 13/Dec/25 20:23
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #1469:
URL: https://github.com/apache/struts/pull/1469
## Summary
Fixes [WW-5593](https://issues.apache.org/jira/browse/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:
```java
} 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
- [x] New unit test `testNoClassDefFoundErrorHandling()` verifies
`NoClassDefFoundError` is caught
- [x] New unit test `testClassNotFoundExceptionHandling()` verifies existing
behavior preserved
- [x] All 8 tests in `PackageBasedActionConfigBuilderTest` pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 996082)
Remaining Estimate: 0h
Time Spent: 10m
> Convention plugin fails with NoClassDefFoundError when scanning classes with
> missing dependencies
> -------------------------------------------------------------------------------------------------
>
> Key: WW-5593
> URL: https://issues.apache.org/jira/browse/WW-5593
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Convention
> Reporter: Lukasz Lenart
> Priority: Major
> Fix For: 7.2.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The convention plugin's {{PackageBasedActionConfigBuilder}} catches only
> {{ClassNotFoundException}} but not {{NoClassDefFoundError}} when testing
> action class candidates. This causes complete application startup failures
> instead of graceful degradation when classes have missing optional
> dependencies.
> *Impact*:
> - Application fails to start when convention plugin encounters classes with
> unavailable dependencies
> - Particularly affects users setting struts.convention.action.includeJars
> - Common during redeployment or with optional dependencies (e.g., JUnit for
> test classes)
> *Current behavior* (PackageBasedActionConfigBuilder.java:664):
> {code:java}
> } catch (ClassNotFoundException ex) {
> LOG.error("Unable to load class [{}]", classInfo.getName(), ex);
> return false;
> }
> {code}
> *Expected behavior*:
> Should also catch NoClassDefFoundError, following the pattern used in
> DefaultClassFinder and other Struts core classes (DefaultInterceptorFactory,
> XmlDocConfigurationProvider).
> *Proposed fix*:
> {code:java}
> } catch (ClassNotFoundException | NoClassDefFoundError ex) {
> LOG.error("Unable to load class [{}]. Perhaps it exists but certain
> dependencies are not available?",
> classInfo.getName(), ex);
> return false;
> }
> {code}
> *Reproduction*:
> 1. Use convention plugin with struts.convention.action.includeJars configured
> 2. Deploy application without JUnit dependency at runtime
> 3. Convention plugin attempts to scan org.apache.struts2.XWorkTestCase
> 4. Application fails with NoClassDefFoundError instead of logging and
> continuing
> *Related classes*:
> - PackageBasedActionConfigBuilder.java (line 664)
> - DefaultClassFinder.java (correct pattern at line 283-286)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)