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

@martin.peeters , @dario
Hi,
I have follow same process that You have mention above but it not work. while I try to run get the error
I follow the link to set up IDE configuration

  • “C:\Program Files\Java\jdk-17\bin\java.exe” --enable-preview “-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.4\lib\idea_rt.jar=56784:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.4\bin” -Dfile.encoding=UTF-8 org.openremote.manager.main

  • Error: Could not find or load main class org.openremote.manager.main

  • Caused by: java.lang.ClassNotFoundException: org.openremote.manager.main

  • Process finished with exit code 1

Here i have share the configuration snip

And this one is main OpenRemote repo file i save it my download folder


In first pic have some error and I don’t know why i am getting.
Any idea how to fix this?
Thanks in advance

Hi Vicky,

I’m a bit confused with the file structure I see there. Do you want to set up a custom project using the repository template, or just run OpenRemote with the demo for example?

In any case it seems like not all files are there? Did you pull everything successfully?
It’s as if you have an incomplete folder of OpenRemote and in there put the custom project? The custom project should use openremote as a submodule (that you need to initialize and update).

If openremote was complete and IntelliJ has some time to properly set up the project, it will come with some preset Run Configurations. If not, you will also be able to select something like customer-project-main.manager.main in the -cp field.

Could you delete everything and start over following User Guide: Custom deployment · openremote/openremote Wiki · GitHub ?
Hopefully that helps.

Don

Hi Don,
First I want to run OpenRemote demo project. Here I deleted and start over using User Guide: Custom deployment · openremote/openremote Wiki · GitHub
Here I am sharing some snip. I hope I was done all that things in right way.


but when i run it give the error

Hope I am able to explain where I getting issue
Vicky

Hi Don @martin.peeters , @Rich After above all I run the command “./gradlew clean installDist” for cop


@Don @martin.peeters @Rich
I am able to compiled successfully but getting empty UI.

Vicky

Hi Vicky,

The wiki page you mention is about running a custom project with OpenRemote as submodule, so that is confusing things. If you just want to run the demo first, you can follow the quickstart: openremote/README.md at master · openremote/openremote · GitHub
If you do want to run the custom project (for advanced users) then you should follow the wiki page you mentioned and make sure you have the docker containers running using docker-compose -f profile\dev-testing.yml up -d, then run the ‘custom project’ run configuration (top right in IDE), then rune the manager ui as you did.

Let me know how it went :slight_smile:

Hi Don,
First I want to run OpenRemote demo using the code. then I will set up a custom project. For demo openremote I import code on IDE and run using “npm run server” command and give a path “ui/app/manager”. and “http://localhost:9000/manager/” but it open blank page I am expecting login page. so i get logi page need to invoke the this from custom project’s file or there is another method for the same.


Am I correct to run this command “npm run server” for open demo OpenRemote ?