« 運用18年目のまとめ | トップページ | java.util.Date との決別 »

2026年9月18日 (金)

OpenDolphin: Java 25 / WildFly 41 への移行

これまで wildfly 38 で運用していたが、wildfly 41 への移行した。Java は 25 のままで変更なし。

wildfly 41 の準備

wildfly の github から branch 41.x を選択,"Download Zip" して解凍する。作業時点ではこれで 41.0.1.Final がダウンロードされた。

mac で wildfly 41 のビルド

brew をアップデートして mvn と ant を最新にしておく。

$ brew update ; brew upgrade

wildfly の build

$ mvn install
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/jboss/jboss-parent/51/jboss-parent-51.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/jboss/jboss-parent/51/jboss-parent-51.pom (104 kB at 402 kB/s)
Downloading from jboss-public-repository-group: https://repository.jboss.org/nexus/repository/public/io/netty/netty-bom/4.1.137.Final/netty-bom-4.1.137.Final.pom
Downloading from central: https://repo.maven.apache.org/maven2/io/netty/netty-bom/4.1.137.Final/netty-bom-4.1.137.Final.pom
 :
 :
[INFO] WildFly Preview: Thin Server Build ................. SUCCESS [ 16.390 s]
[INFO] WildFly Preview: Distribution ...................... SUCCESS [ 18.334 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  28:15 min
[INFO] Finished at: 2026-08-25T15:14:58+09:00
[INFO] ------------------------------------------------------------------------

これで wildfly-41.0.1.Final-SNAPSHOT ができる。full distributable build が欲しい場合は, build/target ではなく, dist/target の方を使う必要がある。

wildfly 41.0.1 のセットアップ

  • ./standalone.sh -b 0.0.0.0 で立ち上げて,./add-user.sh で管理ユーザ登録
  • JDBC の登録(ドライバは postgresql-42.7.13.jar),data-source の作成,パスワード登録。
    $ ./jboss-cli.sh --connect
    [standalone@localhost:9990 /] module add --name=org.postgres --resources=~/Downloads/postgresql-42.7.8.jar --dependencies=javax.api,javax.transaction.api
    [standalone@localhost:9990 /] /subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgres",driver-class-name=org.postgresql.Driver)
    [standalone@localhost:9990 /] data-source add --jndi-name=java:jboss/datasources/DolphinDS --name=DolphinDS --connection-url=jdbc:postgresql://localhost/dolphin --driver-name=postgres --user-name=dolphin
    [standalone@localhost:9990 /] /subsystem=datasources/data-source=DolphinDS:write-attribute(name=password, value=dolphin)
    [standalone@localhost:9990 /] quit
    

ライブラリのアップデート

WildFly 41 に合わせて、ライブラリをアップデートする。

  • Hibernate 7.4.5.Final
  • Hibernate Search 8.4.0.Final
  • Resteasy 7.0.3.Final
  • Jackson 2.22.2
  • Jackson annotations 2.22
  • Postgresql 42.7.13

書き換え内容

  • websocket のタイムアウト抑止
    standalone.xml
    <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true" read-timeout="0" write-timeout="0"/>
    
  • @SequenceGenerator に allocationSizeを指定していない場合、Hibernate はデフォルトで allocationSize=50 を使い、DB側のシーケンスのINCREMENT BYもその値(またはエンティティごとの設定値)に合わせて作成・更新しようとする。Hibernate 6 までは、この不一致をよきに計らってくれていたようだが、7 にしたところ エラーで止まってしまうようになった。
    ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 84) MSC000001: Failed to start
     :
    Caused by: org.hibernate.MappingException: The increment size of the [hibernate_sequence] sequence is set to [50] in the entity mapping but the mapped database sequence increment size is [1]
    
    当院ではずっと @GeneratedValue(strategy = GenerationType.AUTO) のまま使ってきたのであるが、遂に手を付けねばならない潮時がきたようだ。infomodel 全てから extend されている InfoModel というクラスがあったので、そこに sequenceName = hibernate_sequence, allocationSize = 1 の @SequenceGenerator をに設定し、@GeneratedValue にこの generator をセットするように書き換えた。
  • Hibernate 6 へ移行したときに、masuda 先生の ModuleModelBridge.java が動かなくなってしまって、怪しい workaround をしていた。Hibernate 5 で動いていた ModuleModelBridge の byte[] が、Hibernate 6 で byte と判定されていたのは、フィールドが byte[] だと、自動的に byte にばらして呼ばれるような仕様になっていたようだ。最新の masuda 先生のソースでは、ModuleModel ではなく、DocumentModel に DocumentRoutingBinder を付けてインデックスを作るようになっていたので、パクらせてもらった。

Opensearch インストール

  • ダウンロードサイトから tarball を取ってくる
    $ tar xvzf opensearch-3.8.0-linux-x64
    $ ln -s opensearch-3.8.0 opensearch
    
  • 初期インストールのプラグインは全部消す
    $ cd opensearch
    $ rm -rf plugins/*
    
  • プラグインインストール
    $ ./bin/opensearch-plugin install analysis-kuromoji
    $ ./bin/opensearch-plugin install analysis-icu
    
  • config/opensearch.yml を設定して起動してみる
    $ vi ./config/opensearch.yml
    cluster.name: opensearch_dolphin
    path.data: /home/dolphin/opensearch/var/lib/opensearch
    path.logs: /home/dolphin/opensearch/var/log/opensearch
    $ ./bin/opensearch
    WARNING: Using incubator modules: jdk.incubator.vector
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
     :
    
  • 今回、@FullTextField を変更したので、インデックス更新が必要。しかし、masuda 先生のコードをパクったお陰で、インデックス更新が6倍速になったので、あまり苦ではない。

wildfly 起動

2026-09-16 17:17:04,277 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly 41.0.1.Final-SNAPSHOT (WildFly Core 33.0.1.Final) started in 5769ms - Started 634 of 822 services (366 services are lazy, passive or on-demand) - Server configuration file in use: standalone.xml - Minimum feature stability level: community

WildFly アップデート記録
  • 2008年 JBossAS 4.0.5
  • 2009年 JBossAS 4.2.3
  • 2010年 JBossAS 5.1.0
  • 2013年 JBossAS 7.1.4
  • 2015年 WildFly 8.2.1
  • 2017年 WildFly 10.2.0
  • 2019年 WildFly 18.0.1
  • 2021年 WildFly 25.0.2
  • 2023年 WildFly 27.0.2
  • 2024年 WildFly 34.0.1
  • 2025年 WildFly 38.0.1
  • 2026年 WildFly 41.0.1

« 運用18年目のまとめ | トップページ | java.util.Date との決別 »

「OpenDolphin」カテゴリの記事

検索