NullPointerException at Hotbar.init on server startup with empty MongoDB #1

Closed
opened 2026-08-28 02:35:10 +00:00 by crypt · 1 comment
Owner

Environment

The practice server is now deployed in the Willowcrest Kubernetes cluster:

  • SportPaper 1.8.8 (built from source, Java 8)
  • MongoDB 7 running as a StatefulSet in the minecraft namespace (mongo-minecraft.minecraft.svc.cluster.local:27017, no auth)
  • Plugin v1.1.5 deployed via PLUGINS_FILE
  • HolographicDisplays 2.3.0, WorldEdit 6.1, WorldGuard 6.2 installed as dependencies
  • Legacy BungeeCord forwarding via Velocity proxy

Issue

WillowcrestPractice v1.1.5 crashes during onEnable with a NullPointerException at Hotbar.init(Hotbar.java:57). The MongoDB connection succeeds (logs show Monitor thread successfully connected to server and state=CONNECTED), but the plugin crashes immediately after during Hotbar initialization.

Stack Trace

[02:27:18 INFO]: Cluster created with settings {hosts=[mongo-minecraft.minecraft.svc.cluster.local:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[02:27:18 ERROR]: Error occurred while enabling WillowcrestPractice v1.1.5 (Is it up to date?)
java.lang.NullPointerException
	at world.willowcrest.practice.player.profile.hotbar.Hotbar.init(Hotbar.java:57) ~[?:?]
	at world.willowcrest.practice.wPractice.initManagers(wPractice.java:198) ~[?:?]
	at world.willowcrest.practice.wPractice.onEnable(wPractice.java:152) ~[?:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:320) ~[sportpaper.jar:git-SportPaper-2da4f51-P.7cbbda9-SP.6cccfd1-CB.741a1bd]
	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) ~[?:?]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:407) ~[?:?]
	at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:305) ~[?:?]
	at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:264) ~[?:?]
	at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:435) ~[?:?]
	at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:399) ~[?:?]
	at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:354) ~[?:?]
	at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:268) ~[?:?]
	at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:677) ~[?:?]
	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_312]
[02:27:18 INFO]: Opened connection [connectionId{localValue:1, serverValue:106}] to mongo-minecraft.minecraft.svc.cluster.local:27017
[02:27:18 INFO]: Monitor thread successfully connected to server with description ServerDescription{address=mongo-minecraft.minecraft.svc.cluster.local:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[7, 0, 40]}, minWireVersion=0, maxWireVersion=21, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1913608}

Analysis

  • The MongoDB connection is established successfully (the Opened connection and Monitor thread successfully connected lines come AFTER the NPE in the log, which suggests the MongoDB client is initializing asynchronously and Hotbar.init is trying to use a MongoDB-dependent object before the connection is fully ready, or the Hotbar code assumes some MongoDB query returns non-null when the database is empty).
  • The hotbar.yml config file exists and has valid content (all hotbar items defined with slots, materials, names).
  • The crash happens on every server startup, making the plugin non-functional.
  • This is a fresh MongoDB instance with no data - the practice database doesn't exist yet until the plugin creates collections.

Likely Cause

Hotbar.init(Hotbar.java:57) is probably querying MongoDB for some data (e.g., player hotbar preferences or kit configurations) and getting null back because the database is empty. The code at line 57 likely doesn't handle the null case.

How to Reproduce

  1. Start the practice server in the cluster: kubectl rollout restart statefulset/practice -n minecraft
  2. Check logs: kubectl logs -n minecraft practice-0 | grep -A5 "WillowcrestPractice"
  3. The NPE at Hotbar.init will appear

What's Working

  • MongoDB deployment is healthy and reachable from the practice pod
  • BungeeCord forwarding is configured correctly (skins should work)
  • HolographicDisplays, WorldEdit, WorldGuard all load successfully
  • The plugin DOES connect to MongoDB - the crash is in Hotbar initialization, not DB connection

Infrastructure (for reference)

  • MongoDB: mongo-minecraft.minecraft.svc.cluster.local:27017 (no auth, database name: practice)
  • The database.yml config is at /data/plugins/WillowcrestPractice/database.yml on the pod
  • Server jar: SportPaper 1.8.8 (not Paper/Spigot)
  • Java 8 (not 17/21)
## Environment The practice server is now deployed in the Willowcrest Kubernetes cluster: - **SportPaper 1.8.8** (built from source, Java 8) - **MongoDB 7** running as a StatefulSet in the `minecraft` namespace (`mongo-minecraft.minecraft.svc.cluster.local:27017`, no auth) - **Plugin v1.1.5** deployed via `PLUGINS_FILE` - **HolographicDisplays 2.3.0**, **WorldEdit 6.1**, **WorldGuard 6.2** installed as dependencies - **Legacy BungeeCord forwarding** via Velocity proxy ## Issue WillowcrestPractice v1.1.5 crashes during `onEnable` with a `NullPointerException` at `Hotbar.init(Hotbar.java:57)`. The MongoDB connection succeeds (logs show `Monitor thread successfully connected to server` and `state=CONNECTED`), but the plugin crashes immediately after during Hotbar initialization. ## Stack Trace ``` [02:27:18 INFO]: Cluster created with settings {hosts=[mongo-minecraft.minecraft.svc.cluster.local:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} [02:27:18 ERROR]: Error occurred while enabling WillowcrestPractice v1.1.5 (Is it up to date?) java.lang.NullPointerException at world.willowcrest.practice.player.profile.hotbar.Hotbar.init(Hotbar.java:57) ~[?:?] at world.willowcrest.practice.wPractice.initManagers(wPractice.java:198) ~[?:?] at world.willowcrest.practice.wPractice.onEnable(wPractice.java:152) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:320) ~[sportpaper.jar:git-SportPaper-2da4f51-P.7cbbda9-SP.6cccfd1-CB.741a1bd] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) ~[?:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:407) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:305) ~[?:?] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:264) ~[?:?] at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:435) ~[?:?] at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:399) ~[?:?] at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:354) ~[?:?] at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:268) ~[?:?] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:677) ~[?:?] at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_312] [02:27:18 INFO]: Opened connection [connectionId{localValue:1, serverValue:106}] to mongo-minecraft.minecraft.svc.cluster.local:27017 [02:27:18 INFO]: Monitor thread successfully connected to server with description ServerDescription{address=mongo-minecraft.minecraft.svc.cluster.local:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[7, 0, 40]}, minWireVersion=0, maxWireVersion=21, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1913608} ``` ## Analysis - The MongoDB connection is established successfully (the `Opened connection` and `Monitor thread successfully connected` lines come AFTER the NPE in the log, which suggests the MongoDB client is initializing asynchronously and `Hotbar.init` is trying to use a MongoDB-dependent object before the connection is fully ready, or the Hotbar code assumes some MongoDB query returns non-null when the database is empty). - The `hotbar.yml` config file exists and has valid content (all hotbar items defined with slots, materials, names). - The crash happens on every server startup, making the plugin non-functional. - This is a fresh MongoDB instance with no data - the `practice` database doesn't exist yet until the plugin creates collections. ## Likely Cause `Hotbar.init(Hotbar.java:57)` is probably querying MongoDB for some data (e.g., player hotbar preferences or kit configurations) and getting `null` back because the database is empty. The code at line 57 likely doesn't handle the null case. ## How to Reproduce 1. Start the practice server in the cluster: `kubectl rollout restart statefulset/practice -n minecraft` 2. Check logs: `kubectl logs -n minecraft practice-0 | grep -A5 "WillowcrestPractice"` 3. The NPE at `Hotbar.init` will appear ## What's Working - MongoDB deployment is healthy and reachable from the practice pod - BungeeCord forwarding is configured correctly (skins should work) - HolographicDisplays, WorldEdit, WorldGuard all load successfully - The plugin DOES connect to MongoDB - the crash is in Hotbar initialization, not DB connection ## Infrastructure (for reference) - MongoDB: `mongo-minecraft.minecraft.svc.cluster.local:27017` (no auth, database name: `practice`) - The `database.yml` config is at `/data/plugins/WillowcrestPractice/database.yml` on the pod - Server jar: SportPaper 1.8.8 (not Paper/Spigot) - Java 8 (not 17/21)
crypt closed this issue 2026-08-28 02:42:43 +00:00
Author
Owner

Fixed in v1.1.6.

Root cause: The shipped hotbar.yml had no ENABLED keys on any hotbar item. config.getBoolean(path + "ENABLED") returns false when the key is missing, so no items were added to the items map. When the dynamic content loop tried to look up MAP_SELECTION to extract the %MAP% pattern, it got null and NPE'd at .getItemStack().

Fix:

  • getBoolean(path + "ENABLED", true) — defaults to enabled when the key is missing
  • Added ENABLED: true and SLOT: 0 to MAP_SELECTION and KIT_SELECTION in hotbar.yml
  • Added a null check in the dynamic content loop as a safety net
  • Improved the catch block to log the item name and stack trace instead of silently swallowing
Fixed in [v1.1.6](https://git.willowcrest.world/crypt/minecraft-practice-pvp/releases/tag/v1.1.6). **Root cause:** The shipped `hotbar.yml` had no `ENABLED` keys on any hotbar item. `config.getBoolean(path + "ENABLED")` returns `false` when the key is missing, so no items were added to the `items` map. When the dynamic content loop tried to look up `MAP_SELECTION` to extract the `%MAP%` pattern, it got `null` and NPE'd at `.getItemStack()`. **Fix:** - `getBoolean(path + "ENABLED", true)` — defaults to enabled when the key is missing - Added `ENABLED: true` and `SLOT: 0` to `MAP_SELECTION` and `KIT_SELECTION` in `hotbar.yml` - Added a null check in the dynamic content loop as a safety net - Improved the catch block to log the item name and stack trace instead of silently swallowing
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crypt/minecraft-practice-pvp#1
No description provided.