Compiler complaining that "use(new Hbs())" Required Type: Router?

25 views
Skip to first unread message

niko...@brightminds.org

unread,
Nov 21, 2020, 4:55:45 AM11/21/20
to jooby-project
Hello,

I imagine there is a very simple solution to this problem but after many hours cannot figure out what should be quite trivial.  BTW I am using IntelliJ IDEA....

I created a mvc project using the jooby-cli and am trying to work with Handlebars.java

So I have a main class that is below and the line use(new Hbs()) has 2 issues:
1. "use" is deprecated in favour of "mount" (changing it does not help) and
2. compiler is complaining that new Hbs() has Hbs provided but required type is router.  This makes no sense????

package app;
import io.jooby.Jooby;
import org.jooby.hbs.Hbs;
public class App extends Jooby {
  {
     use(new Hbs());
     mvc(new Controller());
   }
   public static void main(final String[] args) {
      runApp(args, App::new);
   }
}

My pom file is using:
...
<jooby.version>2.9.3</jooby.version>
<jooby.hbs.version>1.6.8</jooby.hbs.version>
<handlebars.java.version>4.2.0</handlebars.java.version>
...
<distributionManagement>
  <relocation>
    <groupId>io.jooby</groupId>
  </relocation>
</distributionManagement>
...
<dependency>
  <groupId>org.jooby</groupId>
  <artifactId>jooby-hbs</artifactId>
  <version>${jooby.hbs.version}</version>
</dependency>
<dependency>
  <groupId>com.github.jknack</groupId>
  <artifactId>handlebars.java</artifactId>
  <version>${handlebars.java.version}</version>
  <type>pom</type>
</dependency>

István Mészáros

unread,
Nov 21, 2020, 5:04:22 AM11/21/20
to jooby-project
Hi! Is that a module, right? Then try install() instead of use/mount. Hop it helps!

niko...@brightminds.org

unread,
Nov 21, 2020, 5:12:10 AM11/21/20
to jooby-project
Thanks for the quick reply.  It indeed is a module however if I try:
    install(new Hbs());

The compiler now says:  Required Type: Extension  provided: Hbs

What is more odd is that the docs are clear about using "use":

it is almost like jooby is not reading the "use" properly.  Perhaps there is something wrong in my pom.xml (I'm attaching it just in case I am missing something obvious)

Thank You,

--Nikolaos

pom.xml

István Mészáros

unread,
Nov 21, 2020, 5:17:13 AM11/21/20
to jooby-project

Now I see what the problem is. Youre using Jooby 2.x but trying to install a module what was made for Jooby 1.x. Declare the correct dependency:

<dependency> <groupId>io.jooby</groupId> <artifactId>jooby-handlebars</artifactId> <version>2.9.3</version> </dependency

Furthermore, ignore the documentation under  https://jooby.io/v1 , its not relevant for 2.x

niko...@brightminds.org

unread,
Nov 21, 2020, 5:27:53 AM11/21/20
to jooby-project
That was exactly the issue and I knew that there was a 1.x and 2.x but it seems I accidentally pulled up the 1.0 Handlebars docs.
Should have known when I looked at the jooby-hbs maven repo and it said it had moved to io.jooby that something was up....

Thank You so Much!

--Nikolaos

Reply all
Reply to author
Forward
0 new messages