CUBA Migrated UberJar -port and -contextName equivalent in Jmix

Hello:

I am testing migrating one of my Cuba 7.2 apps to Jmix 1.4. I have successfully created what Cuba would call an uberJar (fat jar in Spring parlance?).

In my normal execution, I would run it like this:

java -Dapp.home=/opt/app_home/myapp -Dapp.user=user -Dapp.password=password -jar /opt/app_home/myapp.jar -port 8200 -contextName myContext

This would let me access the application with the <server>:8200/myContext

Does -contextName still work? If not, how do you achieve the same result in Jmix?

I may have resolved this myself. Posting for posterity. I modified my command line:

java -Dapp.home=/opt/app_home/myapp -Dapp.user=user -Dapp.password=password
-Dserver.port=8200 -Dserver.servlet.context_path=/myContext -jar /opt/app_home/myapp.jar

Replace -port with -Dserver.port and -contextName with -Dserver.servlet.context_path

One caveat is that the contextName in the Cuba uberJar did not begin with a “/” but the server.servlet.context_path must begin with a “/”.

The reason I find this useful is I can deploy the same app under multiple contexts for different users, each with their own database connection configured by the username/password arguments. This is basically a poor man’s multi-tenancy by schema.

This might be something useful to add to the documentation for jar deployment?

Hi Eric
Thanks for sharing your experience.

As for adding this property to the Jmix docs - we’d like to refrain from duplicating Spring Boot docs, there are just too many properties.

I know this is an old thread, but I found that Jmix 2.0 requires different arguments yet again:

–server.port=port to set the port number
–server.servlet.context-path=/path to set the context path (note the leading slash)

Jmix 1.0 requires:

-Dserver.port port
-Dserver.servlet.context_path=/path (note the leading slash)

Documenting here in case somebody else runs into the same issue.

In fact both ways work in both Jmix 1 and 2. Just make sure you use -Dserver.port=8585 before JAR name and --server.port=8585 after it:

java -jar -Dserver.port=8585 myapp.jar

java -jar myapp.jar --server.port=8585

Because -D is a JVM parameter and -- is a Spring Boot application parameter.