Confusion deploying React uberJar - URL

I’ve tried to deploy my application as an uberJar. It works fine locally when run via Intellij and the internal Tomcat server. I have the following in my .env.production.local file:

PUBLIC_URL=/pasweb/front/
REACT_APP_CUBA_URL=/pasweb/rest/
REACT_APP_REST_CLIENT_ID=[...]
REACT_APP_REST_CLIENT_SECRET=[...]

However, I can not reach my application via …/pasweb/front or …/pasweb-front. I see this in the app.log file when I try to access it:

2021-02-09 15:03:35.033 INFO  [main] org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@30130a31{/pasweb,jar:file:/opt/app_home/pasweb/pasweb.jar!/LIB-INF/app,AVAILABLE}
2021-02-09 15:03:35.040 INFO  [main] org.eclipse.jetty.webapp.StandardDescriptorProcessor - NO JSP Support for /pasweb-front, did not find org.eclipse.jetty.jsp.JettyJspServlet
2021-02-09 15:03:35.048 INFO  [main] org.eclipse.jetty.server.handler.ContextHandler.pasweb_front - Initializing Spring AppFrontServlet 'app_front_servlet'
2021-02-09 15:03:35.048 INFO  [main] com.haulmont.frontservlet.AppFrontServlet - Initializing Servlet 'app_front_servlet'
2021-02-09 15:03:35.432 DEBUG [main] com.haulmont.frontservlet.AppFrontServlet - Published WebApplicationContext of servlet 'app_front_servlet' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.app_front_servlet]
2021-02-09 15:03:35.432 DEBUG [main] com.haulmont.frontservlet.AppFrontServlet - enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2021-02-09 15:03:35.432 INFO  [main] com.haulmont.frontservlet.AppFrontServlet - Completed initialization in 384 ms
2021-02-09 15:03:35.433 INFO  [main] org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@6c4c4df8{/pasweb-front,jar:file:/opt/app_home/pasweb/pasweb.jar!/LIB-INF/app-front,AVAILABLE}
2021-02-09 15:03:35.463 INFO  [main] org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@490ab905{HTTP/1.1, (http/1.1)}{0.0.0.0:8300}
2021-02-09 15:03:35.464 INFO  [main] org.eclipse.jetty.server.Server - Started @19074ms
2021-02-09 15:03:36.919 WARN  [qtp95395916-22] com.vaadin.server.DefaultDeploymentConfiguration -
=================================================================
Vaadin is running in DEBUG MODE.
Add productionMode=true to web.xml to disable debug features.
To show debug window, add ?debug to your application URL.
=================================================================
2021-02-09 15:05:27.741 DEBUG [qtp95395916-20] com.haulmont.frontservlet.AppFrontServlet - Completed 302 FOUND
2021-02-09 15:05:27.782 DEBUG [qtp95395916-21] com.haulmont.frontservlet.AppFrontServlet - GET "/pasweb-front/index.html", parameters={}
2021-02-09 15:05:27.936 DEBUG [qtp95395916-21] com.haulmont.frontservlet.AppFrontServlet - Completed 200 OK

If I try to access “/pasweb/front/”, which is what I expected, I get my backend GUI and not the React front end. If I try “/pasweb-front”, as you can see, it served a file called “/pasweb-front/index.html”, but I got back an empty screen.

How do I set the deployment URL properly in an uberJar or, alternatively, what URL do I need to use to access my application as it is current configured?

Hi.
Unfortunately, there is no ability to change react front URL, we have created GitHub issue. However, if you change PUBLIC_URL variable back to default PUBLIC_URL=/pasweb-front/ you will be able to access React front end by “/pasweb-front”.

Regards,
Natalia

Thanks for the reply. My .env.production.local now looks like this:

PUBLIC_URL=/pasweb-front/
REACT_APP_CUBA_URL=/pasweb/rest/
REACT_APP_REST_CLIENT_ID=.....
REACT_APP_REST_CLIENT_SECRET=.....

I redeployed and am still getting a blank screen. It may be because I am behind an Nginx reverse proxy:

location /pasweb-front {
  proxy_pass http://localhost:8300/pasweb-front;
}
location /pasweb {
  proxy_pass http://localhost:8300/pasweb;
}

I can access the regular GUI just fine via www.paslists.com/pasweb, so I’m pretty sure that the reverse proxy is working properly. Here is an excerpt from access.log. URL is Professional Advertising Systems Inc.

MY-IP-ADDR - - [13/Feb/2021:14:19:18 +0000] "GET /pasweb-front HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb-front/ HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb-front/index.html HTTP/1.1" 200 1243 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb/front/manifest.json HTTP/1.1" 301 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"
MY-IP-ADDR - - [12/Feb/2021:14:19:18 +0000] "GET /pasweb HTTP/1.1" 302 5 "https://www.paslists.com/pasweb-front/index.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36"

It seems like it serves /pasweb-front/index.html (status 200), then I get a lot of redirects(HTTP 302) and a permanent redirect (HTTP 301) that are never completed?

I’ve also tried accessing the url directly from my internal hostname (bypassing the proxy):

internal host on my VPN:8300/pasweb-front/

I also get a blank screen there. Of course, any URL it generates would still go through the reverse-proxy. In case it matters, the command line running the uberJar is:

java -jar  -Dapp.home=/opt/app_home/pasweb -Dapp.user=***** -Dapp.pwd=***** -agentlib:jdwp=transport=dt_socket,address=8301,server=y,suspend=n -jar /opt/app_ho
me/pasweb/pasweb.jar -port 8300 -contextName pasweb

I assume my reverse proxy is misconfigured somehow. Any hints?

Hi @eraskin!

Could you please check if you specified appName property in the buildUberJar task e.g.

task buildUberJar(type: CubaUberJarBuilding) {
...
    appName = "passweb"
...
}

?

I did not (and it is pasweb with a single “s” :wink: ):

task buildUberJar(type: CubaUberJarBuilding) {
    webPort = 8300
    logbackConfigurationFile = 'etc/uber-jar-logback.xml'
    singleJar = true
    appProperties = ['cuba.automaticDatabaseUpdate'    : true,
                     'cuba.dataSource.username'        : '***',
                     'cuba.dataSource.password'        : '***',
                     'cuba.dataSource.dbName'          : 'pas',
                     'cuba.dataSource.host'            : 'postgres.paslists.com',
                     'cuba.dataSource.port'            : '',
                     'cuba.dataSource.connectionParams': '?currentSchema=webdata',
                     'cuba.dataSourceProvider'         : 'application']
    polymerBuildDir = '.'
}

Could you try to specify it:

appName = "pasweb"

and see if pasweb-front is accessible?

Yes, that fixed it! Thank you!

1 Like