eclipse-jetty / eclipse-jetty-plugin

Eclipse Jetty Plugin
https://eclipse-jetty.github.io/
47 stars 29 forks source link

Don't support Jetty 9.4.47 Java 11 and Anotation #58

Open behel33 opened 2 years ago

behel33 commented 2 years ago

If you use an external Jetty 9.4, with Java 11 and activate Anotation you get this error

2022-04-03 18:11:09.847:INFO::main: Logging initialized @227ms to org.eclipse.jetty.util.log.StdErrLog
   Configuration: C:\Users\username\AppData\Local\Temp\eclipseJettyPlugin.config.WindexServer.xml
2022-04-03 18:11:09.983:WARN:oejx.XmlConfiguration:main: Config error at <Call name="addBefore"><Arg name="addBefore" type="java.lang.String">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Arg><Arg><Array type="java.lang.String"><Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item></Array></Arg></Call> java.lang.IllegalStateException: No Method: <Call name="addBefore"><Arg name="addBefore" type="java.lang.String">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Arg><Arg><Array type="java.lang.String"><Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item></Array></Arg></Call> on class org.eclipse.jetty.webapp.Configuration$ClassList in UNKNOWN-LOCATION
2022-04-03 18:11:09.983:WARN:oejx.XmlConfiguration:main: Config error at <Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault"><Arg><Ref refid="Server"/></Arg><Call name="addBefore"><Arg name="addBefore" type="java.lang.String">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Arg><Arg><Array type="java.lang.String"><Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item></Array></Arg></Call></Call> java.lang.IllegalStateException: No Method: <Call name="addBefore"><Arg name="addBefore" type="java.lang.String">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Arg><Arg><Array type="java.lang.String"><Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item></Array></Arg></Call> on class org.eclipse.jetty.webapp.Configuration$ClassList in UNKNOWN-LOCATION
Exception in thread "main" java.lang.IllegalStateException: No Method: <Call name="addBefore"><Arg name="addBefore" type="java.lang.String">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Arg><Arg><Array type="java.lang.String"><Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item></Array></Arg></Call> on class org.eclipse.jetty.webapp.Configuration$ClassList
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:950)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:515)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:945)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:515)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:431)
    at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:364)
    at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9LauncherMain.configure(Jetty9LauncherMain.java:85)
    at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.configure(AbstractJettyLauncherMain.java:144)
    at net.sourceforge.eclipsejetty.starter.common.AbstractJettyLauncherMain.launch(AbstractJettyLauncherMain.java:75)
    at net.sourceforge.eclipsejetty.starter.jetty9.Jetty9LauncherMain.main(Jetty9LauncherMain.java:42)
Caused by: java.lang.NoSuchMethodException: addBefore
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:987)
    at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:942)
    ... 9 more

If I disable Annotation all are right ! but my code use annotation .....

uunicorn commented 2 years ago

Eclipse creates a Jetty config file, eg /tmp/eclipseJettyPlugin.config.blah.xml. This config contains an incorrect parameter name:

...
  <Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault">
    <Arg>
      <Ref refid="Server"/>
    </Arg>
    <Call name="addBefore">
      <Arg name="addBefore" type="java.lang.String">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Arg>
      <Arg>
        <Array type="java.lang.String">
          <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
        </Array>
      </Arg>
    </Call>
  </Call>
...

The <Arg name="addBefore" should be <Arg name="beforeClass". See https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/Configuration.java#L250

It was never a problem until jetty 9.4.27.v20200227, when arguments name matching was introduced: https://github.com/eclipse/jetty.project/commit/d27f4ee556a4982144f9354793c629b31399fd52

uunicorn commented 2 years ago

This should probably fix it:

diff --git a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty9/Jetty9ServerConfiguration.java b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty9/Jetty9ServerConfiguration.java
index 275eee6..d082df7 100644
--- a/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty9/Jetty9ServerConfiguration.java
+++ b/plugins/eclipse-jetty-launcher/src/main/java/net/sourceforge/eclipsejetty/jetty9/Jetty9ServerConfiguration.java
@@ -289,7 +289,7 @@ public class Jetty9ServerConfiguration extends Jetty8ServerConfiguration
             builder.argRef("Server");
             builder.beginCall("addBefore");
             {
-                builder.arg("addBefore", "org.eclipse.jetty.webapp.JettyWebXmlConfiguration");
+                builder.arg("beforeClass", "org.eclipse.jetty.webapp.JettyWebXmlConfiguration");
                 builder.argArray("org.eclipse.jetty.annotations.AnnotationConfiguration");
             }
             builder.end();
uunicorn commented 2 years ago

Duplicate of #51 and there's already an open PR #52 to fix this.