Skip to content

Commit a0c8459

Browse files
hunterinoclaude
andcommitted
fix: Move ElasticFacade init before postFacadeInit to prevent NPE
Resolves #1 The ElasticFacade was being initialized after postFacadeInit(), which caused a NullPointerException when loading Elasticsearch entities at startup. This change moves the ElasticFacade initialization before the postFacadeInit() call in both constructor paths. This fix is based on upstream PR moqui#652. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e69f36e commit a0c8459

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

framework/src/main/groovy/org/moqui/impl/context/ExecutionContextFactoryImpl.groovy

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,16 @@ class ExecutionContextFactoryImpl implements ExecutionContextFactory {
244244
screenFacade = new ScreenFacadeImpl(this)
245245
logger.info("Screen Facade initialized")
246246

247-
postFacadeInit()
248-
249-
// NOTE: ElasticFacade init after postFacadeInit() so finds embedded from moqui-elasticsearch if present, can move up once moqui-elasticsearch deprecated
247+
/**
248+
* NOTE: Moved ElasticFacade init before postFacadeInit() as the moqui-elasticsearch component is not being used.
249+
* Before this change, the ElasticFacade was initialized after the postFacadeInit() method.
250+
* Fix for hunterino/moqui#1 - NPE loading Elasticsearch entities at startup
251+
*/
250252
elasticFacade = new ElasticFacadeImpl(this)
251253
logger.info("Elastic Facade initialized")
252254

255+
postFacadeInit()
256+
253257
logger.info("Execution Context Factory initialized in ${(System.currentTimeMillis() - initStartTime)/1000} seconds")
254258
}
255259

@@ -310,12 +314,16 @@ class ExecutionContextFactoryImpl implements ExecutionContextFactory {
310314
screenFacade = new ScreenFacadeImpl(this)
311315
logger.info("Screen Facade initialized")
312316

313-
postFacadeInit()
314-
315-
// NOTE: ElasticFacade init after postFacadeInit() so finds embedded from moqui-elasticsearch if present, can move up once moqui-elasticsearch deprecated
317+
/**
318+
* NOTE: Moved ElasticFacade init before postFacadeInit() as the moqui-elasticsearch component is not being used.
319+
* Before this change, the ElasticFacade was initialized after the postFacadeInit() method.
320+
* Fix for hunterino/moqui#1 - NPE loading Elasticsearch entities at startup
321+
*/
316322
elasticFacade = new ElasticFacadeImpl(this)
317323
logger.info("Elastic Facade initialized")
318324

325+
postFacadeInit()
326+
319327
logger.info("Execution Context Factory initialized in ${(System.currentTimeMillis() - initStartTime)/1000} seconds")
320328
}
321329

0 commit comments

Comments
 (0)