REST Datastore doesn't work on an add-on

Hi,
We have a Jmix 2.4 application with several features supported by add-ons, but we have not manages to make REST Datastore work in those add-ons.

Hello!

Could you, please provide an example project with this issue or describe the steps (add-ons and usage scenario) required to reproduce this problem?

Regards,
Dmitry

Hello Dmitry,
Link to download example project https://drive.canals.es/s/MkFqEKQgS27acbX

Server → Full stack Jmix App with Authorization Server and REST API add-ons.
Client → Full stack Jmix App with Clientcommon add-on
ClientCommon-> Add-on with REST Datastore
Regads,
Francesc,

Hi Francesc,

Thank you for the sample project.
Could you describe the problem in more detail? It’s not immediately clear from the source code.

Regards,
Konstantin

Hi Konstantin,

The Server application is a full stack Jmix application with a Customer entity running on localhost:8080.
On the other hand, Client is a full stack Jmix application without any entity running on localhost:8081,
but it depends on the ClientCommon add-on that has a Customer DTO to consume the REST web services of the Server application.
If we place the Customer DTO in the Client application, it works without problems,
but if we place it in the ClientCommon add-on it does not work at all and does not raise any exception or error message.
Regards,
Francesc

Customers in Server app.
CustomerInServer

Customers in Client / ClientCommon app
CustomerInClient

Thank you for the explanation.

The main reason why you don’t see any errors and the entities are just not loaded is that your views for DTO entity contain empty load/save delegates. When working with entities from REST DataStore you don’t need delegates at all because DataManager can do all the work the same as for JPA entities.

Studio now doesn’t completely supports REST DataStore in add-ons, that’s why it generated these empty delegates for you. I’ve created an issue for improvement: Support for REST DataStore in add-ons : JST-5474.

Also, I’ve fixed a few other problems in your project:

  • client secret on the client side should not have the {noop} prefix
  • the Customer DTO entity needs @RestDataStoreEntity(remoteName = "Customer") annotation
  • the server’s fetch-plans.xml file has to contain a fetch plan named customer-fetch-plan

Now the project works, see demoRESTDatastore 2.zip (615.9 KB)

Regards,
Konstantin

Thnxs, Konstantin,
Everything works now !

Hi Konstantin,
We’ve detected new problem. If the entity definition is on main application ( Server in this example ) your solution works without any problem and Client application can access REST Datasource but if the entity definition is on an add-on of the main application ( ServerCommon add-on ) Client application is unable to use REST Datasource.
See modified project
demoRESTDatastore 3.zip (794.6 KB)
In this project we’ve created an add-on ( ServerCommon ) with a new entity Orders . Client application cannot access Orders with REST Datasource but acces Customer without any problem.
Regards,
Francesc

Hi Francesc

I see the same problem as before: your OrdersListView and OrdersDetailView classes in the clientcommon module have empty load/save delegates. Just remove them and your orders will be loaded.

The upcoming Studio 2.4.2 will correctly generate views for REST entities in add-ons. Until then, please check the generated views manually.

Regards,
Konstantin

Thanks Konstantin.