Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 29 00:31

    dependabot[bot] on npm_and_yarn

    (compare)

  • Nov 29 00:31
    dependabot[bot] closed #2460
  • Nov 29 00:31
    dependabot[bot] commented #2460
  • Nov 29 00:31
    dependabot[bot] labeled #2471
  • Nov 29 00:31
    dependabot[bot] labeled #2471
  • Nov 29 00:31
    dependabot[bot] opened #2471
  • Nov 29 00:31

    dependabot[bot] on npm_and_yarn

    Bump graphiql from 1.4.2 to 1.5… (compare)

  • Nov 29 00:28

    dependabot[bot] on npm_and_yarn

    (compare)

  • Nov 29 00:28
    dependabot[bot] closed #2461
  • Nov 29 00:28
    dependabot[bot] commented #2461
  • Nov 29 00:28
    dependabot[bot] labeled #2470
  • Nov 29 00:28
    dependabot[bot] labeled #2470
  • Nov 29 00:28
    dependabot[bot] opened #2470
  • Nov 29 00:28

    dependabot[bot] on npm_and_yarn

    Bump swagger-ui-dist from 3.52.… (compare)

  • Nov 29 00:18

    dependabot[bot] on maven

    (compare)

  • Nov 29 00:18
    dependabot[bot] closed #2439
  • Nov 29 00:18
    dependabot[bot] commented #2439
  • Nov 29 00:18
    dependabot[bot] labeled #2469
  • Nov 29 00:18
    dependabot[bot] labeled #2469
  • Nov 29 00:18
    dependabot[bot] opened #2469
Nguyen Huu Tuan
@snowyukischnee
@jknack i've done configure hibernate with multiple datasources.
however the @Inject seems not work when I inject EntityManager into mvc router
Edgar Espina
@jknack
what is the error?
Nguyen Huu Tuan
@snowyukischnee
it throws NPE
Nguyen Huu Tuan
@snowyukischnee
oh i forgot
Edgar Espina
@jknack
you need two
one for each datasourcce
decorator(new TransactionalRequest(“db.first"));
Nguyen Huu Tuan
@snowyukischnee
How can I inject some class instance using GuiceModule?
Edgar Espina
@jknack
Hmm?
Nguyen Huu Tuan
@snowyukischnee
I've created a class which extends AbstractModule and put it in
install(new GuiceModule(new MyModule()))
class MyModule {
  configure() {
    bind(Repo.class).to(Impl.class);
  }
}
and I'm inject Repo.class into the mvc router, and it also throws NPE
Edgar Espina
@jknack
show me the controller
it should works that is plain Guice
Nguyen Huu Tuan
@snowyukischnee
class Router {
  @Inject
  Repo repo;

  @Path("test")
  @GET 
  String test() {
    repo.save(new TestObj());
    return "Hello";
  }
}
Edgar Espina
@jknack
show me your App where did you add the Router
Nguyen Huu Tuan
@snowyukischnee
class Repo {
  @Inject
  @Named("db.first")
  EntityManager em;

  public void save(TestObj obj) {
    em.persist(obj);
  }
}
Edgar Espina
@jknack
show me your App where did you add the Router
Nguyen Huu Tuan
@snowyukischnee
{
  mount(new RouterDef());
}
class RouterDef extends Jooby {
  {
    mvc(new Router());
  }
}
Edgar Espina
@jknack
That is wrong
Nguyen Huu Tuan
@snowyukischnee
what should i do?
Edgar Espina
@jknack
class RouterDef extends Jooby {
  {
    mvc(Router.class);
  }
}
you need to let Guice to give you an instance of Router
Nguyen Huu Tuan
@snowyukischnee
oh
Edgar Espina
@jknack
is you created an instance manually, you will get null for any dep
Nguyen Huu Tuan
@snowyukischnee
oh i see
thanks
Edgar Espina
@jknack
cool
Nguyen Huu Tuan
@snowyukischnee

@jknack
if i define the routes and mount it using mount(), then this will not works, it throws io.jooby.exception.RegistryException: Service not found

class RouterDef extends Jooby {
  {
    mvc(Router.class);
  }
}
{
  install(new GuiceModule());
  mount(new RouterDef());
}

but this works

  {
    install(new GuiceModule());
    mvc(Router.class);
  }
Nguyen Huu Tuan
@snowyukischnee
does di was not work under mount() ?
Nguyen Huu Tuan
@snowyukischnee
and, how can i use guice injection with decorator?
Pascal Le Merrer
@PascalLeMerrer
Hi. I'm new to Jooby, it looks very promising. The home page content however looks like it was spammed with links without interest.
Mészáros István
@imeszaros
@PascalLeMerrer use https://jooby.io/ instead of jooby.org.
the latter was taken over by a stranger and Edgar was unable to get it back from the provider unfortunately
If you need the docs for Jooby v1.x: https://jooby.io/v1
Pascal Le Merrer
@PascalLeMerrer
Thanks @imeszaros!
Edgar Espina
@jknack
Hi @snowyukischnee, please provide a complete example + stacktrace
Nguyen Huu Tuan
@snowyukischnee

@jknack here is my main app

{
        install(new GuiceModule(
                new DatabaseRepositoryDI(),
                new DomainServiceDI()
        ));
        // database
        final String dbName = "datasource.expr";
        install(new HikariModule(dbName));
        install(new HibernateModule(dbName).scan("com.package.entities"));
        // default error handler
        error(new DefaultHttpErrorHandler());
        // route definitions
        mvc(CustomerRouter.class); // works here
        mount(new RouteDef());
    }

here is RouteDef class

{
        before(ctx -> ctx.setResponseType(MediaType.json));
        path("/customer", () -> {
            mvc(CustomerRouter.class);
        });
    }
@Slf4j
@Singleton
@Tag(name = "Customer")
public class CustomerRouter {
        @Inject
        private MyService myService;

        @Path("/test")
        @GET
        public Object test(Context ctx) throws Exception {
                System.out.println(myService);
                return 1;
        }
}
it throws io.jooby.exception.RegistryException: Service not found if I request to /customer/test, If I request to /test only then it works
also inside DomainServiceDI class
public class DomainServiceDI extends AbstractModule {
    @Override
    protected void configure() {
        bind(MyService.class).to(MyServiceImpl.class).in(Singleton.class);
    }
}
Pascal Le Merrer
@PascalLeMerrer

Hello. I created a basic project with the Console using "create --gradle -k --server=jetty --docker --openapi io.timiiz:server:0.0.1". When I follow the instructions and type ./gradlew joobyRun, it says it cannot find org.gradle.wrapper.GradleWrapperMain. I verified, gradle/wrapper/gradle-wrapper.jar is present. When running gradle without the wrapper, I 've several build errors :

gradle build

Task :compileTestKotlin FAILED
w: Classpath entry points to a non-existent location: /Users/peal6230/Documents/dev/projects/timiiz/io.timiiz
w: Classpath entry points to a non-existent location: server
w: Classpath entry points to a non-existent location: 0.0.1/build/classes/kotlin/main
e: /Users/peal6230/Documents/dev/projects/timiiz/io.timiiz:server:0.0.1/src/test/kotlin/io/timiiz/IntegrationTest.kt: (11, 12): Unresolved reference: App
e: /Users/peal6230/Documents/dev/projects/timiiz/io.timiiz:server:0.0.1/src/test/kotlin/io/timiiz/IntegrationTest.kt: (11, 12): An annotation argument must be a compile-time constant
e: /Users/peal6230/Documents/dev/projects/timiiz/io.timiiz:server:0.0.1/src/test/kotlin/io/timiiz/UnitTest.kt: (12, 29): Unresolved reference: App

I published the project at https://github.com/PascalLeMerrer/jooby-test.

Edgar Espina
@jknack
looks like a bug in the generator
delete/remove the test directory: /Users/peal6230/Documents/dev/projects/timiiz/io.timiiz:server:0.0.1/src/test
hmm also
not sure about the : in project folder
io.timiiz:server:0.0.1
Pascal Le Merrer
@PascalLeMerrer
the project folder is named like this because I understood the generator said the name parameter should be "Application name or coordinates (groupId:artifactId:version)". I was surprised it used this for naming the folder.
Edgar Espina
@jknack
yea think it is another bug
Pascal Le Merrer
@PascalLeMerrer
It's much better when renaming the folder to something more conventional :)