jflap-lib icon indicating copy to clipboard operation
jflap-lib copied to clipboard

org/w3c/dom/ls/DocumentLS

Open drelhaj opened this issue 4 years ago • 4 comments

When I try to run the jar bundles with any FSA I always get the following error

Exception in thread "main" 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:1016) 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:521) at org.apache.xerces.jaxp.DocumentBuilderImpl.(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source) at edu.duke.cs.jflap.file.XMLCodec.decode(XMLCodec.java:59) at edu.duke.cs.jflap.file.XMLCodec.decode(XMLCodec.java:90) at es.usc.citius.jflap.cli.IO.loadAutomaton(IO.java:37) at es.usc.citius.jflap.cli.CommandLine$RunInputCommand.run(CommandLine.java:79) at es.usc.citius.jflap.cli.CommandLine$Cli.parseAndRun(CommandLine.java:136) at es.usc.citius.jflap.cli.CommandLine.main(CommandLine.java:21) 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:521) ... 17 more

drelhaj avatar Nov 25 '20 18:11 drelhaj

Any solution to this?

sbrokal1 avatar Apr 22 '22 19:04 sbrokal1

I'm running the bundle jar file wrapped in Python code see code below for testing an input and for testing equivalence for FSAs

#this method takes an input array and a jflap FSA machine
def testInput(input, machine):#input is an array e.g. input = ["abc","aabbcc"]
    from subprocess import Popen, PIPE, STDOUT
    from threading import Timer
    p = Popen(['java', '-jar', 'jflaplib-cli-1.3-bundle.jar', 'run', machine, input], stdout=PIPE, stderr=STDOUT)
    timer = Timer(10, p.kill)
    try:
        timer.start()#timeout in case of infinite loops
        for line in p.stdout:
            return line
        return 'false'
    finally:
        timer.cancel()
#check if one machine is equivalent to another
def checkEquivalence(machine1, machine2):
    from subprocess import Popen, PIPE, STDOUT
    from threading import Timer

    p = Popen(['java', '-jar', 'jflaplib-cli-1.3-bundle.jar', 'equivalent', machine1, machine2], stdout=PIPE, stderr=STDOUT)
    timer = Timer(10, p.kill)

    checkResult = ""
    try:
        timer.start()
        for line in p.stdout:
            checkResult = line
        return checkResult
    finally:
        timer.cancel()

drelhaj avatar Apr 25 '22 15:04 drelhaj

I have written a similar utility inspired by this repo, you can try it out here:

https://github.com/ushahid/jflap-cli

ushahid avatar Apr 15 '23 20:04 ushahid

Quick Fix

If you're using Gradle (solution is similar for Maven, see related reading) you can address this issue by overriding the xerces:xercesImpl used in your project. The version used in this project is rather old, and it appears there are some issues using it today. If you need to shell out to the JAR, you could try forking and modifying this project replacing the dependency.

dependencies {
    // ...
    implementation("com.github.citiususc:jflap-lib:1.3") {
        exclude(group = "xerces", module = "xercesImpl")
    }
    implementation("xerces:xercesImpl:2.12.2")
    // ...
}

Related Reading

Here is a related issue: https://stackoverflow.com/questions/62006284/noclassdeffounderror-org-w3c-dom-ls-documentls-issue-occurring-only-on-deploy

DylanLukes avatar Aug 05 '24 01:08 DylanLukes