Skip to content

Fix NullPointerException in Mesquite headless initialization during NEXUS file upload#401

Merged
rvosa merged 3 commits intomasterfrom
copilot/fix-null-pointer-exception
Jan 13, 2026
Merged

Fix NullPointerException in Mesquite headless initialization during NEXUS file upload#401
rvosa merged 3 commits intomasterfrom
copilot/fix-null-pointer-exception

Conversation

Copy link
Contributor

Copilot AI commented Jan 13, 2026

NEXUS file uploads failed with NPE because Mesquite's HelpSearchManager.makeWindow() creates windows with null ownerModule in headless mode, and the Docker containers had an empty /usr/local/mesquite directory missing the required library files (including Apple API stubs).

Changes

Docker Configuration

  • Dockerfile: Copy treebase-core/lib to /usr/local/mesquite in runtime image
  • Dockerfile.dev: Updated to copy Mesquite library via entrypoint
  • docker/entrypoint-dev.sh: Add Mesquite library copy step at container startup

MesquiteConverter.java

  • Extract initialization into initializeMesquiteHeadless() to eliminate duplication
  • Set both headless and suppressAllWindows flags before init
  • Catch specific exceptions (NullPointerException, RuntimeException) instead of broad Exception
  • Allow graceful continuation if mesquiteTrunk is available despite init exceptions
private static void initializeMesquiteHeadless(String[] args) {
    MesquiteWindow.headless = true;
    MesquiteWindow.suppressAllWindows = true;
    
    try {
        Mesquite.main(args);
        setInitMesquite(true);
    } catch (NullPointerException | RuntimeException e) {
        handleMesquiteInitException(e);
    }
}

private static void handleMesquiteInitException(Exception e) {
    if (MesquiteTrunk.mesquiteTrunk != null) {
        LOGGER.warn("Mesquite initialization threw exception but trunk is available: " + e.getMessage());
        setInitMesquite(true);
    } else {
        throw new RuntimeException("Failed to initialize Mesquite for NEXUS parsing", e);
    }
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • getahead.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.8/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/treebase/.codeql-scratch/dbs/java/working/files-to-index17026993226710648279.list --sourceArchiveDir=/home/REDACTED/work/treebase/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/treebase/.codeql-scratch/dbs/java/trap/java vent/FocusEvent.class p/bin/grep com/apple pperCase.class grep grep -l com/apple r.class cal/bin/grep com/apple axon.class rgo/bin/grep grep (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

I try to upload a nexus file, and:

treebase-web-dev | java.lang.NullPointerException: Cannot invoke "mesquite.lib.MesquiteModule.getProject()" because "ownerModule" is null
treebase-web-dev | at mesquite.lib.MesquiteWindow.(MesquiteWindow.java:128)
treebase-web-dev | at mesquite.lib.MesquiteHTMLWindow.(MesquiteHTMLWindow.java:39)
treebase-web-dev | at mesquite.lib.MesquiteHTMLWindow.(MesquiteHTMLWindow.java:36)
treebase-web-dev | at mesquite.lib.HSWindow.(HelpSearchManager.java:1068)
treebase-web-dev | at mesquite.lib.HelpSearchManager.makeWindow(HelpSearchManager.java:44)
treebase-web-dev | at mesquite.Mesquite.init(Mesquite.java:468)
treebase-web-dev | at mesquite.Mesquite.(Mesquite.java:2033)
treebase-web-dev | at mesquite.Mesquite.main(Mesquite.java:2088)
treebase-web-dev | at org.cipres.treebase.domain.nexus.mesquite.MesquiteConverter.parseOneFile(MesquiteConverter.java:238)
treebase-web-dev | at org.cipres.treebase.service.nexus.NexusServiceMesquite.parseNexus(NexusServiceMesquite.java:179)
treebase-web-dev | at org.cipres.treebase.service.study.SubmissionServiceImpl.addNexusFile(SubmissionServiceImpl.java:680)
treebase-web-dev | at org.cipres.treebase.service.study.SubmissionServiceImpl.addNexusFilesJDBC(SubmissionServiceImpl.java:604)
treebase-web-dev | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
treebase-web-dev | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
treebase-web-dev | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
treebase-web-dev | at java.base/java.lang.reflect.Method.invoke(Method.java:569)
treebase-web-dev | at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
treebase-web-dev | at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
treebase-web-dev | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
treebase-web-dev | at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
treebase-web-dev | at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
treebase-web-dev | at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
treebase-web-dev | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
treebase-web-dev | at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:241)
treebase-web-dev | at jdk.proxy3/jdk.proxy3.$Proxy141.addNexusFilesJDBC(Unknown Source)
treebase-web-dev | at org.cipres.treebase.web.controllers.UploadFileController.onSubmit(UploadFileController.java:219)
treebase-web-dev | at org.cipres.treebase.web.compat.CancellableFormController.processFormSubmission(CancellableFormController.java:209)
treebase-web-dev | at org.cipres.treebase.web.compat.CancellableFormController.handleRequestInternal(CancellableFormController.java:112)
treebase-web-dev | at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
treebase-web-dev | at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51)
treebase-web-dev | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1072)
treebase-web-dev | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:965)
treebase-web-dev | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
treebase-web-dev | at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
treebase-web-dev | at javax.servlet.http.HttpServlet.service(HttpServlet.java:555)
treebase-web-dev | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
treebase-web-dev | at javax.servlet.http.HttpServlet.service(HttpServlet.java:623)
treebase-web-dev | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:197)
treebase-web-dev | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:142)
treebase-web-dev | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
treebase-web-dev | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:166)
treebase-web-dev | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:142)
treebase-web-de...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 13, 2026 18:50
… copying Mesquite library files to Docker

Co-authored-by: rvosa <106490+rvosa@users.noreply.github.com>
…tract common logic and use specific exception types

Co-authored-by: rvosa <106490+rvosa@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix NullPointerException during nexus file upload Fix NullPointerException in Mesquite headless initialization during NEXUS file upload Jan 13, 2026
Copilot AI requested a review from rvosa January 13, 2026 18:58
@rvosa rvosa marked this pull request as ready for review January 13, 2026 18:59
@rvosa rvosa merged commit dfce5b9 into master Jan 13, 2026
3 checks passed
@rvosa rvosa deleted the copilot/fix-null-pointer-exception branch January 13, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants