1

I know this might be difficult to answer, but I have tried everything and cannot get a solution. I am trying to create a web project in Java for the first time, using Eclipse and Jetty and JSF, and everything works well until I introduce a Java class. I write in HTMl/XHTML and run the programs, but when I add a Java class - even with nothing in the class, I get the following exceptions:

java.lang.RuntimeException: Error scanning file C:\Users\****\eclipse-workspace\donationFinder\target\classes\com\testingClass\Test.class
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:783)
    at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:876)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:165)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:552)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
    at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: 
java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:986)
    at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:777)
    at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:876)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:165)
    at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:552)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
    at java.base/java.lang.Thread.run(Thread.java:835)

Does anyone know what might be causing this? Thanks in advance.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
sabraship
  • 99
  • 1
  • 8
  • So it works if you run it outside of eclipse? And there is nothing JSF related in your problem – Kukeltje Jun 09 '20 at 15:28
  • @Kukeltje how do I run it outside of eclipse? – sabraship Jun 09 '20 at 15:29
  • No Idea since I don't use jetty but a start and stop script are most likely available. The reason I ask if it does not work if you run outside eclipse, the problem is not eclipse related – Kukeltje Jun 09 '20 at 15:31
  • What are your project's Java compliance settings, and how old a release of Jetty is this? – nitind Jun 09 '20 at 15:38
  • @nitind Default compliance settings, and I downloaded the following plug-in through Eclipse: "An Eclipse plugin for running/debugging Java web applications with Jetty (successor of JettyLauncher) Features: - Support for Jetty 7, 8 and 9 (incl. 9.1.x and 9.2.x, 9.3.x, 9.4.x) - Included Jetty8 - M2Eclipse Support - JSP Support - JNDI Support - JMX Support - Websocket Support - HTTPS" – sabraship Jun 09 '20 at 15:49
  • Neither of those answers what I asked. What is the project's Java compliance set to, and which version of *Jetty* are you using? Odds are that Joakim's answer is the right one, but it's still a guess without those kinds of details. – nitind Jun 09 '20 at 15:52
  • Sorry, okay, I'm pretty sure my settings are project specific. I have "use compliance from from execution environment" selected, then "use --release option" and "use default compliance settings." Under class file generation I have "add variable attributes to generated class files," "add number line attributes," "add source file name," preserve unused local variables," and "inline finally blocks" selected. About Jetty, I don't remember ever downloading it, I only got that plugin listed above, so I'm not sure the version – sabraship Jun 09 '20 at 17:06
  • okay the version is 9.4.15.v20190215 – sabraship Jun 09 '20 at 17:25
  • 1
    That doesn't tell us *which* Execution Environment your project's compliance setting is drawing from, but Jetty releases are up to 9.4.29.v20200521 now, and that contains asm-7.3.jar, which has better odds at being able to read those class files. – nitind Jun 09 '20 at 18:50

1 Answers1

0

The version of asm you are using is too old for your JVM runtime.

For Jetty 9.4.x you should be using (at least) asm-7.1.jar if you want to scan bytecode produced for Java 8 thru Java 13.

Use asm-7.2.jar if you want to scan bytecode produced for Java 8 thru 14.

Use asm-7.3.1.jar if you want to scan bytecode produced for Java 8 thru 15.

See prior answer for details.

https://stackoverflow.com/a/26496604/775715

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • unfortunately, this didn't work (i installed asm 7.2 and then asm 8.0 and neither worked). any more suggestions? – sabraship Jun 10 '20 at 02:25
  • Jetty 9.x does not support asm 8.0 (due to an API change on asm) - if you are using Java 15 for your build then using asm 7.2 would produce the error you are seeing. – Joakim Erdfelt Jun 10 '20 at 16:34
  • oh that makes sense. thanks so much for all your help, but i can't seem to find a download for org.objectweb.asm_7.3.1. do you know where i could find it? – sabraship Jun 10 '20 at 20:33
  • Use maven (or any other build tool that supports the global java repository system). All of the mentioned ASM versions are present on the global java repository system. Bonus is that you'll also not get into these situations with bad/mismatched versions like you are struggling with. – Joakim Erdfelt Jun 11 '20 at 11:29
  • i configured my existing project to be a maven project, added the dependency for asm 7.3.1 to the pom, and successfully downloaded it, but i got the same error. should i be running the entire project through maven or something like that? i'm really stumped. sorry it's been so long – sabraship Jun 22 '20 at 19:51