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

MYFACES-4427: 5.0 Quarkus UberJar check multiple classloaders for XML #792

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
Expand Down Expand Up @@ -63,19 +65,20 @@ public class FacesUberJarProcessor
void uberJarServiceLoaders(BuildProducer<UberJarMergedResourceBuildItem> producer)
{
List<String> serviceFiles = List.of(
"jakarta.el.ExpressionFactory",
"jakarta.enterprise.inject.spi.Extension",
"jakarta.json.spi.JsonProvider",
"jakarta.servlet.ServletContainerInitializer",
"jakarta.websocket.ContainerProvider",
"jakarta.websocket.server.ServerEndpointConfig$Configurator",
"org.apache.myfaces.spi.AnnotationProvider",
"org.apache.myfaces.spi.InjectionProvider"
"licenses/facelets-LICENSE.txt",
"services/jakarta.el.ExpressionFactory",
"services/jakarta.enterprise.inject.spi.Extension",
"services/jakarta.json.spi.JsonProvider",
"services/jakarta.servlet.ServletContainerInitializer",
"services/jakarta.websocket.ContainerProvider",
"services/jakarta.websocket.server.ServerEndpointConfig$Configurator",
"services/org.apache.myfaces.spi.AnnotationProvider",
"services/org.apache.myfaces.spi.InjectionProvider"
);

for (String serviceFile : serviceFiles)
{
producer.produce(new UberJarMergedResourceBuildItem("META-INF/services/" + serviceFile));
producer.produce(new UberJarMergedResourceBuildItem("META-INF/" + serviceFile));
}
}

Expand Down Expand Up @@ -113,11 +116,14 @@ private void mergeAndGenerateResource(String filename,
{
XmlCombiner combiner = new XmlCombiner();
// Retrieve all instances of the specified file in the resources
List<URL> resources = Collections.list(getClass().getClassLoader().getResources(filename));
Set<URL> resources = new LinkedHashSet<>();
resources.addAll(Collections.list(getClass().getClassLoader().getResources(filename)));
resources.addAll(Collections.list(Thread.currentThread().getContextClassLoader().getResources(filename)));

// Combine each resource file found
for (URL resource : resources)
{
log.debugf("XML Combine: %s", resource);
try (InputStream is = resource.openStream())
{
combiner.combine(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

<factory>
<factory combine.children='append'>
<application-factory>org.apache.myfaces.core.extensions.quarkus.runtime.application.QuarkusApplicationFactory</application-factory>
<exception-handler-factory>org.apache.myfaces.core.extensions.quarkus.runtime.exception.QuarkusExceptionHandlerFactory</exception-handler-factory>
</factory>
Expand Down