もぐらびノート

検索しても答えにたどり着けない問題を、掘り下げて解決する。
業務システム開発で、検索しても出てこない・英語の情報しかない問題を、手元で再現して確かめたうえで書いています。

LazyInitializationException(could not initialize proxy - no Session)が画面では出ないのにバッチやテストで出る理由

画面からは問題なく動いているサービスのメソッドを、夜間バッチ(とテスト)から呼んだところ、次の例外が出ました。 Spring Boot 3.x(Hibernate 6.6)のメッセージです。 ...

2026年10月15日 · 4 分 · もぐらび

@Transactional を付けたのにロールバックされない2つの原因:同じクラス内からの呼び出しとチェック例外

一括登録の処理で例外が出たのに、途中まで登録したデータがデータベースに残っていました。登録のメソッドには @Transactional を付けています。 調べると、ロールバックされない原因は2つありました。どちらもエラーは出ず、テストで例外の発生だけを確かめていると気付けません。 ...

2026年10月15日 · 4 分 · もぐらび

Spring Boot 2.6 以降で「The dependencies of some of the beans in the application context form a cycle」と出て起動しない

Spring Boot のバージョンを上げたところ、コードは何も変えていないのに、起動時に次のエラーが出るようになりました。 *************************** APPLICATION FAILED TO START *************************** Description: The dependencies of some of the beans in the application context form a cycle: ┌─────┐ | inventoryService (field private com.example.demo.OrderService com.example.demo.InventoryService.orderService) ↑ ↓ | orderService (field private com.example.demo.InventoryService com.example.demo.OrderService.inventoryService) └─────┘ Action: Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true. 結論:Spring Boot 2.6 から、Bean 同士の循環参照が既定で禁止されました。 2.5 までは Spring が自動で循環を解決していたので、昔から循環していたコードがバージョンアップで表に出ます。設定で以前の動きに戻せますが、本来は循環そのものをなくします。 ...

2026年10月15日 · 4 分 · もぐらび

Spring Boot 3 移行後に @NotBlank が効かない:javax.validation が残っているとエラーも出ずに素通りする

Spring Boot 3 へ移行した後、一部の画面だけ入力チェックが効かなくなりました。必須項目を空にして送っても、エラーにならずに登録処理まで進みます。 エラーメッセージが一切出ない のがこの問題の厄介なところです。 ...

2026年10月15日 · 4 分 · もぐらび

Spring Boot 3/4 が UnsupportedClassVersionError(class file version 61.0)で起動しない原因と確認手順

開発 PC では動く Spring Boot のアプリが、検証サーバーで java -jar すると次のエラーで起動しませんでした。 エラー: メイン・クラスorg.springframework.boot.loader.launch.JarLauncherのロード中にLinkageErrorが発生しました java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/launch/JarLauncher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 ビルドする側の Java が古いと、Maven では次のエラーになります。 ...

2026年10月15日 · 4 分 · もぐらび