From e7933ff0d582f578b4e64673f58d059bb96bd01e Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Mon, 12 Apr 2021 11:39:54 +0100 Subject: [PATCH] PAYARA-3691 Support reading catalog/wsdl from WEB-INF Signed-off-by: Andrew Pielage --- .../sun/xml/ws/util/xml/XmlCatalogUtil.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/util/xml/XmlCatalogUtil.java b/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/util/xml/XmlCatalogUtil.java index 20febf2f3..8eb8f34bd 100644 --- a/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/util/xml/XmlCatalogUtil.java +++ b/jaxws-ri/runtime/rt/src/main/java/com/sun/xml/ws/util/xml/XmlCatalogUtil.java @@ -15,13 +15,21 @@ import com.sun.org.apache.xml.internal.resolver.Catalog; import com.sun.org.apache.xml.internal.resolver.CatalogManager; import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver; +import com.sun.xml.ws.api.ResourceLoader; import com.sun.xml.ws.server.ServerRtException; +import com.sun.xml.ws.util.ServiceFinder; + import java.io.IOException; import java.net.URL; import java.util.Enumeration; import javax.xml.ws.WebServiceException; + import org.xml.sax.EntityResolver; +import com.sun.xml.ws.api.ResourceLoader; +import com.sun.xml.ws.server.ServerRtException; +import com.sun.xml.ws.util.ServiceFinder; + /** * * @author lukas @@ -61,11 +69,15 @@ public static EntityResolver createDefaultCatalogResolver() { manager.setIgnoreMissingProperties(true); // Using static catalog may result in to sharing of the catalog by multiple apps running in a container manager.setUseStaticCatalog(false); - // parse the catalog + + // Activates debug via system property, if set + manager.getVerbosity(); + + // Parse the catalog ClassLoader cl = Thread.currentThread().getContextClassLoader(); Catalog catalog = manager.getCatalog(); parseResourcesToCatalog(cl, catalog, "META-INF/jax-ws-catalog.xml"); - parseResourcesToCatalog(cl, catalog, "/WEB-INF/jax-ws-catalog.xml"); + parseResourcesToCatalog(catalog, "jax-ws-catalog.xml"); return workaroundCatalogResolver(catalog); } @@ -88,6 +100,19 @@ private static void parseResourcesToCatalog(ClassLoader classLoader, Catalog cat } } + private static void parseResourcesToCatalog(Catalog catalog, String resourceName) { + try { + for (ResourceLoader resourceLoader : ServiceFinder.find(ResourceLoader.class)) { + URL resource = resourceLoader.getResource(resourceName); + if (resource != null) { + catalog.parseCatalog(resourceLoader.getResource(resourceName)); + } + } + } catch (IOException e) { + throw new WebServiceException(e); + } + } + /** * Default CatalogResolver implementation is broken as it depends on * CatalogManager.getCatalog() which will always create useStaticCatalog is