embedded tomcat setenv configuration with spring boot - spring-boot

I want to provide the contents of setenv when running a spring boot app on an embedded tomcat container. What is the best place to do this?
I would like it to be in an external file and also ensure that tomcat is able to access it before the spring context loading kicks in.

Related

Defining context path for spring boot application in external tomcat

I have a spring boot application abc.myapp.war, that is deployed on external tomcat server. By default the tomcat uses the war file name as the context path of the application deployed so it becomes http://localhost:8080/abc.myapp, but I want to have a custom context path like http://localhost:8080/abc/myapp.
I have read through other post they suggest using context tag in server.xml of tomcat, but there is not clear mention how to use it. Can anyone suggest any reference or way to change the context path of the application.
Other ways of doing this are also welcome.
If you want your app to appear with a context path of /abc/myapp you don't have to write any context file, just rename the WAR file to abc#myapp.war: the # will be converted to / (cf. Tomcat documentation for more examples).

Deploy spring boot applications

I know spring boot applications can be deployed to production environments as war files. But what is the typical way of deploying spring boot applications? Does it only require a jvm, not a container?
The Spring Boot Project Page states that Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".
Means by default, the Spring Boot maven or gradle plugin builds self-contained executable jars, that contain all dependencies and an embedded webserver, e.g. tomcat or jetty. The Spring Boot Getting Started doc gives you an introduction to that. Using this approach you just need a JVM to run your application. But you can also configure it to create war files if this is a better fit to your production environment.
Does it only require a jvm, not a container?
It can run anywhere Java is setup.
Spring Boot's use of embedded containers and why Spring chose to go the container-less route. Many of their main driving forces were ease of use while testing and debugging, and being able to deploy Spring-based Java applications to the cloud, or any other environment.
Rest can be found out in attached image.
Spring boot applications if they are serving web requests do require a container. You can either deploy them as a war inside a container such as tomcat/jetty. Or you can deploy them with embedded container, tomcat.

Deploy a war file inside the embedded servlet container in a Spring Boot web application

I want to deploy one or more already existing war files into the embedded servlet container in the Spring Boot project.
Specifically, I want to fire up both the hawtio and the ActiveMQ Web Console wars inside the same application, in addition to some of my own stuff.
Is there a correct way to do this, or do I have to go for the "nuclear option" of configuring the servlet container instance myself? (Note that I'd rather have Jetty than Tomcat, but if it is one line with Tomcat, and lots of cruft with Jetty, then Tomcat is okay)

Tomcats RemoteIPValve not invoked in Spring Boot Application deployed as a WAR file

My Spring Boot 1.3.2 Application is deployed as a WAR file into a standalone tomcat7. I am trying to activate the RemoteIPValve using server.use-forward-headers=true as described in the spring boot docs.
But the RemoteIPValve is not properly configured nor invoked when handling the request. Log says:
NonEmbeddedServletContainerFactory detected.
When I start the application using the maven plugin I get a:
Initializing Spring embedded WebApplicationContext
... and RemoteIPValve is working as expected. How can I accomplish the same using WAR File deployment?
When you deploy a Spring Boot application to standalone Tomcat, none of the embedded server configuration takes effect. Instead, you need to update your Tomcat installation's configuration to enable the valve. To use the valve in its default configuration, add the following to server.xml:
<Valve className="org.apache.catalina.valves.RemoteIpValve"/>

How to configure wily with spring boot application

I have created an application as spring boot application,Now i want to integrate this application with wily,where i ll passed wily parameter in application to configure application.
The fact that it's a Spring Boot application shouldn't make any difference. If you're using an executable jar file, you'll need to configure the agent when you launch the jar, for example:
java -jar my-app.jar -javaagent:<Agent_Home>/Agent.jar -Dcom.wily.introscope.agentProfile=<Path_To_Agent_Profile>
If you're deploying your Spring Boot application as a war file to a servlet container or application server, you'll need to be make the equivalent configuration changes. The documentation describes how to configure Tomcat.

Resources