Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] NoSuchMethodException at ResourceHandler


Alex,

Here is an example from jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/fileserver.xml
Note that whilst it is in ee10, it doesn't actually use a servlet context or any servlet stuff, as it is pure core Jetty:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">

<Configure id="FileServer" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg><Ref refid="FileServer"/></Arg>
<Set name="port">
<Property name="http.port" default="8080" />
</Set>
</New>
</Arg>
</Call>

<Set name="handler">
<New class="org.eclipse.jetty.server.handler.ResourceHandler">
<Set name="baseResourceAsString"><Property name="fileserver.baseResource" default="."/></Set>
<Set name="dirAllowed">true</Set>
<Set name="welcomeFiles">
<Array type="String"><Item>index.html</Item></Array>
</Set>
</New>
</Set>
</Configure>


On Sun, 3 Nov 2024 at 05:18, Alexander Farber via jetty-users <jetty-users@xxxxxxxxxxx> wrote:
Hi Greg and others,

> From: Greg Wilkins <gregw@xxxxxxxxxxx>
> The method in now call setBaseResourceAsString, so use name=baseResourceAsString
> Note this is a slightly strange style mixing an EE10 WebAppContext with a core ResourceHandler.   
> Typically if you are not using Servlets, just use a ContextHandler.  If you are using Servlet, then use a DefaultServlet to serve static content.

I have tried both name=baseResourceAsString and name=baseResource
and both are unfortunately reported as not found:

java.lang.NoSuchMethodException: class org.eclipse.jetty.ee10.servlet.DefaultServlet.setBaseResourceAsString(class java.lang.String)

and:

java.lang.NoSuchMethodException: class org.eclipse.jetty.ee10.servlet.DefaultServlet.setBaseResource(class java.lang.String)

However when I look at https://javadoc.jetty.org/jetty-12/org/eclipse/jetty/ee10/servlet/ResourceServlet.html
then there is "The following init parameters are supported ... baseResource"

Also I have read the "Operations Guide" and "Programming Guide" for Jetty 12
and searched "https://github.com/jetty/jetty-examples" - and unfortunately
nowhere is an explanation to find how to set up serving static files via Jetty XML.
There are only examples on embedded Jetty.

My current failing root.xml is below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://jetty.org/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.ee10.servlet.ServletContextHandler">
    <Set name="contextPath">/</Set>
    <Set name="handler">
        <New class="org.eclipse.jetty.ee10.servlet.DefaultServlet">
            <Set name="baseResourceAsString"><SystemProperty name="jetty.base"/>/../wordsbyfarber.com</Set>
            <Set name="dirAllowed">true</Set>
        </New>
    </Set>
</Configure>

Best regards
Alex
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users


--

Back to the top