Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

welcome-file ignored on jetty12ee10 on exploded deploy, works on ee9 and older jettys. #10141

Closed
andresluuk opened this issue Jul 25, 2023 · 6 comments
Labels
Bug For general bugs on Jetty side

Comments

@andresluuk
Copy link

andresluuk commented Jul 25, 2023

Jetty version(s)
jetty12ee10 built from latest source.
Java version/vendor (use: java -version)
JDK17
OS type/version
Windows/Unix
Description
Maybe the same issue as described under #10139 ?
How to reproduce?
Anyway I have a simple webapp with the following web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
	      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	version="2.4">

	<context-param>
		<param-name>org.eclipse.jetty.servlet.Default.welcomeServlets</param-name>
		<param-value>true</param-value>
	</context-param>

	<servlet>
		<servlet-name>myServlet</servlet-name>
		<servlet-class>test.MyServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>myServlet</servlet-name>
		<url-pattern>/myServlet</url-pattern>
	</servlet-mapping>

	<welcome-file-list>
		<welcome-file>myServlet</welcome-file>
	</welcome-file-list>
</web-app>

If I deploy the application as packaged application on jetty12ee10 then it works and MyServlet is hit.
But If I deploy it as exploded application then I will get the directory listing from the webapp root.
The same application for jett12ee9 it works in both modes.

The request made looks like that:
http://localhost:8080/exp-http-welcomeServlet/?foo=bar&1801

@andresluuk andresluuk added the Bug For general bugs on Jetty side label Jul 25, 2023
@joakime
Copy link
Contributor

joakime commented Jul 25, 2023

The following XML context-param configuration is not used in ee10. (it is used, however, in ee8/ee9)

	<context-param>
		<param-name>org.eclipse.jetty.servlet.Default.welcomeServlets</param-name>
		<param-value>true</param-value>
	</context-param>

Instead you would need to configure the DefaultServlet properly with init-params.

Eg:

  <servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.eclipse.jetty.ee10.servlet.DefaultServlet</servlet-class>
    <init-param>
      <param-name>welcomeServlets</param-name>
      <param-value>true</param-value>
    </init-param>
  </servlet>

@andresluuk
Copy link
Author

Thanks.
I tryed it out, you are right it works with that servlet.

I am a little sad that the new servlet, will fail with other servers, but I can work around that.

@andresluuk
Copy link
Author

Okei, I got one more question here. The explanation you gave, is about the parameter not beeing used. But why does it work on packaged mode? and the issue arrises only on exploded deploy.

@andresluuk andresluuk reopened this Jul 25, 2023
@andresluuk
Copy link
Author

Ok my mistake here. I did not actually run it in packaged mode. so no more questions here.

joakime added a commit that referenced this issue Jul 25, 2023
….jetty.servlet.Default.` prefix for ee10

+ Fix named servlet lookup NPE in ee10 ServletHandler.getMappedServlet
@joakime joakime reopened this Jul 25, 2023
@joakime
Copy link
Contributor

joakime commented Jul 25, 2023

I'm reintroducing org.eclipse.jetty.servlet.Default. prefix support for ee10 in PR #10149

Can you please test it out with your examples too.

@andresluuk
Copy link
Author

I can confirm that this worked when I used jetty built from the PR.

joakime added a commit that referenced this issue Jul 26, 2023
….jetty.servlet.Default.` prefix for ee10 (#10149)

+ Issue #10141 and #10142 - Reintroduce context init-param `org.eclipse.jetty.servlet.Default.` prefix for ee10
+ Fix named servlet lookup NPE in ee10 ServletHandler.getMappedServlet
+ Adding requested javadoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

2 participants