Calling spring boot from extension

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
rlaksana
Posts: 14
Joined: 15 Apr 2019, 11:57

Calling spring boot from extension

Postby rlaksana » 26 Jun 2019, 14:21

Hi,
I know from blog's guide that you can call extension from servlet deployed on jetty,
but is there a way to call servlet from extension?

I'm trying to call spring boot deployed on sfs2x jetty using war.

Thanks,
Richard
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Calling spring boot from extension

Postby Lapo » 26 Jun 2019, 16:51

Hi,
no this is not possible sorry. Also it sounds quite strange as use case.
Servlets respond to HTTP requests. Why do you need to invoke one from an Extension?

Can you explain what you're trying to do?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rlaksana
Posts: 14
Joined: 15 Apr 2019, 11:57

Re: Calling spring boot from extension

Postby rlaksana » 27 Jun 2019, 05:49

Hi,

I'm trying to use spring boot but it seems it can only deployed as:

a standalone jar with embedded application server such as jetty
OR
a war to be deployed to application server.

My case is actually simple, to be able to use spring 5 and spring data jpa with hibernate as jpa provider.
The only know way to run is actually only by using spring boot but it has limitation where it need to run in Java EE environment.

Scenario that I have tried:
1. running extension build as spring boot standalone jar. extension was able to be started but spring boot boot failed to start.
2. running old version of boot as war and was successful.
3. running newest version of boot as war and upgrade jetty on sfs installation to newest 9.3 jetty and was successful
4. running newest version of boot as war and failed on sfs jetty because JEP 238 jars.
5. I can run old version of spring using normal maven dependency as extension but still failing to configure to run spring data jpd with hibernate.

Thank you,
Richard
User avatar
rlaksana
Posts: 14
Joined: 15 Apr 2019, 11:57

Re: Calling spring boot from extension

Postby rlaksana » 27 Jun 2019, 14:58

Hi,

I found a temporary solution by using spring-jdbc for database connection and thus i don't need to use spring boot.

Spring boot facilitate automatic spring dependency and configuration. I have been using their auto configuration for so long that
currently are struggling to manually configure spring.

So my original question was me trying to find a shortcut by calling spring boot war deployed on jetty from extension.
If I'm able to do this then I don't need to do manual spring configuration.

it is just about boilerplate size. spring-jdbc require 100+ LoC where spring-data-jpa 3 require 1 LoC.

Thanks,
Richard
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Calling spring boot from extension

Postby Lapo » 27 Jun 2019, 15:58

Hi,
I am glad you were able to figure out a solution. We don't use Spring so our knowledge of the framework is very limited.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
DrPsyche
Posts: 8
Joined: 09 Jan 2019, 11:47

Re: Calling spring boot from extension

Postby DrPsyche » 22 Jul 2019, 08:46

rlaksana wrote:
Hi,

I found a temporary solution by using spring-jdbc for database connection and thus i don't need to use spring boot.

Spring boot facilitate automatic spring dependency and configuration. I have been using their auto configuration for so long that
currently are struggling to
do my assignment and manually configure spring.
So my original question was me trying to find a shortcut by calling spring boot war deployed on jetty from extension.
If I'm able to do this then I don't need to do manual spring configuration.

it is just about boilerplate size. spring-jdbc require 100+ LoC where spring-data-jpa 3 require 1 LoC.

Thanks,
Richard


Hello,

Thanks for the possible solution. Once I tried to create table (h2) with jdbcTemplate. So I had a defined a datasource in the spring configuration and then defined JdbcTemplate as a bean in my spring configuration and autowired it.
smithclarkson1
Posts: 1
Joined: 21 Dec 2019, 17:32

Re: Calling spring boot from extension

Postby smithclarkson1 » 21 Dec 2019, 17:33

Hi,
I know from blog's guide that you can call extension from servlet deployed on jetty,
but is there a way to call servlet from extension? 9Apps VidMate Vlc

I'm trying to call spring boot deployed on sfs2x jetty using war.
Last edited by smithclarkson1 on 19 Jan 2020, 19:18, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Calling spring boot from extension

Postby Lapo » 22 Dec 2019, 08:07

No, because they live in their own separate class loader, plus it's not a good idea generally speaking to invoke a servlet directly.

What you could do is using an event system to communicate between Extensions and Servlets.
Using something like the Observer pattern you could register one or more servlets to receive events from an Extension (and viceversa).

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 65 guests