Skip to content

Commit

Permalink
MYFACES-4427: 5.0 Quarkus UberJar check multiple classloaders for XML (
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Oct 29, 2024
1 parent b887261 commit 0b937b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
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

0 comments on commit 0b937b4

Please sign in to comment.