[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] jetty-ant-task: ContextHandler not found
|
Hello,
I am using the *jetty-ant-task* and, for starters, would like to serve a simple file-system directory listing. No WAR here!
I use the same XML configuration file, that I successfully deployed for a Jetty stand-alone instance on localhost. It's named `code.xml`, resides in the same directory like the build file and looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="contextPath">/code</Set>
<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="resourceBase">S:/Users/me/Code</Set>
<Set name="directoriesListed">true</Set>
</New>
</Set>
</Configure>
However, when I invoke the assigned target, the server starts up, I can reach it, it lists the context, but when I follow the link to `/code` (the context) I get a `404 - not found` from Jetty.
During startup this appeared on the console (complete output below):
[jetty.run] java.lang.ClassNotFoundException: org.eclipse.jetty.server.handler.ContextHandler
For this Ant build I resolve the dependencies via the *maven-resolver-ant-task* and add the resolved artifacts to the classpath. I now will show the complete startup process, as communicated by Ant:
Executing:
"C:\Program Files\Eclipse Foundation\jdk-17.0.0.35-hotspot/bin/java" -Dfile.encoding=UTF-8 -Xmx256m -classpath "C:\Program Files (x86)\Java\jre-common\lib;C:\Users\me\.ant\lib;C:\Users\me\Java\lib" -Djava.awt.headless=true -classpath "C:\Program Files (x86)\apache-ant/lib/ant-launcher.jar" "-Dant.home=C:\Program Files (x86)\apache-ant" org.apache.tools.ant.launch.Launcher -f "build.xml" "-D-logger=org.apache.tools.ant.listener.AnsiColorLogger" -verbose
Apache Ant(TM) version 1.10.5 compiled on July 10 2018
Buildfile: C:\Users\me\Eigene Projekte\XQuery\app-bestof\test-scratches\build.xml
Detected Java version: 17 in: C:\Program Files\Eclipse Foundation\jdk-17.0.0.35-hotspot
Detected OS: Windows 10
parsing buildfile C:\Users\me\Eigene Projekte\XQuery\app-bestof\test-scratches\build.xml with URI = file:/C:/Users/me/Eigene%20Projekte/XQuery/app-bestof/test-scratches/build.xml
Project base dir set to: C:\Users\me\Eigene Projekte\XQuery\app-bestof
Build sequence for target(s) `test' is [jetty-depend, jetty-run, test]
Complete build sequence is [jetty-depend, jetty-run, test, jetty-stop, ]
jetty-depend:
parsing buildfile jar:file:/C:/Users/me/.ant/lib/maven-resolver-ant-tasks-uber.jar!/org/apache/maven/resolver/ant/antlib.xml with URI = jar:file:/C:/Users/me/.ant/lib/maven-resolver-ant-tasks-uber.jar!/org/apache/maven/resolver/ant/antlib.xml from a zip file
parsing buildfile jar:file:/C:/Program%20Files%20(x86)/apache-ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/C:/Program%20Files%20(x86)/apache-ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[mvn:resolve] Using local repository C:\Users\me\.m2\repository (enhanced)
Overriding previous definition of reference to central
Using remote repository central (https://repo1.maven.org/maven2/, default, releases)
Using remote repository Sonatype (https://oss.sonatype.org/content/repositories/releases/, default, releases)
Using remote repository basex (https://files.basex.org/maven/, default, releases)
Using remote repository apache (https://repo.maven.apache.org/maven2, default, releases)
Collecting dependencies
[mvn:resolve] Resolved Dependency Graph:
[mvn:resolve] org.eclipse.jetty:jetty-server:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:jar:5.0.2:compile
[mvn:resolve] org.eclipse.jetty:jetty-http:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-util:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-io:jar:11.0.8:compile
[mvn:resolve] org.slf4j:slf4j-api:jar:2.0.0-alpha5:compile
[mvn:resolve] org.eclipse.jetty:jetty-ant:jar:11.0.8:compile
[mvn:resolve] org.apache.ant:ant:jar:1.10.12:compile
[mvn:resolve] org.apache.ant:ant-launcher:jar:1.10.12:compile
[mvn:resolve] org.eclipse.jetty:jetty-security:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-plus:jar:11.0.8:compile
[mvn:resolve] jakarta.transaction:jakarta.transaction-api:jar:2.0.0:compile
[mvn:resolve] org.eclipse.jetty:jetty-jndi:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-webapp:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-servlet:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-xml:jar:11.0.8:compile
[mvn:resolve] org.eclipse.jetty:jetty-annotations:jar:11.0.8:compile
[mvn:resolve] jakarta.annotation:jakarta.annotation-api:jar:2.0.0:compile
[mvn:resolve] org.ow2.asm:asm:jar:9.2:compile
[mvn:resolve] org.ow2.asm:asm-commons:jar:9.2:compile
[mvn:resolve] org.ow2.asm:asm-tree:jar:9.2:compile
[mvn:resolve] org.ow2.asm:asm-analysis:jar:9.2:compile
[mvn:resolve] org.eclipse.jetty:jetty-slf4j-impl:jar:11.0.8:compile
[mvn:resolve] Resolving artifacts
[typedef] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[typedef] SLF4J: Defaulting to no-operation (NOP) logger implementation
[typedef] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
jetty-run:
[jetty.run] stopPort=9999
[jetty.run] stopKey=9999
[jetty.run] Configuring Jetty for project: ant-maven-test
[jetty.run] Setting property 'org.eclipse.jetty.LEVEL' to value 'DEBUG'
[jetty.run] 2022-02-21 14:02:42.185: Starting web application null
[jetty.run] Applying context xml file C:\Users\me\Eigene Projekte\XQuery\app-bestof\code.xml
[jetty.run] java.lang.ClassNotFoundException: org.eclipse.jetty.server.handler.ContextHandler
[jetty.run] Jetty AntTask Started
And now the server is reachable.
The build file I use is:
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="."
name="ant-maven-test"
default="test"
xmlns:mvn="antlib:org.apache.maven.resolver.ant">
<!-- Public targets -->
<target name="test"
depends="jetty-run"
description="Test target.">
</target>
<target name="jetty-run"
depends="jetty-depend"
description="Starts a Jetty instance.">
<jetty.run stopPort="9999"
stopKey="9999">
<systemProperties>
<systemProperty name="org.eclipse.jetty.LEVEL" value="DEBUG"/>
</systemProperties>
<webApp contextPath="/code" contextXml="code.xml"/>
</jetty.run>
</target>
<target name="jetty-stop"
depends="jetty-depend"
description="Stops the running Jetty instance.">
<jetty.stop stopPort="9999"
stopKey="9999"
stopWait="5"/>
</target>
<!-- Internal utility targets -->
<target name="jetty-depend">
<mvn:resolve failOnMissingAttachments="true">
<mvn:dependencies>
<mvn:dependency groupId="org.eclipse.jetty"
artifactId="jetty-server"
version="11.0.8"/>
<mvn:dependency groupId="org.eclipse.jetty"
artifactId="jetty-ant"
version="11.0.8"/>
<mvn:dependency groupId="org.eclipse.jetty"
artifactId="jetty-slf4j-impl"
version="11.0.8"/>
</mvn:dependencies>
<mvn:path refid="jetty.dependencies"
classpath="compile"/>
<!--<mvn:properties prefix="deps" scopes="compile"/>-->
</mvn:resolve>
<!-- <echoproperties prefix="deps"/> -->
<path id="jetty.classpath">
<path refid="jetty.dependencies"/>
</path>
<taskdef resource="tasks.properties"
loaderref="jetty.loader"
classpathref="jetty.classpath"/>
<typedef name="webApp"
classname="org.eclipse.jetty.ant.AntWebAppContext"
classpathref="jetty.classpath"
loaderref="jetty.loader" />
<typedef name="contextHandlers"
classname="org.eclipse.jetty.ant.types.ContextHandlers"
classpathref="jetty.classpath"
loaderref="jetty.loader" />
</target>
</project>
As an alternative I tried it with copying all the artifacts from my stand-alone (v9.x) installation into a flat structure into a `lib` directory in my project's home and I also tried one of the 9.x uber JARs. The error remains the same.
I even checked the `jetty-server-11.0.8.jar` file, the needed class is inside.
I also tried running the JVM with the `-verbose` switch, but that did show a lot of other stuff happening, but when it came to the aforementioned error, I could not identify anything referencing the error than the error-message itself.
I have run out of ideas, so I kindly ask you for help. Thank you.
--
Mit freundlichen Grüßen, All the Best, Minden jót.
Andreas Mixich