Multiple Application Deployments (using Jetty)

Dears,

I am using Jetty web server to deploy my Cuba Billing application, specifically based on the following documentation:
https://doc.cuba-platform.com/manual-6.1/war_deployment.html

Recently, I need to maintain and deploy multiple versions of the same application on the same server (each with different customizations based on customer’s need).

Could you please advise on how to achieve this?

More specifically:

  1. Shall I have different Jetty instances or just different “jetty base” directories each belonging to one version?
  2. How to start specific versions and stop others?
  3. Any possible drawbacks or conflicts by doing multiple live deployments on the same server?

Thank You.

Hi Shady,

  1. Shall I have different Jetty instances or just different “jetty base” directories each belonging to one version
    Application configuration (JNDI resources, JVM properties) is stored in the “jetty-base” directory. So you should create different “jetty base” directories for each version.
  1. How to start specific versions and stop others?
    You can navigate to the “jetty-base” directory for the specific application version and run:
java -jar c:\work\jetty-home\start.jar

You can stop specific version:

  • By "kill" command in the Unix-like systems
  • Or using stop port https://wiki.eclipse.org/Jetty/Howto/Secure_Termination
  1. Any possible drawbacks or conflicts by doing multiple live deployments on the same server?
    You should specify different HTTP ports for each application version. Also “app.home” property (specified on the step 8 https://doc.cuba-platform.com/manual-6.1/war_deployment.html?_ga=2.61328616.592848322.1500878265-719213779.1500637692) must be unique for each application version.

Thanks,
Subbotin Andrey

Dear Andrey,

Thanks for the reply.

I followed above steps, and currently have 2 “jetty-base” folders for each of the 2 versions I deployed.

I have modified start.ini in each version, so that each uses different ports. (I have uncommented jetty.http.port and also changed the port in agentlib so that I can launch both versions at the same time).

When I start both versions by running “java -jar c:\work\jetty-home\start.jar” in the specific application version, I have no issue. Both start successfully and I got the login screen of each version.

However, when I click on login, I get the following error:

ERROR [qtp31705400-15] com.haulmont.cuba.web.AppUI - Unable to init ui
org.springframework.remoting.RemoteConnectFailureException: Could not connect to HTTP invoker remote service at [cuba_LoginService]; nested exception is java.net.ConnectException: Connection refused: connect
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:206) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.invoke(HttpInvokerClientInterceptor.java:147) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]

Any idea what is missing?

Thanks.

Hi Shady,

I think it is a problem with HTTP port for each deployment.
Try to build WAR for each deployment using task:


task buildWar(type: CubaWarBuilding) {
    appHome = '${app.home}'
    singleWar = false
    appProperties = ['cuba.webPort' : <webPort>, 'cuba.connectionUrlList': "http://localhost:<webPort>/app" ]
}

where is a port of concrete Jetty server instance.

Application properties cuba.webPort and cuba.connectionUrlList are described in https://doc.cuba-platform.com/manual-6.1/app_properties_reference.html

Thanks.

Hi Andrey,

Thanks for your reply,

I tried the above, and got a new error:

[qtp31705400-60] com.haulmont.cuba.web.AppUI - Unable to init ui
org.springframework.remoting.RemoteAccessException: Could not access HTTP invoker remote service at [cuba_LoginService]; 
nested exception is java.io.StreamCorruptedException: invalid stream header: 3C21646F
        at org.springframework.remoting.httpinvoker.HttpInvokerClientInterceptor.convertHttpInvokerAccessException(HttpInvokerClientInterceptor.java:226)

Note that now when I start the first app (running on default port 8080), I have no issue.
However, when I start the second app, I got above issue, and then both app fail. (the running one stops working).

Clearly, there is still some conflict between the 2 apps.

Also, note that I have added the below to build WAR as per your suggestion:

task buildWar(type: CubaWarBuilding) {
    coreContextXmlPath = 'modules/core/web/META-INF/jelastic-context.xml'
    includeJdbcDriver = true
    appHome = 'C:/CubaBillingAppHome'
    singleWar = false
    includeContextXml = false
	appProperties = ['cuba.webPort' : 8081, 'cuba.connectionUrlList': "http://localhost:8081/billing" ]
}

Hi Shady,
Could you provide console outputs and logs for two jetty instances?

Hi Andrey,

I have attached logs of the 2 instances.

Instance 1 is the one launching correctly (kdc), up until I start instance 2 (qdc) which is giving the error.

Instance1.txt (31.2K)

Instance2.txt (35.6K)

Shady,

Please change a cuba.connectionUrlList property in the buildWar task to http://localhost:8081/billing-core. It’s an URL for core WAR module in the qdc application.

Hi Andrey,

Thanks for pointing this out.
Finally, both instances are starting successfully now.

However, I am getting randomly (almost every few seconds) a “session expired issue” in each instance: Session Expired, Pay attention to any unsaved data, and click here to continue.

Then I have to click to resume working.

Could this be due to the fact that both instances have the same app name: billing?

Many Thanks.

Shady

Hi Andrey,

Problem solved by specifying different app names and app homes for each instance.

Thanks for your help in closing this issue.

Shady