0

I am using jetty to deploy my web application. I have changed the webdefault.xml dirAllowed parameter to false, still jetty is listing all the contexts path inside it whenever I will give IP:PORT.

<init-param>
    <param-name>dirAllowed</param-name>
    <param-value>false</param-value>
</init-param>

Thanks in advance.

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
Mohit Agrawal
  • 323
  • 4
  • 13
  • What version of Jetty are you using? I am unable to replicate this on 9.4.3 in either the webdefault.xml or by implementing it in the web.xml for a specific webapp. – Steps Apr 10 '17 at 16:23
  • @Walkerwatch I am using 9.4.3 version. Downloaded from https://repo1.maven.org/maven2/org/eclipse/jetty/jetty-home/9.4.3.v20170317/jetty-home-9.4.3.v20170317.tar.gz . I am using jetty docker image. – Mohit Agrawal Apr 11 '17 at 06:10
  • The page contains the following information : Error 404 - Not Found. No context on this server matched or handled this request. Contexts known to this server are: /UserManagement ---> o.e.j.w.WebAppContext@887af79{/UserManagement,file:///tmp/jetty/jetty-0.0.0.0-8080-UserManagement.war-_UserManagement-any-2467051063966033581.dir/webapp/,AVAILABLE}{/UserManagement.war} – Mohit Agrawal Apr 11 '17 at 07:53
  • The error you've given another issue entirely. You originally stated that you were able to deploy the web app and navigate to it's root but that the directory listing was appearing. What you indicated in your latest message is that the webapp/context is not available at all. Could you clarify what problem is happening? – Steps Apr 11 '17 at 15:11

1 Answers1

1

Don't modify the webdefault.xml directly, you have to provide your own copy of it, and specify its location in your context xml deployable ${jetty.base}/webapps/UserManagement.xml.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
                           "http://www.eclipse.org/jetty/configure_9_3.dtd">

<Configure id="testWebapp" class="org.eclipse.jetty.webapp.WebAppContext">

  <Set name="contextPath">/UserManagement</Set>
  <Set name="war">
    <Property name="jetty.webapps"/>/UserManagement.war
  </Set>

  <Set name="defaultsDescriptor">
    <Property name="jetty.base"/>/etc/mywebdefault.xml
  </Set>
</Configure>

A simpler solution is to modify your WEB-INF/web.xml in your UserManagement.war as outlined in the previous answer ...

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

Community
  • 1
  • 1
Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136