Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue related to javafx #1180

Closed
starsareintherose opened this issue Feb 25, 2025 · 9 comments
Closed

Issue related to javafx #1180

starsareintherose opened this issue Feb 25, 2025 · 9 comments

Comments

@starsareintherose
Copy link

I use the complied version from bioarchlinux maintained by me and @sukanka

But I found when I install some pkgs from beast2 beauti package management, for example, model_selection.

Then I run the command

 beast2-applauncher PathSampler -model1 100.xml -nrOfSteps 33 -rootdir test -chainLength 3000000 -alpha 0.3
Loading package SNAPP v1.6.1 BEAST.app v2.7.7 MM v1.2.1 starbeast2 v1.0.0 snapper v1.1.4 SA v2.1.1 starbeast3 v1.1.9 BEASTLabs v2.0.2 BEAST.base v2.7.7 ORC v1.2.0 MODEL_SELECTION v1.6.2 bModelTest v1.3.3
About to invoke modelselection.app.tools.PathSampler public static void modelselection.app.tools.PathSampler.main(java.lang.String[]) throws java.lang.Exception
Args:[-model1, 100.xml, -nrOfSteps, 33, -rootdir, test, -chainLength, 3000000, -alpha, 0.3]
Alignment(snapp_new)
  73 taxa
  765 sites
  763 patterns
...
4 taxa
501 sites
433 patterns
Log Likelihood Correction = -6534.657983452196
===============================================================================
Citations for this model:

Bouckaert, Remco, Timothy G. Vaughan, Joëlle Barido-Sottani, Sebastián Duchêne, Mathieu Fourment,
Alexandra Gavryushkina, Joseph Heled, Graham Jones, Denise Kühnert, Nicola De Maio, Michael Matschiner,
Fábio K. Mendes, Nicola F. Müller, Huw A. Ogilvie, Louis du Plessis, Alex Popinga, Andrew Rambaut,
David Rasmussen, Igor Siveroni, Marc A. Suchard, Chieh-Hsi Wu, Dong Xie, Chi Zhang, Tanja Stadler,
Alexei J. Drummond
  BEAST 2.5: An advanced software platform for Bayesian evolutionary analysis.
  PLoS computational biology 15, no. 4 (2019): e1006650.

M Stolz, B Baumer, R Bouckaert, C Fox, G Hiscott, D Bryant, Bayesian Inference of Species Trees using Diffusion Models, Systematic Biology, 2021

===============================================================================
Loading package SNAPP v1.6.1
Loading package BEAST.app v2.7.7
Loading package MM v1.2.1
Loading package starbeast2 v1.0.0
Loading package snapper v1.1.4
Loading package SA v2.1.1
Loading package starbeast3 v1.1.9
Loading package BEASTLabs v2.0.2
Loading package BEAST.base v2.7.7
Loading package ORC v1.2.0
Loading package MODEL_SELECTION v1.6.2
Loading package bModelTest v1.3.3
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at beastfx.app.tools.AppLauncher.runAppFromCMD(Unknown Source)
        at beastfx.app.tools.AppLauncher.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at beast.pkgmgmt.launcher.BeastLauncher.run(Unknown Source)
        at beast.pkgmgmt.launcher.AppLauncherLauncher.main(Unknown Source)
Caused by: java.lang.StringIndexOutOfBoundsException: Range [0, -1) out of bounds for length 0
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
        at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
        at java.base/java.lang.AbstractStringBuilder.substring(AbstractStringBuilder.java:1093)
        at java.base/java.lang.StringBuilder.substring(StringBuilder.java:91)
        at modelselection.inference.PathSampler.sanitise(Unknown Source)
        at modelselection.inference.PathSampler.getCommand(Unknown Source)
        at modelselection.inference.PathSampler.run(Unknown Source)
        at beastfx.app.tools.Application.<init>(Unknown Source)
        at beastfx.app.tools.Application.<init>(Unknown Source)
        at modelselection.app.tools.PathSampler.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 7 more

Is that the problem that we compiled beast2 using java 23 openjfx etc?

@rbouckaert
Copy link
Member

From the error message, it does not look like a JavaFX problem. Judging from the code, I think it appears to be looking for the path separator character, but finds an empty string. What OS are you running this on?

@starsareintherose
Copy link
Author

Hello I run on archlinux, a linux distribution

@starsareintherose
Copy link
Author

starsareintherose commented Feb 25, 2025

I'm even thinking, because we use the shared library, our de facto command is

 java -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp /usr/share/beast2/lib/launcher.jar --module-path :/usr/lib/jvm/default/lib/javafx.controls.jar:/usr/lib/jvm/default/lib/javafx.fxml.jar:/usr/lib/jvm/default/lib/javafx.graphics.jar:/usr/lib/jvm/default/lib/javafx.base.jar:/usr/lib/jvm/default/lib/javafx.web.jar:/usr/lib/jvm/default/lib/javafx.media.jar:/usr/lib/jvm/default/lib/javafx.swing.jar --add-modules javafx.controls,javafx.fxml,javafx.web,javafx.media,javafx.swing  beast.pkgmgmt.launcher.AppLauncherLauncher PathSampler -model1 100.xml

but the official compiled package would be like this (I replace the path to our jar etc)

java -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp /usr/share/beast2/lib/launcher.jar beast.pkgmgmt.launcher.AppLauncherLauncher PathSampler -model1 100.xml

if we run the official command, it will report error, that's why we add some additional arg

java -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp /usr/share/beast2/lib/launcher.jar beast.pkgmgmt.launcher.AppLauncherLauncher PathSampler -model1 100.xml
Loading package SNAPP v1.6.1 BEAST.app v2.7.7 snapper v1.1.4 BEASTLabs v2.0.2 BEAST.base v2.7.7 MODEL_SELECTION v1.6.2
About to invoke modelselection.app.tools.PathSampler public static void modelselection.app.tools.PathSampler.main(java.lang.String[]) throws java.lang.Exception
Args:[-model1, 100.xml]
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at beastfx.app.tools.AppLauncher.runAppFromCMD(Unknown Source)
        at beastfx.app.tools.AppLauncher.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at beast.pkgmgmt.launcher.BeastLauncher.run(Unknown Source)
        at beast.pkgmgmt.launcher.AppLauncherLauncher.main(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: beastfx.app.tools.Application
        at beast.pkgmgmt.MultiParentURLClassLoader.loadClass(Unknown Source)
        at modelselection.app.tools.PathSampler.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 7 more

Even I change the parameter

+ /usr/lib/jvm/default/bin/java -Dlauncher.wait.for.exit=true -Xms256m -Xmx8g -Duser.language=en '-Djava.library.path=":"' -cp /usr/share/beast2/lib/beagle.jar:/usr/share/beast2/lib/launcher.jar --module-path :/usr/lib/jvm/default/lib/javafx.controls.jar:/usr/lib/jvm/default/lib/javafx.fxml.jar:/usr/lib/jvm/default/lib/javafx.graphics.jar:/usr/lib/jvm/default/lib/javafx.base.jar:/usr/lib/jvm/default/lib/javafx.web.jar:/usr/lib/jvm/default/lib/javafx.media.jar:/usr/lib/jvm/default/lib/javafx.swing.jar --add-modules javafx.web,javafx.media,javafx.swing beast.pkgmgmt.launcher.AppLauncherLauncher PathSampler -model1 100.xml -nrOfSteps 33 -rootdir test3 -chainLength 3000000 -alpha 0.3
Loading package SNAPP v1.6.1 BEAST.app v2.7.7 snapper v1.1.4 BEASTLabs v2.0.2 BEAST.base v2.7.7 MODEL_SELECTION v1.6.2
About to invoke modelselection.app.tools.PathSampler public static void modelselection.app.tools.PathSampler.main(java.lang.String[]) throws java.lang.Exception
Args:[-model1, 100.xml, -nrOfSteps, 33, -rootdir, test3, -chainLength, 3000000, -alpha, 0.3]
Alignment(snapp_new)
  73 taxa
  765 sites
  763 patterns

novaehollandiae: 765 121
sp_Coolah: 765 5
sp_MtKaputar: 765 11
richmondiana: 765 13
Data(snapper.snapp_new)
  4 taxa
  765 sites
  307 patterns

Loading package SNAPP v1.6.1
Loading package BEAST.app v2.7.7
Loading package snapper v1.1.4
Loading package BEASTLabs v2.0.2
Loading package BEAST.base v2.7.7
Loading package MODEL_SELECTION v1.6.2
/root/Thersites/snapper/new/100/test3/step0/run.sh
java.lang.ClassNotFoundException: beastfx.app.beast.BeastMain
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:595)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:578)
        at java.base/java.lang.Class.forName(Class.java:557)
        at beast.pkgmgmt.BEASTClassLoader.forName(Unknown Source)
        at beast.pkgmgmt.launcher.BeastLauncher.run(Unknown Source)
        at beast.pkgmgmt.launcher.BeastLauncher.main(Unknown Source)
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at beastfx.app.tools.AppLauncher.runAppFromCMD(Unknown Source)
        at beastfx.app.tools.AppLauncher.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at beast.pkgmgmt.launcher.BeastLauncher.run(Unknown Source)
        at beast.pkgmgmt.launcher.AppLauncherLauncher.main(Unknown Source)
Caused by: java.io.FileNotFoundException: /root/snapper/new/100/test3/step0/beast.xml.state (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:159)
        at modelselection.inference.PathSampler.copyStateFile(Unknown Source)
        at modelselection.inference.PathSampler.doRuns(Unknown Source)
        at modelselection.inference.PathSampler.run(Unknown Source)
        at beastfx.app.tools.Application.<init>(Unknown Source)
        at beastfx.app.tools.Application.<init>(Unknown Source)
        at modelselection.app.tools.PathSampler.main(Unknown Source)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        ... 7 more

If I add -doNotRun true, it won't give error report

@rbouckaert
Copy link
Member

Archlinux should return ":" as path separator. It maybe something to do with the actual XML: for path sampling in the /root/Thersites/snapper/new/100/test3/step0/ directory there should be a beast.xml file. Do you see any log files there (in particular likelihood.log)? If not, if you change to that directory, can you run it using beast beast.xml (I assume you can run beast with the torturous module related extra options, or that failing a s well)?

Some unrelated question: are you performing a species delimitation analysis? If so, have you considered using speedemon instead? It usually is less painful than doing path sampling analysis (see blog post).

@starsareintherose
Copy link
Author

I somewhat know why, it is supposed to run the beast2 after generating these heaps of beast.xml files and folders. But it only use default path, however, we may use different path, that's why?

@rbouckaert
Copy link
Member

Perhaps this is the reason: for path sampling, each step directory has a script for running beast2.
By using applauncher PathSampler, a default script is used, which relies on the default JDK bundled with the release to be available.
If you want to use a custom script, the XML needs to be edited by replacing the run element with the mcmc element, and wrapping the mcmc element in a run element that looks like so:

<run spec='modelselection.inference.PathSampler' nrOfSteps="33" chainLength="100000" alpha='0.3' rootdir='/root/Thersites/snapper/new/100/test3' burnInPercentage='80' preBurnin="50000" deleteOldLogs='true'>
cd $(dir)
$(java) -cp $(java.class.path) beast.pkgmgmt.launcher.BeastLauncher $(resume/overwrite) -seed $(seed) beast.xml

  <mcmc chainLength="10000000" id="mcmc" spec="MCMC">

Note that the script here has various parts replaced (everything of the form $(xyz)). For your setup, the module related bits need to be added. Hope this helps.

@starsareintherose
Copy link
Author

Yeah, thanks, that's all reasons I believed.

Some unrelated words: thanks for your recommendation for another pkg, for our dataset… runing 48 steps path sampler to test 3 prior each model hypothesis is quite heavily computing tasks. 3 million nchain will run about 12h using beast.

But for speedemon we don't have any prior, Epsilon is quite hard to estimate, I guess bayesian factor is not suitable for our current dataset based on limited knowledge and computing resources

@rbouckaert
Copy link
Member

Glad to hear that fixed the problem.

For epsilon, the blog post has a section on "Selecting the threshold ε", which may be useful for your analysis.

@starsareintherose
Copy link
Author

Thanks for your response, I now close the issue

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

No branches or pull requests

2 participants