简体   繁体   中英

java.lang.NoClassDefFoundError while trying to run PGDSpider

I am trying to run the bioinformatics software PGDSpider . Installation instructions are pretty straightforward:

  1. Installing the Java7 RE.
  2. Downloading the PGDSpider application.
  3. Executing the command bash./PGDSpider2.sh .

However when I try to execute the program an error appears related to Java that I don't quite understand:

luis@luis-Inspiron-5570:PGDSpider_2.1.1.5$ bash PGDSpider2.sh
java.lang.NoClassDefFoundError: org/w3c/dom/ls/DocumentLS
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:861)
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:773)
    at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:901)
    at ch.unibe.iee.cmpg.pgdspider.PGDSpider.main(PGDSpider.java:17)
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ls.DocumentLS
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 15 more

I am working on Ubuntu 20.04 and have the following version of Java:

(bioinfo) luis@luis-Inspiron-5570:PGDSpider_2.1.1.5$ java -version
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7-Ubuntu-1ubuntu1)
OpenJDK 64-Bit Server VM (build 14.0.1+7-Ubuntu-1ubuntu1, mixed mode, sharing)

Any help will be pretty much appreciated.

I'm not familiar with PGDSpider, so you're going to have to do some fiddling about in the PGDSpider2.sh script, but you should see a line that reads something akin to:

java PGDSpider2.jar

That line should be changed to the following:

java --add-modules java.se.ee -jar PGDSpider2.jar

Again, my fix may not be perfect, so feel free to add comments which might provide more insight (such as the exact text of PGDSpider2.sh ). The latest versions of Java SDK no longer include certain Java EE modules by default, and it looks like your tool was built when those modules were included. The strategy here is just to make them available again.

Error was solved by following the next steps:

  1. Downgrading Java to Java 8:

sudo apt-get install openjdk-8-jre

  1. Manually switching to this older version of java:
(bioinfo) luis@luis-Inspiron-5570:PGDSpider_2.1.1.5$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-14-openjdk-amd64/bin/java      1411      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-14-openjdk-amd64/bin/java      1411      manual mode
  3            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 3

  1. Executing PGDSpider2 script

bash PGDSpider2.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM