]
Ricardo Martin Camarero commented on WFLY-13293:
------------------------------------------------
[~flavia.rainone] [~brian.stansberry] I have been working on this trying to see other
alternatives. The summary:
* The main problem is that the UndertowDeploymentInfoService.java right now changes the
context path at the end
[
].
* So the UndertowDeploymentProcessor.java saves in the model and in the alias of the
service an incorrect context path. That's why the jboss-cli shows an incorrect value
and the root problem. In other parts of the code the context path saved in the model is
used to recover the service using the alias.
The options I have been managing are the following two:
* The first solution I thought and what it's done in the PR.
UndertowDeploymentProcessor.java just retrieves the Host service before and calculates the
correct context path which is used for everything later (alias, model info, service,...).
But there is no dependency over the host as Brian stated.
* Other option I have tried is just removing the alias for the service and use the real
name which is obtained from the deploymentUnit (it's something like
{{jboss.deployment.unit."app.war"}} or
{{jboss.deployment.subunit."app.ear"."app.war"}} depending if it's
in an ear or not). This means that several classes should also be modified, for example
[
].
With this change the service name used is the real one, not the alias. This way the
service can be the one that sets the context path in the model with the final value and it
has a dependency over the Host. This is a big change, but it seems to work OK. Test pass
at least. But I don't know if we can backport something like that (but that is another
story).
Do you like more the second option? Do I prepare another PR and see if you think that is
better?
When deploying "ROOT.war" in EAP7.x, the context root value
output through jboss-cli is not valid
-------------------------------------------------------------------------------------------------
Key: WFLY-13293
URL:
https://issues.redhat.com/browse/WFLY-13293
Project: WildFly
Issue Type: Bug
Components: Web (Undertow)
Affects Versions: 19.0.0.Final
Reporter: Ricardo Martin Camarero
Assignee: Ricardo Martin Camarero
Priority: Major
*When deploying "ROOT.war" default context-root is "/" even though i
set a specific context-root in jboss-web.xml. However, If I check resources by jboss-cli,
it seems like context-root value refers to jboss-web.xml and this value is invalid.*
ROOT.war/WEB-INF/jboss-web.xml
{code}
<jboss-web version="7.0"
xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
jboss-web_7_0.xsd">
<context-root>/hello</context-root>
</jboss-web>{code}
{code}[standalone@192.168.122.1:10090 /] deployment-info
NAME RUNTIME-NAME PERSISTENT ENABLED STATUS
ROOT.war ROOT.war true true OK
{code}
server.log
{code}
2020-03-24 10:35:56,344 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool
-- 78) WFLYUT0021: Registered web context: '/' for server
'default-server'
2020-03-24 10:35:56,354 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010:
Deployed "ROOT.war" (runtime-name : "ROOT.war")
{code}
However, If I check resource by jboss-cli, it seems like context-root value refers to
jboss-web.xml and this vaule is invalid.
{code}
[standalone@192.168.122.1:10090 /]
/deployment=ROOT.war/subsystem=undertow:read-resource(include-runtime=true)
{
"outcome" => "success",
"result" => {
"active-sessions" => 0,
"context-root" => "/hello", => this is invalid, the
real value is "/"
"expired-sessions" => 0,
"highest-session-count" => 0,
"max-active-sessions" => -1,
"rejected-sessions" => 0,
"server" => "default-server",
"session-avg-alive-time" => 0,
"session-max-alive-time" => 0,
"sessions-created" => 0,
"virtual-host" => "default-host",
"servlet" => undefined,
"websocket" => undefined
}
}
{code}
valid context-root is "/"
{code}
[hyoskim@hyoskim sophia]$ curl -v
http://192.168.122.1:8180/test.jsp
* About to connect() to 192.168.122.1 port 8180 (#0)
* Trying 192.168.122.1...
* Connected to 192.168.122.1 (192.168.122.1) port 8180 (#0)
> GET /test.jsp HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 192.168.122.1:8180
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: JSP/2.3
< Set-Cookie: JSESSIONID=_Ej56uTEuy1B0U2Oi94pcVtCNwg7ngRNr7HO7TQ7.worker1; path=/
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 6
< Date: Tue, 24 Mar 2020 01:37:53 GMT
<
hello
[hyoskim@hyoskim sophia]$ curl -v
http://192.168.122.1:8180/hello/test.jsp
* About to connect() to 192.168.122.1 port 8180 (#0)
* Trying 192.168.122.1...
* Connected to 192.168.122.1 (192.168.122.1) port 8180 (#0)
> GET /hello/test.jsp HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 192.168.122.1:8180
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Connection: keep-alive
< Content-Type: text/html;charset=UTF-8
< Content-Length: 74
< Date: Tue, 24 Mar 2020 01:37:23 GMT
<
* Connection #0 to host 192.168.122.1 left intact
<html><head><title>Error</title></head><body>/hello/test.jsp</body></html>{code}