File Upload Problem with 2 applications deployment to single Tomcat

Good evening,
we have developed two applications that insist on the same database schema in Postgres.
Once deployed, the first upload of a file to one of the two applications completely disables the ability to upload to the other and the second application stop responding.

We use to test the upload action the External File voice in the cuba administration menu. Where are we wrong?

2019-02-19 18:24:01.019 ERROR [http-nio-8080-exec-1/imp/admin] com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.toolkit.ui.CubaFileUpload: 
com.vaadin.server.ServerRpcManager$RpcInvocationException: Unable to invoke method queueUploadFinished in com.haulmont.cuba.web.toolkit.ui.client.fileupload.CubaFileUploadServerRpc
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:160)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:119)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:444)
    at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:409)
    at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
    at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1435)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:361)
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:324)
    at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:210)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:107)
    at com.haulmont.cuba.web.security.idp.BaseIdpSessionFilter.doFilter(BaseIdpSessionFilter.java:220)
    at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:112)
    at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:73)
    at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at psiprobe.Tomcat85AgentValve.invoke(Tomcat85AgentValve.java:37)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)

Hi,

It is hard to say what is wrong. We will be able to help you if you send us a small sample project along with reproduction scenario that demonstrates the issue.

Hi Yuriy,
this is the scenario:

  • test2 has test1 as application component
  • test1 and test2 use the same db schema
  • test1 and test2 run in the same tomcat instance.
    Now you run tomcat and connect with admin both to http://localhost:8080/app2 and http://localhost:8080/app, the try to upload a file with “external files” in both application.
    In the second one you’ll get “IllegalArgumentException: object is not an instance of declaring class” error.
    Thanks
    Manuel

test1.zip (80.6 KB)
test2.zip (77.1 KB)

By design, you cannot use the same Tomcat for 2 applications with exploded JARs deployment. It is a limitation of shared libraries class loader.

If you want to deploy 2 applications to the same Tomcat instance, I’d recommend that you build a Single WAR for each application and deploy them as isolated WAR files. Do not forget to undeploy your apps using Gradle task or from Studio.