Meganizer error: Execute failed: Cannot invoke “String.length()” because “message0” is null


I encountered an error when I tried to meganize a daa file produced using Galaxy. I downloaded the daa file and the megan-map database (Feb2022) file and ran meganizer from the GUI (MEGAN 6.22.0). The program ran the annotation and then wrote the file and right at the end of writing the file it produced the following error:

Execute failed: Cannot invoke “String.length()” because “message0” is null

I also downloaded the older megan-map-Oct2019 database file, reran meganizer and got the same error.

I don’t think I’m the only one experiencing this error. Another user posted this message last night:

I ran MEGAN on my file.daa produced by diamon. I tried to use both command line and graphic modes.
When I use command line as follow:
daa-meganizer --threads 40 -i file_merged.daa -mdb megan-map-Feb2022.db
I got:
** at java.base/java.lang.System.arraycopy(Native Method)**
** at java.base/**
** at megan/**
** at megan/**
** at megan/megan.daa.DAAReferencesAnnotator.apply(**
** at megan/megan.daa.Meganize.apply(**
** at megan/**
** at megan/**

While when I used the graphic version of MEGAN, I got this error:

IOException: Cannot invoke “String.length()” because “message0” is null
Error: Execute failed: Cannot invoke “String.length()” because “message0” is null

Can anyone help me?

Is this a bug in meganizer. Please help! Many thanks in advance.

I’ve fixed the program to stop the message0” is null exception, that won’t fix the underlying cause.
The null pointer exception my be caused by an out of memory issue… Did you allow MEGAN enough memory during installation, say 16GB? If not, try editing the file MEGAN.vmoptions and setting the memory to -Xmx 16G


Thanks for the help. I downloaded the updated version (6.22.1) and tried to meganize a file again and I did not get the message() is null exception. Now it runs the whole meganizer then writes the file and at the very end it produces an error that simply states null. So as you said, the underlying error has not been solved.

Since meganizer appends a column to the original DAA file, I tried opening that and got the error message that the file had not been meganized. So whatever the program did it did not seem to get saved.

I set the memory to 16GB during the install (I had done this previously) and still got the error. The files are pretty big as I had about 9.6 million 150 bp reads but I monitored the task manager and MEGAN never used more than 13GB of memory. It seems like the problem arises right at the end of writing the file. So, what could the underlying issue be? Is it a problem that I ran Diamond on Galaxy (and downloaded the DAA files)?

I hope you can help resolve this issue as I feel like I am so close to being able to explore and visualize my data. I already mapped the classification using Kraken2, but I am hoping that MEGAN will greatly simplify the visualization process.

Thanks again (and in advance) for your help.


Hi Daniel, et al.

I have a similar issue. I’ve just downloaded the new version and using db Feb2022. Running as usually my .daa files which was working fine with your old version and I keep getting this message:

Meganizing file: /Applications/-EncycloReference/MG4_S4_L1_R1.daa
Annotating DAA file using FAST mode (accession database and first accession per line)
Error: java.sql.SQLException: Error opening connection
java.sql.SQLException: Error opening connection
Info: Finished meganizing 1 files. ERRORS: 1

I’m going to try to re-install the old version but I see other people have tried this and it’s still not working. Would you be able to assist?
Many thanks, Melissa

p.s. I’m running Mac M1 Pro chip, OS12.2.1. Cannot use older version now of Megan - file says it’s damaged (mac.os 6.11) and 6.18 or 6.16 says it’s too old for Mac OS - because “Apple can’t check for malicious software” so I believe this has fallen apart when I updated to 12.2.1 with your most recent versions…thank you for looking at this when you have the time.

Update: I have found my last version installer and re-installed (macOS 6_21_17) and can now run .daa files successfully!

Could you please make a example file available to me (e.g. send me a download link to email address) and I will run this in my debugger…

Thanks for the file. Unfortunately, I was not able to reproduce the problem.
Meganization completed without any issue…

So, I need more details: which OS are you using? How much memory did you give MEGAN (i.e., what is in the file MEGAN.vmoptions).
It would also be help to have all output messages that MEGAN produces…
It looks like MEGAN tries to write a null block to the end of the DAA file and I need to figure out where that is coming from.


Hmm, that’s unfortunate. Interestingly, I have tried to run the meganizer on two different computers. The first was a Dell Inspiron running Windows10, with 16BG RAM. At first I kept the default memory setting (8GB actually set as 8000 megabytes) during installation (MEGAN 6.22.0), but meganizer stalled out in the middle of the annotation step. So I reinstalled it and set the memory to 16GB (16000 megabytes). Meganizer then ran showing the following steps: Init, Annotation, Writing. Right at the end of the writing phase it spit out the original error message in the title of this thread.

While I was waiting for a response on the forum, I unfortunately managed to kill that computer (dumb decision, I’d rather not talk about it)! I got a new machine that is running Windows 11 with 16GB RAM. I installed MEGAN again (MEGAN 6.22.1, also 16000MB) and reran meganizer. It ran through all the steps mentioned above (Init, Annotation, Writing) and right at the end, I got the new error message that simply said null.

These were the only out messages that MEGAN produced as far as I can tell. Both came up in a faint window at the bottom of the screen that disappeared after about 1 minute. I took photos both times if you would like to see them.

I looked in the MEGAN.vmoptions file and it has the following text:

Enter one VM parameter per line

For example, to adjust the maximum memory usage to 512 MB, uncomment the following line:


To include another file, uncomment the following line:

-include-options [path to other .vmoption file]


I hope this information helps and let me know if I can provide anything else.

Thank you, I will investigate this on a windows machine…


So I have to apologize, I realized over the weekend that I was incorrect about MEGAN producing no further output than the null error message. Of course, the message window has a bunch of messages about the process. I reran meganizer and this was what was produced in the messages window:

rsion MEGAN Community Edition (version 6.22.2, built 10 Mar 2022)
Author(s) Daniel H. Huson
Copyright © 2022 Daniel H. Huson. This program comes with ABSOLUTELY NO WARRANTY.
This is free software, licensed under the terms of the GNU General Public License, Version 3.
Sources available at:
Java version: 17.0.2

Opening startup files
Loading 2,396,736
Loading ncbi.tre: 2,396,740
Executing: show window=MeganizeDAA;
Loading 8,200
Loading ec.tre: 8,204
Loading 30,875
Loading eggnog.tre: 30,986
Loading 240,103
Loading gtdb.tre: 240,107
Loading 14,242
Loading interpro2go.tre: 28,907
Loading 961
Loading seed.tre: 962
Executing: use cViewer=CARD state=false;
Executing: load mapFile=‘C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\megan-map-Feb2022.db’ mapType=MeganMapDB cName=EC;
Executing: use cViewer=EC state=true;
Executing: load mapFile=‘C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\megan-map-Feb2022.db’ mapType=MeganMapDB cName=EGGNOG;
Executing: use cViewer=EGGNOG state=true;
Executing: load mapFile=‘C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\megan-map-Feb2022.db’ mapType=MeganMapDB cName=GTDB;
Executing: use cViewer=GTDB state=true;
Executing: load mapFile=‘C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\megan-map-Feb2022.db’ mapType=MeganMapDB cName=INTERPRO2GO;
Executing: use cViewer=INTERPRO2GO state=true;
Executing: use cViewer=KEGG state=false;
Executing: load mapFile=‘C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\megan-map-Feb2022.db’ mapType=MeganMapDB cName=SEED;
Executing: use cViewer=SEED state=true;
Executing: load mapFile=‘C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\megan-map-Feb2022.db’ mapType=MeganMapDB cName=Taxonomy;
Executing: use cViewer=Taxonomy state=true;
Executing: update;
Executing: meganize daaFile='C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\Diamond_(ESO1A)_DAA_output__reverse.daa’ minScore=50.0 maxExpected=0.01 minPercentIdentity=0.0 topPercent=10.0 minSupportPercent=0.01 lcaAlgorithm=naive minComplexity=0 useIdentityFilter=false readAssignmentMode=readCount fNames=EC EGGNOG GTDB INTERPRO2GO SEED longReads=false paired=false;
Meganizing file: C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\Diamond
Annotating DAA file using FAST mode (accession database and first accession per line)
Error: null
Info: Finished meganizing 1 files. ERRORS: 1
Info: Command completed (2772s): meganize daaFile='C:\Users\Michael Foulk\Documents\Metagenomics - Mohan\DIAMOND-MEGAN Analysis\Diamond

I hope this can help you figure out what the issue may be. Thank you again for all of your efforts to help fix the problem!

Thanks for the messages. Unfortunately, nothing immediately obvious there…
As mentioned, I had no problems with your file on my Mac. I tried running the file under Windows 10 using the Parallels virtual machine on my Mac, but was not able to set that up with enough memory. Now I have setup Parallels on a bigger Mac and am now running the program in a debugger under Windows 10. If it fails with the same exception that you encountered then I might be able to figure out what is going on…

I was able to meganize your file using MEGAN CE (and also UE) under Windows 10. So, it is not a Windows-issue per se, but more probably a question of physical memory available on your machine. I emulated a Windows machine with 64 GB of memory and then ran MEGAN with an allowance of 32G.
How much memory does your machine have and how much did you allow MEGAN?


That may very well be the case. My Windows machine only has 16 GB of RAM and I set MEGAN to use 16,000 MB when doing the set up (the vmoptions files lists -Xmx16000M). So, apparently this is not enough memory to run the meganization? If that is the case, is there no hope of being able to meganize on this machine?

If my machine does not have enough memory to complete meganization, I suppose I will need to look into cloud computing options to complete the meganization step. Should be be able to meganize the files this way, would I be able to load the meganized file into MEGAN on my machine or will 16GB of memory also be problematic?

Many thanks for all your efforts to figure out the problem. I truly appreciate your repeated efforts to help out this metagenomics neophyte!

Meganization requires much more memory than then working with the files in MEGAN. So, yes, the best way to go is to meganize files on a server, e.g. using the command line tool daa-meganizer, and then to download the meganized files onto your local machine.
Another option is to run the megan-server program on your server. It can serve files over the web to MEGAN and you can thus work with your meganized DAA files without having to do download them.


Many thanks for all of your efforts to figure out my meganizing problem a couple of weeks ago. I just wanted to give you a quick update. One of my colleagues has a computer with 64GB of RAM (unbeknownst to me at the time). I was able to successfully meganize my files using this machine (running with a max of 32GB RAM usagage)!

Thanks again for your diligent efforts and also for the Diamond/Megan metagenomics pipeline. I am seeing some interesting things in my initial look at the datasets…made possible by your programs.