Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Scout application in single war(How scout client and server can be combined in single war file)
Scout application in single war [message #1848554] Tue, 07 December 2021 15:36 Go to next message
Seydou Zakou is currently offline Seydou ZakouFriend
Messages: 44
Registered: May 2020
Member
Hi all,
Does any one has an idea how to combine scout client and server war into a single one ?

Thanks,
Re: Scout application in single war [message #1848565 is a reply to message #1848554] Wed, 08 December 2021 08:41 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 207
Registered: November 2010
Senior Member
Yes, this is possible, although not very well documented.

You need a module with these dependencies:


  • Everything from the *.ui.html.app.war module
  • Everything from the *.server.app.war module
  • One additional module: org.eclipse.scout.rt.serverbridge


You can either use the existing *.ui.html.app.war module and extend it or create a copy of it under a new name (e.g. *.all.app.war). Because resources can only exist once, you have to merge files such as config.properties or logback.xml.

There is an example in the Scout contacts demo app, although only for the development mode (but the production module should be quite similar).

How does it work? The serverbridge module installs a bean decorator that simply replaces the HTTP service tunnel for all beans annotated with @TunnelToServer by direct calls to the implementation. Everything else works just the same, i.e. you still have a client session and a server session with run contexts, transactions etc.

Regards,
Beat
Re: Scout application in single war [message #1848610 is a reply to message #1848565] Thu, 09 December 2021 16:38 Go to previous messageGo to next message
Seydou Zakou is currently offline Seydou ZakouFriend
Messages: 44
Registered: May 2020
Member
Thanks for your Quick reply.
Re: Scout application in single war [message #1848900 is a reply to message #1848610] Wed, 22 December 2021 16:43 Go to previous messageGo to next message
Seydou Zakou is currently offline Seydou ZakouFriend
Messages: 44
Registered: May 2020
Member
I were able to combine the 2 parts of the application into a single war, but it Seems that ClientSession and ServerSession are having problem with the setup.
After deployment into tomcat, call to
ClientSession.get().getUserId()
returns null and call to
ServerSession.get()
return also null, see below debug log from Sessions classe
org.eclipse.scout.rt.shared.session.Sessions - Session not of the expected type [session=com.groupesepro.bp.core.client.ClientS
ession@4e1ebf2f[id = ernoft2tisrth6328ocl7avbm8s4etjnbkhf2dplk9tn3bu0ds6], expectedType=interface org.eclipse.scout.rt.server.IServerSession]


Is there some case where combining of the 2 parts of the application in single war is not recommended ? Or what should be care about when someone plan to have a single war ?

[Updated on: Wed, 22 December 2021 16:49]

Report message to a moderator

Re: Scout application in single war [message #1848901 is a reply to message #1848900] Wed, 22 December 2021 17:33 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 207
Registered: November 2010
Senior Member
Looks like you are mixing "client" and "server" code.

Even if you deploy both parts in a single war (with the additional serverbridge module, as described above), the presentation layer (forms, outlines etc.) and the service/persistence layer are still separated. The run context determines in which "world" your code is running. The only way to switch between them is by calling a service with @TunnelToServer annotation. Only with in this tunnel Scout automatically convert the client context to a server context for you. The serverbridge does not remove this tunnel, it will only make it very thin (in-memory calls instead of HTTP).

You can have a look at the contacts demo application. If you start the application from the module org.eclipse.scout.contacts.all.app.dev (instead of org.eclipse.scout.contacts.server.app.dev and org.eclipse.scout.contacts.ui.html.app.dev), you can see it in action and compare it with your setup.

Regards,
Beat
Re: Scout application in single war [message #1848937 is a reply to message #1848901] Fri, 24 December 2021 16:59 Go to previous messageGo to next message
Seydou Zakou is currently offline Seydou ZakouFriend
Messages: 44
Registered: May 2020
Member
Hi @Beat,
Thank you for your reply.
I Review all our code but I dont't see where we have mixed the {Service, Client} Session or RunContext.
Checking the logs in debug mode, I attached the output of the log, maybe someone have idea of what is wrong in my code.

Note that all the exception occurs in execLoadPermission of ServerAccessControlService where I tried to get an assigned shared variable data (profile) on the user with ServerSession.get()

  • Attachment: debug.log
    (Size: 114.80KB, Downloaded 75 times)
Re: Scout application in single war [message #1848964 is a reply to message #1848937] Mon, 27 December 2021 10:05 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 207
Registered: November 2010
Senior Member
The message "Session not of the expected type" you posted earlier suggests that you do somehow call server code from within a client context. Unfortunately, the debug log does not help, and it does not contain the method "execLoadPermission" you mentioned.

A point you have to keep in mind: When you put the client and server code in the same application, all of the bean classes are on the same class path. This means that when resolving an instance for an interface, you might get a different implementation than before. Example: assume there is an interface IFoo in the shared module, a ClientFoo implementation in the client module and a ServerFoo implementation in the server module. Naturally BEANS.get(IFoo.class) can only return one of the the implementations. If there are two WAR files, each part of the application only contains one implementation. But when merged, the bean manager will choose one of them. This can lead to errors when the implementation does not support this situation correcly. So if ServerFoo calls Sessions.currentSession(IServerSession.class), this may fail when called from within a client context. To fix it, you need an implementation that can handle both cases, e.g. "if (ISession.CURRENT.get() instanceof IClientSession) { ... }".

Long story short: If you need class isolation, stick to the setup with two separate WAR files (both application can't "see" each other). When deployed in a single WAR file, the bean implementations might have to be adjusted to work with different runtime contexts.

Regards,
Beat
Re: Scout application in single war [message #1856703 is a reply to message #1848964] Fri, 23 December 2022 13:42 Go to previous messageGo to next message
Jerome HolbeinFriend
Messages: 13
Registered: June 2020
Junior Member
Hi,

I successfully setup a project like this. Copying over the ui.thml.app.dev module and including the serverbridge dependency, I can launch it in dev mode without any problems. But switching over to production mode does not allow me to login to the application:
org.eclipse.jetty.server.HttpChannel.handleException(HttpChannel.java:673) - handleException /auth java.net.ConnectException: Connection refused (Connection refused) - MDC[]
I suspect it's got to do with the setup of the servlet filters in the web.xml of all.app.dev. Any ideas how that should look like for such a serverbridge project to work in production mode, if we don't have separate web.xml files for server and UI anymore?

Bests,
Jérôme
Re: Scout application in single war [message #1856768 is a reply to message #1856703] Fri, 30 December 2022 10:13 Go to previous message
Matthias Villiger is currently offline Matthias VilligerFriend
Messages: 232
Registered: September 2011
Senior Member
Hi Jérôme

The "Contacts" demo application contains an example using the serverbridge. See the org.eclipse.scout.contacts.all.app.dev module and the containing web.xml.

Maybe this helps you to track down the issue.

Kind regards
Mat
Previous Topic:Scout 7 Tabs
Next Topic:Migrating Scout from 11 to 22 - Error when importing custom fonts from WEB
Goto Forum:
  


Current Time: Wed May 08 12:57:50 GMT 2024

Powered by FUDForum. Page generated in 0.03906 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top