Spring Boot and Jboss wildfly setting the context root - spring-boot

I am trying to set the context root of my spring boot application. I'm deploying my application as a war file to Jboss.
i've tried to set the contextPath of what I'd like my root URL to be when deploying it to JBoss/Wildfly but it seems to get ignored. Unless I add a jboss-web.xml file setting a contex-root variable, my deployment url is always based on the war file name:
e.g. : myapp.war always deploys as : localhost:8080/myapp unless I use jboss-web. I've tried setting the contextPath in the server.properties file and it doesn't seem to work.
My question is should I be able to? I'm using the latest Spring Boot.

In other words, add your jboss-web.xml
file in this directory : /src/main/webapp/WEB-INF
Content of your jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>/</context-root>
</jboss-web>

All of the server.* properties that Spring Boot supports only apply to the configuration of the embedded servlet container (Tomcat, Jetty, or Undertow). If you're deploying your Spring Boot app to a standalone server then you'll need to configure that server using whatever mechanisms it provides.

Related

Start spring boot jar file as part of tomcat start

There is a way I can start the spring boot jar file as part of tomcat start(catalina.bat start).
I have a spring cloud api gateway which does not support war file deployment.
In a bare metal box, I have installed the tomcat, and as part of deployment I have converted all microservice into war file and able to deploy it into tomcat/webapp folder and up and running.
As spring cloud api gateway does not support war file, I kept this application with embed tomcat.
Now I need this jar file as well get started along with the tomcat [catalina.bat start].
In tomcat I have seen there is something shared.loader option in catalina.properties file.
I have kept the jar file in below path as shown below and when I try to start it, jar file is not getting picked up.
Need to know if there is a way to start the spring boot application [jar file] as part of tomcat [catalina.bat start] start.

Control order of WAR file deployment in JBoss EAP 7.2.0

I have developed two Spring Boot applications, one is Cloud Config Server and the other is a Spring Boot application that fetches property from Config Server. I have deployed the two applications as WAR files in JBoss EAP. I am deploying the WAR files in sequence, deploying the Config Server before the other application. Problem is happening after I restart the server, the second war file is getting deployed before the war file for Config Server.
I Jboss EAP 7.2.0, how will I ensure that the WAR file for Config Server is always deployed before the WAR file of the other application?
You can control the startup order of deployment by using jboss-all.xml deployment descriptor to declare dependencies between the deployments.
Example:
If you want foo.ear is deployed before bar.ear then you can create an bar.ear/META-INF/jboss-all.xml file like this:
<jboss xmlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="foo.ear" />
</jboss-deployment-dependencies>
</jboss>
[1] https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.1/html/configuration_guide/deploying_applications#control_order_deployments
[2] https://access.redhat.com/solutions/88763

jetty: how to modify embedded jetty server start config in springboot?

I am using embedded jetty server in a springboot project. I need to set following configuration.
--module=jvm
--exec
-javaagent xxxx.jar
The document shows these configuration should set in start.ini. But embedded jetty does not have start.ini. Any idea about how to set start.ini properies in an embedded jetty?

Deploying spring boot executable jar on jboss but not as a war ,so that other applications can invoke as an api

I want to deploy an executable jar file on to jboss server, so that other application written in c/c++ can invoke it through workflow by passing the arguments to the executable jar file.
I have googled and found examples where war is deployed by making it restful webservice, but I could not find any such example where an executable jar file is deployed on jboss.
Appreciate your help
Regards,
Kiran Kumar
You can not deploy the spring boot executable jar file in Jboss. You need tweak your application to some extent for it to work on JBoss.
1. Add jboss-web.xml file src/main/webapp/WEB-INF folder, provide application context there.
<jboss-web>
<context-root>YOUR_APP_ROOT</context-root>
</jboss-web>
Set below spring property in your yml/props file.
server.servlet-path = /*

how to deploy Spring Cloud war to old container

I had a Spring Cloud project which was deployed in embeded tomcat. Now I modify the project add web.xml and make the Application class extends SpringBootServletInitializer. I followed the instruction of 81.5 Deploying a WAR in an Old (Servlet 2.5) Container in below link. But I found that the application.properties was not loaded. And the server port listed in application.properties was not listened.
[http://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html#howto-servlet-2-5]
Deploying a WAR in an Old (Servlet 2.5) Container
application.properties
spring.application.name=api-gateway
server.port=5555
# routes to serviceId
zuul.routes.api-a.path=/api-a/**
zuul.routes.api-a.serviceId=service-A
zuul.routes.api-b.path=/api-b/**
zuul.routes.api-b.serviceId=service-B
# routes to url
zuul.routes.api-a-url.path=/api-a-url/**
zuul.routes.api-a-url.url=http://localhost:2222/
eureka.client.serviceUrl.defaultZone=http://localhost:9999/eureka/

Resources