Running manager from IDE (custom template or main project)

Hi.
I’m trying to run the manager using the IDE, but so far, I haven’t managed to complete the process.

I first tried to use the custom-project template according to User Guide: Custom deployment, but for some reason, npm run serve -- --env config=..\..\..\..\deployment\manager\app returns some errors, and I believe this makes the frontend unavailable at http://localhost:9000/manager/.

Alternatively, I cloned the main openeremote repo directly to see if working on the main project could make any difference. After executing docker-compose -p openremote -f profile/dev-testing.yml up --build -d, I can see the Keycloak and the PostgreSQL containers running properly. Besides, npm run serve -- --env config=..\..\..\..\deployment\manager\app seems to work now. However, I’m not sure how to run the manager backend using the IDE. I’ve downloaded IntelliJ IDEA for the first time, and I don’t know how to configure it properly. I opened the openremote project in the IDE, but it seems that there is no application configuration ready. So I added a new application configuration under run>edit configurations, but I’m not sure how to configure it correctly.

If I try to run from the IDE I get:

Error: Could not find or load main class org.openremote.manager.Main
Caused by: java.lang.ClassNotFoundException: org.openremote.manager.Main

and http://localhost:9000/manager/ returns:

Compiled with problems:
ERROR
unable to locate ‘E:/RemoteMeter/Software/RemotePlatform/ui/app/manager/…......\deployment\manager\app’ glob

I believe that I’m not specifying the main class correctly, but I don’t know exactly how to do it.
Any idea how to fix this issue?

Thanks in advance.

Hi dario!

Normally when importing the project in IntelliJ a set of default run configurations are present.
This makes it way easier to get the manager running.

Have you checked the Setting up an IDE wiki page? Especially the ‘Importing a project in an IDE’ and ‘Setting the working directory’ sections could help here.

.
Setting the option “Build and run using” to IntelliJ IDEA in Build, Execution, Deployment ->
Build Tools -> Gradle should make the configurations appear like “Demo Setup” and “Empty”:

(screenshot of my IntelliJ IDEA Ultimate instance)

The ‘Running and debugging the Manager’ section also describes a custom configuration in case of using custom projects, since classpath and main class specifications differ there.

.
Hopefully this helped!
Let me know if further issues appear :wink:

1 Like

Hi Martin.
Thanks for your reply.

Yes, I can see the configurations you mentioned, but it seems to work only with the custom-template. However, when I use the custom template, I cannot manage to get the manager frontend up and running ( npm run serve -- --env config=..\..\..\..\deployment\manager\app returns some errors).

Because of this issue, I tried to use directly -at least for now- the openremote main repo, but in this case, I cannot see any configurations appearing on IntelliJ. I’ve also referred to the Setting up an IDE wiki page you mentioned, and it says:

If you are using the custom project repository as starting point the run configurations will already be set up. If not, set up a Run Configuration:

Module/Classpath: custom-project.setup.main for custom projects
Working directory: Must be set to OpenRemote main project directory!
Main class: org.openremote.manager.Main
Any environment variables that customise deployment (usually custom projects have some)

However, I’m probably missing how to set the Module/Classpath.
Am I supposed to see a default set of configurations even working directly on openremote main project?

Thanks!

Am I supposed to see a default set of configurations even working directly on openremote main project?

That is correct. It should run out of the box when importing the project into IntelliJ IDEA. (after following the steps on the wiki page I mentioned)

The screenshot I sent earlier is from the openremote main repo where I’m working on right now.
I can’t remember editing the default one, so here are my run configurations:

.
Empty configuration: (no pre-loaded assets)

Module/Classpath:  openremote.manager.main
Working directory:   /* OpenRemote main project directory (normally ends with "/openremote" folder after cloning) */
Main class:  org.openremote.manager.main

.
Demo Setup configuration: (included SmartCity demo assets)

Module/Classpath:  openremote.setup.main
Working directory:   /* OpenRemote main project directory (normally ends with "/openremote" folder after cloning) */
Main class:  org.openremote.manager.main
Environment variables:  OR_SETUP_TYPE=demo;
1 Like

Thanks, Martin!
It is working now (at least the main repo).
As you pointed out, the problem was that the repo was cloned in my folder without the /openremote subdirectory.
Thanks a lot!
Dario

1 Like