-
Notifications
You must be signed in to change notification settings - Fork 119
Description
Describe the bug
The test ee/jakarta/tck/persistence/ee/packaging/web/scope/ClientTest describes how the application should be deployed:
@TargetContainer("tck-javatest")
@OverProtocol("javatest")
@Deployment(name = "jpa_ee_packaging_web_scope", order = 2)
public static WebArchive createDeployment(@ArquillianResource TestArchiveProcessor archiveProcessor) {
// War
WebArchive jpa_ee_packaging_web_scope_web =
ShrinkWrap.create(WebArchive.class, "jpa_ee_packaging_web_scope_web.war");
// Classes
jpa_ee_packaging_web_scope_web.addClasses(
ee.jakarta.tck.persistence.ee.util.Data.class,
ee.jakarta.tck.persistence.ee.util.HttpTCKServlet.class,
ee.jakarta.tck.persistence.ee.packaging.web.scope.ServletTest.class,
ee.jakarta.tck.persistence.ee.common.Account.class
);
// web.xml
URL warResURL = Client.class.getResource(
"/ee/jakarta/tck/persistence/ee/packaging/web/scope/jpa_ee_packaging_web_scope_web.xml");
jpa_ee_packaging_web_scope_web.addAsWebInfResource(warResURL, "web.xml");
// sun-web.xml
warResURL = Client.class.getResource(
"/ee/jakarta/tck/persistence/ee/packaging/web/scope/jpa_ee_packaging_web_scope_web.war.sun-web.xml");
jpa_ee_packaging_web_scope_web.addAsWebInfResource(warResURL, "sun-web.xml");
// persistence.xml
warResURL = Client.class.getResource(
"/ee/jakarta/tck/persistence/ee/packaging/web/scope/persistence.xml");
if (warResURL != null) {
jpa_ee_packaging_web_scope_web.addAsWebResource(
warResURL, "/WEB-INF/classes/META-INF/persistence.xml");
}
// Call the archive processor
archiveProcessor.processWebArchive(jpa_ee_packaging_web_scope_web, Client.class, warResURL);
return jpa_ee_packaging_web_scope_web;
}The sun-web.xml used here contains:
<sun-web-app>
<context-root>jpa_ee_packaging_web_scope</context-root>
<class-loader delegate="true"/>
</sun-web-app>The corresponding client code uses this context root:
public static final String SERVLET_NAME = "ServletTest";
public static final String CONTEXT_ROOT = "/jpa_ee_packaging_web_scope";On GlassFish this works because sun-web.xml is a GlassFish-specific deployment descriptor that sets the context root.
However, for other Jakarta EE servers, sun-web.xml is not recognized. If the container does not understand sun-web.xml, the WAR is typically deployed with a context root derived from the WAR name, for example:
/jpa_ee_packaging_web_scope_web
As a result, Client tries to access /jpa_ee_packaging_web_scope/ServletTest, while the actually deployed servlet is available at /jpa_ee_packaging_web_scope_web/ServletTest. This causes the test to fail on non-GlassFish servers even if the JPA packaging behavior itself is correct.
Why this is a problem
sun-web.xmlis GlassFish-specific and not part of the Jakarta EE platform.- The test currently assumes all implementations will honour
sun-web.xmlfor context root configuration. - There is no standard, container-neutral descriptor for context root in a standalone WAR. Other vendors use their own descriptors or deployment options instead.
This makes the test non-portable and effectively tied to GlassFish behavior.
Suggested fix
The smallest, most portable change would be to align the client’s context root with the WAR name and stop relying on sun-web.xml:
public static final String CONTEXT_ROOT = "/jpa_ee_packaging_web_scope_web";This would allow all containers to pass the test without needing to implement or emulate support for sun-web.xml while keeping the actual packaging scenario the test is checking intact.
Environment
- TCK:
persistence-platform-tck-tests-11.0.0(and related artifacts) - Test:
ee/jakarta/tck/persistence/ee/packaging/web/scope/ClientTest - Container: non-GlassFish Jakarta EE implementation (JEUS in my case)
On this container the test fails because the context root defined only in sun-web.xml is not applied.