Skip to content
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
10 changes: 10 additions & 0 deletions common/src/main/java/com/genexus/xml/XMLReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
6 changes: 6 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<artifactId>commons-net</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>6.0.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
Expand Down
9 changes: 8 additions & 1 deletion java/src/main/java/com/genexus/util/GXFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down