diff --git a/common/src/main/java/com/genexus/xml/XMLReader.java b/common/src/main/java/com/genexus/xml/XMLReader.java index 78ecaec37..9355bde9f 100644 --- a/common/src/main/java/com/genexus/xml/XMLReader.java +++ b/common/src/main/java/com/genexus/xml/XMLReader.java @@ -922,6 +922,16 @@ protected void finalize() { public void addSchema(String url, String schema) { url = url.replaceAll(" ", "%20"); + if (ApplicationContext.getInstance().isSpringBootApp()) + { + if (!new ClassPathResource(url.replace(".\\", "")).exists()) + { + parserConfiguration.setFeature("http://apache.org/xml/features/validation/dynamic", true); + parserConfiguration.setFeature("http://xml.org/sax/features/validation", false); + parserConfiguration.setFeature("http://apache.org/xml/features/validation/schema",false); + return; + } + } String externalSchema = schema + " " + url; parserConfiguration.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", externalSchema); diff --git a/gxspringboot/src/main/java/com/genexus/springboot/GXServletContextInitializer.java b/gxspringboot/src/main/java/com/genexus/springboot/GXServletContextInitializer.java new file mode 100644 index 000000000..96a6e9d4e --- /dev/null +++ b/gxspringboot/src/main/java/com/genexus/springboot/GXServletContextInitializer.java @@ -0,0 +1,36 @@ +package com.genexus.springboot; + +import jakarta.servlet.Servlet; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletRegistration; +import org.apache.logging.log4j.Logger; +import org.springframework.boot.web.servlet.ServletContextInitializer; +import org.springframework.core.io.ClassPathResource; + +public class GXServletContextInitializer implements ServletContextInitializer { + private static Logger log = org.apache.logging.log4j.LogManager.getLogger(GXServletContextInitializer.class); + + @Override + public void onStartup(ServletContext container) { + try { + //Add QueryViewer Servlets mappings + if (new ClassPathResource("qviewer/services/agxpl_get.class").exists()) { + ServletRegistration.Dynamic dispatcherQuery1 = container.addServlet("agxpl_get", (Servlet) Class.forName("qviewer.services.agxpl_get").getConstructor().newInstance()); + dispatcherQuery1.addMapping("/qviewer.services.agxpl_get"); + } + + if (new ClassPathResource("qviewer/services/agxpl_get_debug.class").exists()) { + ServletRegistration.Dynamic dispatcherQuery2 = container.addServlet("agxpl_get_debug", (Servlet) Class.forName("qviewer.services.agxpl_get_debug").getConstructor().newInstance()); + dispatcherQuery2.addMapping("/qviewer.services.agxpl_get_debug"); + } + + if (new ClassPathResource("qviewer/services/gxqueryviewerforsd.class").exists()) { + ServletRegistration.Dynamic dispatcherQuery3 = container.addServlet("gxqueryviewerforsd", (Servlet) Class.forName("qviewer.services.gxqueryviewerforsd").getConstructor().newInstance()); + dispatcherQuery3.addMapping("/qviewer.services.gxqueryviewerforsd"); + } + } + catch(Exception e) { + log.error("Error executing ServletContextInitializer", e); + } + } +} diff --git a/java/pom.xml b/java/pom.xml index 1d5867019..bf5832620 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -74,6 +74,12 @@ commons-net 3.9.0 + + org.springframework + spring-core + 6.0.11 + provided + javax.transaction jta diff --git a/java/src/main/java/com/genexus/util/GXFile.java b/java/src/main/java/com/genexus/util/GXFile.java index 58dd601d6..896442886 100644 --- a/java/src/main/java/com/genexus/util/GXFile.java +++ b/java/src/main/java/com/genexus/util/GXFile.java @@ -21,12 +21,14 @@ import com.genexus.common.classes.AbstractGXFile; import org.apache.logging.log4j.Logger; +import org.springframework.core.io.ClassPathResource; public class GXFile extends AbstractGXFile { private static Logger log = org.apache.logging.log4j.LogManager.getLogger(HttpContextWeb.class); private IGXFileInfo FileSource; + private String source; private int ErrCode; private String ErrDescription; private boolean ret; @@ -138,10 +140,11 @@ public void setSource(String FileName) { if (ModelContext.getModelContext() != null && ! new File(absoluteFileName).isAbsolute()) { IHttpContext webContext = ModelContext.getModelContext().getHttpContext(); - if((webContext != null) && (webContext instanceof HttpContextWeb || !webContext.getDefaultPath().isEmpty()) && !FileName.isEmpty()) { + if((webContext != null) && !webContext.getDefaultPath().isEmpty() && webContext instanceof HttpContextWeb && !FileName.isEmpty()) { absoluteFileName = ModelContext.getModelContext().getHttpContext().getDefaultPath() + File.separator + FileName; } } + source = absoluteFileName; URI uriFile = URI.create(absoluteFileName); FileSource = new GXFileInfo(new File(uriFile)); } catch(Exception e) { @@ -234,6 +237,10 @@ public boolean exists() { if (sourceSeted()) { try { resetErrors(); + if (ApplicationContext.getInstance().isSpringBootApp() && new ClassPathResource(source).exists()) + { + return true; + } return FileSource.exists(); } catch (SecurityException e) { ErrCode = 100;