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

Explicitly deregister JDBC driver #181

Merged
merged 2 commits into from
Jul 3, 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
20 changes: 6 additions & 14 deletions klass-forvaltning/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<!-- Potential cause of DPMETA-287 -->
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
mmwinther marked this conversation as resolved.
Show resolved Hide resolved
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<!-- Potential cause of DPMETA-287 -->
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>

<!--VAADIN-->
Expand Down Expand Up @@ -198,6 +184,12 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,43 @@
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Import;

// CHECKSTYLE:OFF
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;


@SpringBootApplication
@Import(EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat.class)
public class KlassForvaltningApplication extends SpringBootServletInitializer {
// TODO kmgv if using embedded container (e.g. Tomcat) remove below method and extends SpringBootServletInitializer

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(KlassForvaltningApplication.class);
}

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.addListener(new ServletContextListener() {

@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
// Nothing to do here
}

@Override
public void contextDestroyed(ServletContextEvent sce) {
// Explicitly deregister the driver to prevent race conditions with Tomcat de-registering the Driver.
// This is fixed in Spring Boot versions >=2.3.0
// Ref https://github.com/spring-projects/spring-boot/issues/21221
org.mariadb.jdbc.Driver.unloadDriver();
}
});
super.onStartup(servletContext);
}


public static void main(String[] args) {
SpringApplication.run(KlassForvaltningApplication.class, args);
}
}
// CHECKSTYLE:ON
Loading