Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 23 13:51
    vellrya edited #2598
  • May 23 13:23
    vellrya opened #2598
  • May 23 10:01
    jknack labeled #2594
  • May 23 10:01
    jknack labeled #2594
  • May 23 10:01
    jknack commented #2594
  • May 23 07:18
    walkman90 commented #2594
  • May 23 00:45
    jknack milestoned #2596
  • May 23 00:45
    jknack milestoned #2594
  • May 23 00:45
    jknack labeled #2596
  • May 23 00:45
    jknack labeled #2596
  • May 23 00:45
    jknack labeled #2596
  • May 23 00:44
    jknack closed #2596
  • May 23 00:44
    jknack commented #2596
  • May 23 00:38
    dependabot[bot] labeled #2597
  • May 23 00:38
    dependabot[bot] labeled #2597
  • May 23 00:38
    dependabot[bot] opened #2597
  • May 23 00:38

    dependabot[bot] on maven

    build(deps): bump nexus-staging… (compare)

  • May 23 00:20
    jknack edited #2596
  • May 23 00:16
    jknack opened #2596
  • May 23 00:13
    dependabot[bot] labeled #2595
Hashim Sayyid
@Sayyiditow
  1. I would prefer undertow but since this is an embedded servlet, does not really matter.
  2. Its more of a preference again. I would use MVC style for huge apps to separate the diff concerns and not have everything in one huge file.
Edgar Espina
@jknack
Antoine DAVID
@antoinedvd

Hi folks, someone has already create a Unit Test for resource with an App that use the Hikari Module ?
I follow this link jooby-project/jooby#1891 but I don't understand how to mock Hikari ?
For me it's not possible due to this line (https://github.com/jooby-project/jooby/blob/34eb70cf2583e317d3c77f94d165bc8be7520bb5/modules/jooby-hikari/src/main/java/io/jooby/hikari/HikariModule.java#L209).
My App.java code :

public class App extends Jooby {
    {
        install(new HikariModule());
[...]
    }
}

The unit test execute the new HikariModule() that try to create a connection to a database...
My unit test method :

    @Test
    @SneakyThrows
    void getSensors() {
        final var router = new MockRouter( new App());
}
Marcel Stör
@marcelstoer
@jknack will you consider merging jooby-project/jooby#2370 to fix a critical security issue (at least reported as critical) for 1.x?
Facundo Parra
@facup94

Hi! I'm having some issues combining dynamic routing (mount with predicates) and DI with Guice and mvc() primitives.
This is throwing "Service not found" exception

public class V1 extends Jooby {
  {
    install(new GuiceModule());
    mvc(PingController.mvc);
  }
}

public class App extends Jooby {
  {
    mount(ctx -> ctx.header("version").value().equals("v1"), new V1()); 
  }
}
curl localhost:8080/ping
io.jooby.exception.RegistryException: Service not found: project.controllers.PingController

How can I solve it?

Facundo Parra
@facup94

This also fails. I don't understand really how mvc + Guice primitives work.

Jooby app = new Jooby();
app.install(new GuiceModule());
app.mvc(PingController.class);
mount(app);

But this works:

mvc(PingController.class);
Edgar Espina
@jknack
Toriga
@Master-Antonio
Hi guys, im a full stack developer and i work in enterprise from 5 years
I love golang, but i always used Spring for my clients
I would like to know about jooby, how much is mature to replace Spring?
Im interested about jooby because i saw is so fast, and i like the syntax ...
xammax73
@xammax73
Hi, Edgar. Its my repo. Can I create my repositories in this style? https://github.com/xammax73/jooby
And how in this repo to do transactional scheme?
If i u
If I use repo without route
xammax73
@xammax73
How to create control to transaction status that equal transaction decorator from route?
Edgar Espina
@jknack
Jonathan Ryan
@jryan128
Is there a way to inject context into an object with dagger?
Jonathan Ryan
@jryan128
I guess I'd need to interface with the service registry and context
Jonathan Ryan
@jryan128
Figured it out, made my Jooby app a Module and created a @Provides for context and setContextAsService(true) then use provider syntax for mvc with a dagger factory
@Module
public class App extends Jooby {

    public App() {
        setContextAsService(true);
        install(new GracefulShutdown());
        install(new OpenAPIModule());

        decorator(new AccessLogHandler());
        decorator(new CorsHandler());
//        decorator(new TracingHandler());

        var endpointFactory = HelloEndpoint_Factory.create(() -> require(Context.class));
        mvc(HelloEndpoint.class, endpointFactory);
    }

    @Provides
    public Context bindEndpoint() {
        return require(Context.class);
    }
xammax73
@xammax73
If this written for me, no, i use guice. It works, but sometimes I get the problems with hibernate transactions with status not active.
xammax73
@xammax73
And yes, works YransaqionRequest from jooby 2.9.5.
TransactionRequest
With SessionRequest
cyberquarks
@cyberquarks

I have this SSE code but the server does not send events to the browser:

sse("/events/{eventId}", sse -> {
      // if we go down, recover from last event ID we sent. Otherwise, start from zero.
      int lastId = OptionalInt.of(sse.lastEventId(Integer.class)).orElse(0);

      AtomicInteger next = new AtomicInteger(lastId);

      ScheduledFuture<?> future = executor.scheduleAtFixedRate(() -> {
        Integer id = next.incrementAndGet();
        String data = "test " + id;
        sse.send(data);
//        sse.send(
//                new ServerSentMessage(data)
//                        .setId(id)
//                        .setRetry(1000L)
//        );
      }, 0, 1, TimeUnit.SECONDS);
      sse.keepAlive(15, TimeUnit.SECONDS);
      sse.onClose(() -> {
        future.cancel(true);
      });
    });

And another question how do you get the path parameter within an SSE, like how can I get the eventId in this case?

Mészáros István
@imeszaros
Gradle 7.3 final is out with official Java 17 support. @jknack any chance for a Jooby release with #2445 and #2267 ? :angel:
costa100
@costa100

Scala & Jooby - did anyone use scala with jooby? I created this simple app:

`package app

import io.jooby.
import io.jooby.annotations.

@Path(Array("/scala"))
class ScalaController {

@GET(Array("/{id}"))
def sayHi(ctx: Context, @PathParam id: String) = s"Welcome to another Jooby,- $id! ${ctx.getRequestURL()}"

}

class JoobyApp extends Jooby {
mvc(new ScalaController())
}

object JoobyApp {
def main(args: Array[String]): Unit = {
Jooby.runApp(args, classOf[App])
}
}
`
It compiles and runs but it seems that jooby doesn't take into account the annotations. I am going to keep digging but I was curious if anyone tried it.

costa100
@costa100

Corrected version:

package app

import io.jooby._
import io.jooby.annotations._

@Path(value = Array("/scala"))
class ScalaController {

  @GET(value = Array("/{id}"))
  def sayHi(ctx: Context, @PathParam id: String) =  s"Welcome to another Jooby,- $id! ${ctx.getRequestURL()}"

}

class JoobyApp extends Jooby {

  mvc(new ScalaController())
}



object JoobyApp {
  def main(args: Array[String]): Unit = {
     Jooby.runApp(args, classOf[JoobyApp])
  }
}

I get this error:
Caused by: io.jooby.Usage: Router not found: app.ScalaController. Make sure Jooby annotation processor is configured properly.
For more details, please visit: https://jooby.io/usage#annotation-processing-tool-router-not-found

//decompiled from ScalaController.class
package app;

import io.jooby.Context;
import io.jooby.annotations.GET;
import io.jooby.annotations.Path;
import io.jooby.annotations.PathParam;
import scala.reflect.ScalaSignature;

@Path({"/scala"})
@ScalaSignature(
   bytes = "\u0006\u0005\u00053Aa\u0001\u0003\u0001\u000f!)a\u0002\u0001C\u0001\u001f!)!\u0003\u0001C\u0001'\ty1kY1mC\u000e{g\u000e\u001e:pY2,'OC\u0001\u0006\u0003\r\t\u0007\u000f]\u0002\u0001'\t\u0001\u0001\u0002\u0005\u0002\n\u00195\t!BC\u0001\f\u0003\u0015\u00198-\u00197b\u0013\ti!B\u0001\u0004B]f\u0014VMZ\u0001\u0007y%t\u0017\u000e\u001e \u0015\u0003A\u0001\"!\u0005\u0001\u000e\u0003\u0011\tQa]1z\u0011&$2\u0001F\u0010*!\t)BD\u0004\u0002\u00175A\u0011qCC\u0007\u00021)\u0011\u0011DB\u0001\u0007yI|w\u000e\u001e \n\u0005mQ\u0011A\u0002)sK\u0012,g-\u0003\u0002\u001e=\t11\u000b\u001e:j]\u001eT!a\u0007\u0006\t\u000b\u0001\u0012\u0001\u0019A\u0011\u0002\u0007\r$\b\u0010\u0005\u0002#O5\t1E\u0003\u0002%K\u0005)!n\\8cs*\ta%\u0001\u0002j_&\u0011\u0001f\t\u0002\b\u0007>tG/\u001a=u\u0011\u0015Q#\u00011\u0001\u0015\u0003\tIG\r\u000b\u0002*YA\u0011Q\u0006M\u0007\u0002])\u0011qfI\u0001\fC:tw\u000e^1uS>t7/\u0003\u00022]\tI\u0001+\u0019;i!\u0006\u0014\u0018-\u001c\u0015\u0005\u0005M2t\u0007\u0005\u0002.i%\u0011QG\f\u0002\u0004\u000f\u0016#\u0016!\u0002<bYV,G&\u0001\u001d\"\u0003e\nQaL>jIvDC\u0001A\u001e7}A\u0011Q\u0006P\u0005\u0003{9\u0012A\u0001U1uQ2\nq(I\u0001A\u0003\u0019y3oY1mC\u0002"
)
public class ScalaController {
   @GET({"/{id}"})
   public String sayHi(final Context ctx, @PathParam final String id) {
      return (new StringBuilder(29)).append("Welcome to another Jooby,- ").append(id).append("! ").append(ctx.getRequestURL()).toString();
   }
}
costa100
@costa100
ok, scala works without annotations. Annotations seem to be a rabbit hole. I am not exactly sure how annotations work with jooby - is it a runtime feature or is it compile time? Processing the annotations in scala needs to be an additional step where the javac compiler is invoked.
package app

import io.jooby._
import io.jooby.annotations._

@Path(value = Array("/scala"))
class ScalaController {

  @GET(value = Array("/{id}"))
  def sayHi(ctx: Context, @PathParam id: String) =  s"Welcome to another Jooby,- $id! ${ctx.getRequestURL()}"

}

class JoobyApp extends Jooby {

  //mvc(new ScalaController())
  get("/scala",  (ctx) => "Testing") // <- this works!
}



object JoobyApp {
  def main(args: Array[String]): Unit = {
     Jooby.runApp(args, classOf[JoobyApp])
  }
}
Lars George
@Xerxekyran

Hi there, I have two problems with the OpenApi generation of Jooby 2.x:

  • One thing is that I do not get the json I expect for the return type java.util.Map ( jooby-project/jooby#2505 )
  • Another problem is the parameter type byte[] (in the RequestBody). Here I end up with a List<int?> in C# after generating the classes from the generated OpenApi json. The schema type changed from Jooby 1.x: "schema": {"type": "string", "format": "byte"} to the following in Jooby 2.x: "schema" : { "maximum" : 127, "minimum" : -128, "type" : "integer", "format" : "int32" }

Am i doing something wrong or is this not yet implemented correctly?

Ragnar Rova
@rrva
@jknack how do I rewrite incoming request paths in 1.x (just strip off first path component)
Ravi Hasija
@RaviH
Hello, has anybody got Graalvm working with Jooby? Sample project?
martinbe1io
@martinbe1io
@jknack can you give me a hint how i dynamically change the attributes of the session cookie (eg secure flag, domainstart with .) in joony 1.6.9? challenge is that i cant use the session.cookie… in .conf as it is a Multi domain site. See issue #2540 as well thx
LisandroTesta-Meli
@LisandroTesta-Meli
@jknack Hello, Jooby in the latest version (2.13.0) is using dependencies with know critics vulnerabilities, the dependencies with this problems are: io.netty/netty-codec:4.1.73.Final need to be updated to 4.1.74.Final and com.google.code.gson/gson:2.8.6 need to be updated to 2.9.0 its posible that your team update those libraries? when it can be done?
Lars George
@Xerxekyran
Hi, thanks for accepting the openapi changes! Just so I know when I can update my Jooby dependency with the fixes, are there any plans for the next release version?
Ragnar Rova
@rrva

@jknack When upgrading from 1.x to 2.x in a kotlin app, I noticed that CompletableFuture responses get converted to literal json instead of the response... so jooby 2.13.0 sends

{
  "done": true,
  "cancelled": false,
  "completedExceptionally": false,
  "numberOfDependents": 0
}

for code like

post("/foo") { ctx ->
  val completableFuture = asyncFoo()
  completableFuture
}

In 1.x you had to register AsyncMapper() to get this right. How to do it in 2.x? The docs seem to state that CompletableFuture responses are supported out-of-the-box. I use the JacksonModule and want a JSON response of the completablefutures value

Edgar Espina
@jknack
@rrva works on Java… probably there is a bug with kotlin
Ragnar Rova
@rrva
@jknack jooby-project/jooby#2553 I found the case where the analyzer thinks the route handler return type is Object
@jknack also, you mention that you cannot use after handlers in the pipeline if you use async responses. What is a good pattern to modify the outgoing response headers depending on some value in a completablefuture response (I want to set cache headers differently depending on the response)
Ragnar Rova
@rrva
@jknack is jooby 2.13.1 planned soon?
Edgar Espina
@jknack
I’m trying to upgrade to latest kotlin, without luck yet. I’m block on open-api integration
will keep trying a bit more, if I can’t do it going to to make a release with current fixes
Ragnar Rova
@rrva
@jknack what problems are there?
amir hasanebrahimi
@doki244
hi I want research about jooby which source you recommend except jooby.io
Edgar Espina
@jknack
@doki244 that's all :D
Lars George
@Xerxekyran
Edgar Espina
@jknack
Going to work on jooby 3, which is going require Java 11 as minimum. I can’t update some major libraries bc all them now requires Java 11
David (javalin.io)
@tipsy
jetty? :D