Unable to retrieve javax.websocket.server.ServerContainer from ServletContext in Spring Boot (Tomcat application) - spring-boot

I have a spring boot application using spring-boot-starter-tomcat. I am trying to add a custom websocket endpoint in the application class.
To do this, I am trying to retrieve the ServerContainer with following:
ServerContainer container = (ServerContainer)servletContext.getAttribute(ServerContainer.class.getName());
However, the container is null, even though the tomcat server seems to come up in the spring boot application.
Is there any way to initialize the javax.websocket.server.ServerContainer in a spring boot application?

Related

Is there a way I can integrate the spring boot application jar to another servlet application?

I have created a spring boot application with a few endpoints and want to make that endpoint to the existing servlet application without deploying it separately. So I want to create a jar from the spring boot app and use that jar in the servlet project. How can this be done? Any suggestion would be really helpful.

How to Refresh Spring Boot Configuration Info with Using Spring Cloud Config

I would like to ask how to refresh spring boot configuration info with using spring cloud config. Would you please give me some advice? Many thanks.
If your spring boot application is a client of Spring Cloud Configuration Server and use itself as single point of truth in the application configuration let's say retrieve application.properties/yml from the config server, you can benefit of #RefreshScope. in this case if you do a post to the /refresh if you use spring boot 1.x or /actuator/refresh if you use spring boot 2.x all the bean that are have are annotated as #RefreshScope will be refreshed.

Using Spring Boot Thymeleaf by do not run as a web application

I have a Spring Boot application that uses Thymeleaf for email templating. My application is not a web application though.
However, when including the spring boot starter thymeleaf dependency:
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
Spring MVC is transitively included and eventually Servlet.class in my class path signaling that my application is a web application... which then has the undesirable result of running my application in the Tomcat servlet container (by default on port 8080).
How can I use the features of Spring Boot Thymeleaf (such as configuring in a props file ala https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html) without my application running as a web application?
Setting the following property as follows prevents the Spring Boot application from running as web application:
spring.main.web-environment=false

Is it possible to expose a Spring MVC controller within a simple application context that is NOT a web application with a web.xml?

I would like to expose a Spring MVC controller in an application that will NOT be deployed in a web container like Tomcat. Is this possible? If so, can you please provide an example.
Spring boot has embedded servlet containers. This enables you to launch apps by executing a jar, instead of deployment to servlet container

Spring Boot Actuator in the traditional container

Can we use the Spring Boot Actuator in the traditional shared container within the context of an application? If so, how would be the configuration look like?
I have tried it by bootstrapping EndpointWebMvcAutoConfiguration. However, could not map mvc urls.
There's nothing stopping you from just using it as a dependency. Any Spring Boot app should be able to use actuator features out of the box.

Resources