Skip to main content

Spring Bean Injection Not Enrolled Student

Symptom

Application startup fails with BeanCreationException or an autowiring error around NotEnrolledStudentRepository or a closely related service.

The original April 5, 2026 incident record is incomplete: it preserved only a screenshot, not the full stack trace or the follow-up fix commit.

What Is Confirmed

  • the failure happened at Spring context refresh time, not during a later request;
  • NotEnrolledStudentRepository was part of the missing dependency chain in the screenshot;
  • the incident happened before the current backend monolith structure settled.

The current repo no longer contains NotEnrolledStudentRepository, so this page documents the failure pattern and diagnostic path rather than a live module contract.

Likely Causes

  • missing @Repository, @Component, or Spring Data interface inheritance on a newly added repository;
  • package placement outside the application's component scan or repository scan;
  • a circular dependency introduced while wiring a new domain service;
  • multiple bean candidates with no @Qualifier or @Primary.

Diagnosis

When this class of failure appears, check in this order:

  1. Does the repository interface extend the expected Spring Data base interface or carry the right stereotype annotation?
  2. Is the package inside the active @SpringBootApplication and @EnableJpaRepositories scan path?
  3. Does the stack trace show a dependency cycle rather than a simple missing bean?
  4. Are there multiple beans of the same type competing for injection?

Because the historical record is incomplete, do not assume the root cause was annotation drift. Reconstruct the exact bean-creation chain from logs before changing code.

Fix

  • add the missing stereotype or repository inheritance;
  • move or rescan the package;
  • break circular dependencies by restoring one-way layer boundaries;
  • resolve bean ambiguity with @Qualifier or @Primary only when multiple beans are genuinely intentional.

Prevention

  • Keep full stack traces, not just screenshots, for Spring boot failures.
  • Add a context-load test for any module that introduces a new repository or service graph.
  • Treat startup-time bean failures as fast feedback: they are cheaper to fix than partially working runtime wiring.

Source Incident Detail

The April 5, 2026 source record is intentionally cautious: the exact stack trace was not preserved, so the root cause cannot be stated as fact. The useful retained value is the diagnostic shape for a missing NotEnrolledStudentRepository bean.

DetailValue
Affected areaSpring bean creation for a repository/service graph
Evidence qualitypartial; likely screenshot-based
Confirmed symptomstartup-time missing bean or injection failure
Not confirmedexact annotation, scan path, or circular-dependency root cause
Durable lessonkeep complete stack traces for Spring boot failures

When reconstructing a similar failure, separate these cases before editing code:

CaseEvidence
missing repository stereotype or inheritancerepository interface is not a Spring Data repository bean
package scan missrepository package is outside application/repository scan boundaries
circular dependencystack trace shows a dependency cycle rather than a missing candidate
bean ambiguitymultiple candidates exist but injection lacks a qualifier

Do not treat this historical page as proof that the original fix was annotation-only. It is a runbook for reconstructing the evidence correctly next time.