ONOS app development

466 views
Skip to first unread message

Luis Casarrubios Élez

unread,
Feb 22, 2022, 1:18:32 PM2/22/22
to ONOS Discuss
Hi!

I want to develop my own ONOS app. 

I have just installed ONOS on my local machine and properly configured the IDE as suggested here:

My question is regarding the following steps since I have seen some tutorials, but they use Maven or Buck to build those apps, and I should use Bazel, right?

Are there any up-to-date tutorials? Are those other tutorials still valid?

I appreciate your help.

Thank you!

Luis C.

0ice...@gmail.com

unread,
Feb 22, 2022, 1:33:09 PM2/22/22
to ONOS Discuss, Luis Casarrubios Élez
Hi Luis,

Here the guide for creating/developing your ONOS app https://wiki.onosproject.org/display/ONOS/Template+Application+Tutorial

Best
Davide

Luis Casarrubios Élez

unread,
Feb 22, 2022, 1:38:33 PM2/22/22
to ONOS Discuss, 0ice...@gmail.com, Luis Casarrubios Élez
Thank you Davide for your answer.

That's the tutorial I already saw, and it mentions Maven archetypes, but I built ONOS and configured my IDE using Bazel...

I don't see the compatibility between them.

Best,
Luis

0ice...@gmail.com

unread,
Feb 22, 2022, 2:03:23 PM2/22/22
to ONOS Discuss, Luis Casarrubios Élez, 0ice...@gmail.com
Hi Luis,

You should read carefully the guide. Moreover the IDE + Bazel helps you to navigate/have fully visibility of the ONOS core code. You still utilize your IDE for developing any kind of java program.  So, you can create the template of your onos application following the guide and once you import the into the IDE you 'll not have any issues. The only things that you have to take care is importing the maven dependencies as is written in the guide. 

More in details, ONOS is builted/deployed via bazel but you are able to load additional application, once it's running, because it utilizes OSGi components. So, via maven you create the .oar file , of your application,  and you can load on ONOS. 

Best
ds

Luis Casarrubios Élez

unread,
Feb 22, 2022, 2:45:53 PM2/22/22
to ONOS Discuss, 0ice...@gmail.com, Luis Casarrubios Élez
Alright, I think I get it now.

ONOS is built using Bazel, but the template generator remains using Maven. So, once I generate the app with the proper Maven dependencies, I can open and modify its source code in the IDE.

And, regarding the POM version... if I am running ONOS 3.0.0, I should set:
$ export ONOS_POM_VERSION=3.0.0
Right?

Thank you very much.

Luis

0ice...@gmail.com

unread,
Feb 22, 2022, 2:50:24 PM2/22/22
to ONOS Discuss, Luis Casarrubios Élez, 0ice...@gmail.com
Hi Luis,

Should be 3.0.0-SNAPSHOT
Best,
Davide

Luis Casarrubios Élez

unread,
Feb 22, 2022, 6:06:15 PM2/22/22
to ONOS Discuss, 0ice...@gmail.com, Luis Casarrubios Élez
Hi Davide,

After following carefully all the steps described in the tutorial, I obtain this error when executing in '/foo-app' the '$ mvn clean install' command:

[INFO] Compiling 3 source files to /Users/luis/onos/foo-app/target/classes
An exception has occurred in the compiler (17.0.2). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.IllegalAccessError: class com.google.errorprone.ErrorProneJavacPlugin (in unnamed module @0x433ea2ac) cannot access class com.sun.tools.javac.api.BasicJavacTask (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.api to unnamed module @0x433ea2ac
        at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:38)
        at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:255)
        at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:229)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.prepareCompiler(JavacTaskImpl.java:204)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:101)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
        at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1129)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:188)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:972)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.090 s
[INFO] Finished at: 2022-02-22T17:00:39-06:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project foo-app: Compilation failure
[ERROR] An unknown compilation problem occurred
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Any suggestion? 

Best, 
Luis

Eder

unread,
Feb 23, 2022, 10:47:19 AM2/23/22
to ONOS Discuss, Luis Casarrubios Élez, 0ice...@gmail.com
Hi!

Could you share your project in a zip file? I might try to build it myself.

To complement the words of Davide, you can develop apps in two ways, as independent apps (oar packages) or as part of the ONOS core. If you create an app that is part of the ONOS code, you build the entire ONOS project all together, which will also build your app. I think that if you have any errors, Bazel can identify what has ben built already and you should not wait a long time to rebuild ONOS (and your app). If you create an independent app you have to build it with Maven, which results into an .oar package file. You then install it with the onos-app command. If you configure everything correctly, IntelliJ IDEA should offer you automcomplete functionalities when you program your own app, which helps a lot. 

Cheers,

Luis Casarrubios Élez

unread,
Feb 23, 2022, 12:55:30 PM2/23/22
to ONOS Discuss, Eder, Luis Casarrubios Élez, 0ice...@gmail.com
Hi Eder!

Here is a link to my project zip file, I really appreciate your help. I'm using macOS, just in case is a relevant information.

Since it is an unknown error with the java compiler, there must be some incompatibility with the Maven/ONOS version that I am using, I guess... So my next troubleshooting steps were intended to downgrade Maven version, ONOS', or both of them in the worst case.

I am really interested in that possibility you mentioned for developing apps "inside" the ONOS code with Bazel, since I have properly configured the IntelliJ IDEA environment and all my troubles started with Maven. However, all the tutorials and guides I have seen so far begin with the app template after calling the "$ onos-create-app ..." command, so I don't know where to start from with this alternative.

Thank you!
Best,
Luis

Eder

unread,
Feb 23, 2022, 2:17:15 PM2/23/22
to ONOS Discuss, Luis Casarrubios Élez, Eder, 0ice...@gmail.com
Hi, 

I will try to test the code. I suspect that macOS could be a problem here, but I am not sure. Let me check it in an Ubuntu VM.

Also, where exactly is the app? You posted ONOS that is nearly 500 MB, but not sure what is the name of the app (foo-app?) and where it is located.

Cheers,

Eder

unread,
Feb 23, 2022, 2:47:41 PM2/23/22
to ONOS Discuss, Eder, Luis Casarrubios Élez, 0ice...@gmail.com
Hi Luis,

Please do not drop ONOS mail, or it does not appear on Google Groups anymore :)

As I see, it builds fine from your output (see BUILD SUCCESS) output.

Not sure if your problem is another one, but that app seems fine from the text you posted.

Let us know if the issue is another one.

Cheers,

So sorry, I deleted/created the project several times so it was missing on my ONOS project filesystem when compressing. This is just the foo-app directory after calling the '$onos-create-app' command:

This is the output it generated, just in case is useful for you:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.2.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.2.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.2.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository not defined. Using the one from [org.onosproject:onos-bundle-archetype:3.0.0-SNAPSHOT] found in catalog local
[INFO] Using property: onosVersion = 3.0.0-SNAPSHOT
[INFO] Using property: groupId = org.foo
[INFO] Using property: artifactId = foo-app
[INFO] Using property: version = 1.0-SNAPSHOT
[INFO] Using property: package = org.foo.app
Confirm properties configuration:
onosVersion: 3.0.0-SNAPSHOT
groupId: org.foo
artifactId: foo-app
version: 1.0-SNAPSHOT
package: org.foo.app
 Y: : Y
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: onos-bundle-archetype:3.0.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.foo
[INFO] Parameter: artifactId, Value: foo-app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.foo.app
[INFO] Parameter: packageInPathFormat, Value: org/foo/app
[INFO] Parameter: package, Value: org.foo.app
[INFO] Parameter: groupId, Value: org.foo
[INFO] Parameter: artifactId, Value: foo-app
[INFO] Parameter: onosVersion, Value: 3.0.0-SNAPSHOT
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Project created from Archetype in dir: /Users/luis/onos/foo-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.111 s
[INFO] Finished at: 2022-02-23T13:25:29-06:00
[INFO] ------------------------------------------------------------------------

Thank you!

Luis Casarrubios Élez

unread,
Feb 23, 2022, 2:59:18 PM2/23/22
to ONOS Discuss, Eder, Luis Casarrubios Élez, 0ice...@gmail.com
Hi Eder, 

Yes, the issue is when I try to run "$mvn clean install" inside foo-app that I get the error that I was trying to troubleshoot with Davide:
$ cd foo-app/
$ mvn clean install

[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< org.foo:foo-app >---------------------------
[INFO] Building foo-app 1.0-SNAPSHOT
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ foo-app ---
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-maven) @ foo-app ---
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (enforce-java) @ foo-app ---
[INFO]
[INFO] --- onos-maven-plugin:2.4.0:swagger (swagger) @ foo-app ---
[INFO]
[INFO] --- onos-maven-plugin:2.4.0:cfg (cfg) @ foo-app ---
[INFO] Generating ONOS component configuration catalogues...
[INFO] Processing property someProperty|STRING|Some Default String Value|Some configurable property. ...
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ foo-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/luis/onos/foo-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ foo-app ---
[INFO] Changes detected - recompiling the module!

[INFO] Compiling 3 source files to /Users/luis/onos/foo-app/target/classes
An exception has occurred in the compiler (17.0.2). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.IllegalAccessError: class com.google.errorprone.ErrorProneJavacPlugin (in unnamed module @0x12952aff) cannot access class com.sun.tools.javac.api.BasicJavacTask (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.api to unnamed module @0x12952aff
[INFO] Total time:  2.026 s
[INFO] Finished at: 2022-02-23T13:58:24-06:00

[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project foo-app: Compilation failure
[ERROR] An unknown compilation problem occurred
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Eder

unread,
Feb 23, 2022, 5:48:48 PM2/23/22
to ONOS Discuss, Luis Casarrubios Élez, Eder, 0ice...@gmail.com
Hi,

Your app fails in my Lubuntu 21 VM. But my default app does not. I believe this could be because your ONOS_POM_VERSION set to 3.0.0, but I am not sure (see the error at the end). I think that ONOS_POM_VERSION has to follow the ONOS version you clone. I checked out 2.5.0 so that is mine, compare our pom.xml files:

Additionally, I will add a bash script (I have not tested it, so DO NOT RUN IT. It just has commands pasted) with all the steps I followed from a vanilla Lubuntu 21 Virtualbox VM to install all dependencies and then be able to build ONOS and a maven app.


Mine:
    <parent>
        <groupId>org.onosproject</groupId>
        <artifactId>onos-dependencies</artifactId>
        <version>2.5.0</version>
    </parent>


Yours:
   <parent>
        <groupId>org.onosproject</groupId>
        <artifactId>onos-dependencies</artifactId>
        <version>3.0.0-SNAPSHOT</version>
    </parent>


See the error I got when building yours:

eoza@onosvm:~/Downloads/foo-app$ mvn clean install -DskipTests
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.foo:foo-app:1.0-SNAPSHOT: Could not find artifact org.onosproject:onos-dependencies:pom:3.0.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 20, column 13
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]  
[ERROR]   The project org.foo:foo-app:1.0-SNAPSHOT (/home/eoza/Downloads/foo-app/pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for org.foo:foo-app:1.0-SNAPSHOT: Could not find artifact org.onosproject:onos-dependencies:pom:3.0.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 20, column 13 -> [Help 2]

[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:


Hope it helps.

Cheers,

Eder

unread,
Feb 23, 2022, 5:49:52 PM2/23/22
to ONOS Discuss, Eder, Luis Casarrubios Élez, 0ice...@gmail.com
Oh Sorry, the script is here :)
dependencies.sh

Luis Casarrubios Élez

unread,
Mar 1, 2022, 1:10:27 PM3/1/22
to ONOS Discuss, Eder, Luis Casarrubios Élez, 0ice...@gmail.com
Hi Eder, 

I'm sorry I couldn't reply sooner, but I have some other projects in parallel.

Finally, I could solve this! After reviewing your script, I checked my Maven version just in case and I realised that it used jdk 17.0.2 for some reason. So all I had to do is to change the JAVA_HOME to force Maven to use the one that I have installed here.

So, for MacOS (Big Sur in my case) users in the future if they face any similar error, this made the trick for me:
$ export JAVA_HOME=$(/usr/libexec/java_home)

Thank you very much for your help!

Luis
Reply all
Reply to author
Forward
0 new messages