Hi Philipp,
java.lang.NoSuchMethodError means the method was there when compiled,
and isn't at runtime.
ServletContextHandler.contextInitialized is in the "jetty-server" jar;
ServletHandler in "jetty-servlet"
Check the classpath and make sure all the necessary jars are present and
compatible.
The code was compiled for Jetty 9.4.40.
mvn dependency:tree shows:
+- org.apache.jena:jena-fuseki-main:jar:4.1.0
| +- org.apache.jena:jena-fuseki-core:jar:4.1.0
| | +- org.eclipse.jetty:jetty-servlet:jar:9.4.40.v20210413
| | | +- org.eclipse.jetty:jetty-security:jar:9.4.40.v20210413
| | | | \- org.eclipse.jetty:jetty-server:jar:9.4.40.v20210413
| | | | \- javax.servlet:javax.servlet-api:jar:3.1.0
| | | \- org.eclipse.jetty:jetty-util-ajax:jar:9.4.40.v20210413
| | +- org.eclipse.jetty:jetty-servlets:jar:9.4.40.v20210413
| | | +- org.eclipse.jetty:jetty-continuation:jar:9.4.40.v20210413
| | | +- org.eclipse.jetty:jetty-http:jar:9.4.40.v20210413
| | | \- org.eclipse.jetty:jetty-io:jar:9.4.40.v20210413
| +- org.apache.jena:jena-fuseki-access:jar:4.1.0
| \- org.eclipse.jetty:jetty-xml:jar:9.4.40.v20210413
| \- org.eclipse.jetty:jetty-util:jar:9.4.40.v20210413
Andy
On 23/06/2021 11:48, Philipp Leeb wrote:
Hey guys,
the following code gives me a:
Exception in thread "main" java.lang.NoSuchMethodError: 'void
org.eclipse.jetty.servlet.ServletContextHandler.contextInitialized()'
at
org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:746)
at
org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextH
andler.java:379)
at
org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:
852)
at
org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandle
r.java:288)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.j
ava:73)
at
org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle
.java:169)
at org.eclipse.jetty.server.Server.start(Server.java:418)
at
org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCyc
le.java:110)
at
org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.jav
a:113)
at org.eclipse.jetty.server.Server.doStart(Server.java:382)
at
org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.j
ava:73)
at
org.apache.jena.fuseki.main.FusekiServer.start(FusekiServer.java:260)
at helper.EmbeddedDatabase.<init>(EmbeddedDatabase.java:27)
public EmbeddedDatabase(Dataset ds, String path, int port, String
logFilePath) throws IOException {
logger = MyLogger.getInstance(EmbeddedDatabase.class.getName(),
logFilePath);
fusekiServer = FusekiServer.create()
.port(port)
.add(path, ds)
.build();
fusekiServer.start();
isRunning = true;
registry = fusekiServer.getDataAccessPointRegistry();
dataset = ds;
MyLogger.logInfo(logger, "FusekiServer up and running.");
}
The error is thrown when calling fusekiServer.start(). Using version 4.1.0
of apache-jena-libs and jena-fuseki-main.
Is this a known bug? I just "copied" the code from
https://jena.apache.org/documentation/fuseki2/fuseki-embedded.html or are
the examples incomplete?
Kind regards
Phil