Are there any Java API to work with CUBA platform from external Java App?

I am trying to integrate CUBA and our using BPM engine (Camunda).
From CUBA, I can interact with BPM process application using BPM engine’s Java API such as start/stop/send message to the BPM engine.

My question is: can I use java API to work with CUBA entities or managed beans from Process Application which run in BPM engine? Of course I can call Rest API of CUBA, but it would be much better if Cuba Platform support Java API as well for faster development and better performance.

Disclaimer: This is not by far the only way to accomplish this, only the first thing it came to my mind…

Take a look at : JMX Beans - CUBA Platform. Developer’s Manual

and an example on how to write a custom JMX client: Creating a Custom JMX Client (The Java™ Tutorials > Java Management Extensions (JMX) > Remote Management)

UPDATE: interacting with entities directly from external code is indeed a bad practice, try to interact only at a higher level, like managed beans or REST API. Another option is to write an alternative API based on Spring controller, and do whatever you want (for example use a binary protocol for higher speeds: )



There is a special library masquerade-connector that allows you using CUBA REST API and JMX from Java:


It is is our internal library, but we are going to announce it in the near future.

You can esaily create a small Java interface for local JMX proxy and call it:

public interface ConfigStorage {
    String printAppProperties();

ConfigStorage configStorage = Connectors.jmx(ConfigStorage.class);
String appProperties = configStorage.printAppProperties();

or work with CUBA REST API:

public interface UserService {
    Call<List<User>> all();

    Call<ResponseBody> create(@Body User user);

UserService userService = Connectors.restApi(UserService.class);
List<User> allUsers = userService.all().execute().body();

REST API binding based on the popular retrofit2 library.

We use this library for integration and UI tests of the platform.

Thank you all for quick reply.

Actually, I found a solution, sorry for late update:
I added bpm process application code into core module of CUBA project and configure web.xml to have one more listener for that. CUBA and process application now will be in a combined project, and app-core.war files will be deployed on Camunda Tomcat server (shared engine mode). From bpm process application beans, I can now work with CUBA using AppBeans.get() and skip user session using system authentication.

BPM bean:

  public void execute(DelegateExecution delegate) throws Exception {
    Authentication authentication = AppBeans.get(Authentication.class);
    try {
      System.out.println("BPM Process Application bean invoked");
      TestBean testBean = AppBeans.get(TestBean.class);
    } finally {

Cuba managed bean: TestBean

public void updateEntityName() {
    System.out.println("Cuba managed bean invoked");
    Persistence persistence = AppBeans.get(Persistence.class);
    Transaction tx = persistence.createTransaction();
    try {
        TestEntity testEntity = persistence.getEntityManager().find(TestEntity.class,UUID.fromString("dc044f40-25bb-c5f5-c945-86d772e71157"),"_local");
        testEntity.setName("Name is set by CUBA managed bean");
    } finally {

Thank you a gain for support.

My approach may be not work once i use it as an application component as the web.xml and spring.xml is altered.

I will try to use JMX as suggested.