by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:49
    dependabot-preview[bot] labeled #1842
  • 06:49
    dependabot-preview[bot] labeled #1842
  • 06:49
    dependabot-preview[bot] opened #1842
  • 06:49

    dependabot-preview[bot] on maven

    build(deps): bump netty.version… (compare)

  • Jul 09 23:28
    imeszaros opened #1841
  • Jul 09 06:59
    dependabot-preview[bot] labeled #1840
  • Jul 09 06:59
    dependabot-preview[bot] labeled #1840
  • Jul 09 06:59
    dependabot-preview[bot] opened #1840
  • Jul 09 06:59

    dependabot-preview[bot] on maven

    build(deps): bump caffeine from… (compare)

  • Jul 07 19:33
    jknack commented #1808
  • Jul 07 19:05
    moromindful commented #1808
  • Jul 07 11:39
    jknack milestoned #1839
  • Jul 07 11:39
    jknack labeled #1839
  • Jul 07 11:39
    jknack labeled #1839
  • Jul 07 08:33
    csisy closed #1839
  • Jul 07 08:33
    csisy commented #1839
  • Jul 07 08:26
    walkman90 commented #1839
  • Jul 07 08:20
    csisy opened #1839
  • Jul 07 07:14
    dependabot-preview[bot] labeled #1838
  • Jul 07 07:14
    dependabot-preview[bot] labeled #1838
Marcel Stör
@marcelstoer
Q6. There is no equivalent to environment-based feature toggles (on("environment")) in 2.x? Other than using if (environment.isActive("environment")).
Edgar Espina
@jknack
@marcelstoer
Q3. Hasim is right. It is: error((ctx, cause, code) -> {….}). Request and Response are merged into Context in 2.x. wrapper exception: org.jooby.Err is gone. Instead you have cause (original error) and code suggested status code
Q4. Jackson:
ObjectMapper mapper = JsonMapper.builder()
        .addModule(new ParameterNamesModule())
        .addModule(new Jdk8Module())
        .addModule(new JavaTimeModule())
        .addModule(new AfterburnerModule())
        .addModule(new KotlinModule())
        .build();

install(new Jackson(mapper));
Q5. ctx.setResponseType(JSON).setResponseCode(statusCode).send(myContent);
Edgar Espina
@jknack
Q6. Environment callbacks are gone. 2.x simplifies the configuration and enviroment access, so it is available at construction/init time (not at startup time like in 1.x). This simplifies everything and makes env callbacks useless:
{
   Environment env  = getEnvironment();
  if (env.isActice(“…”)) {
     // .. do something
  }
}
same for Config, you can check/test any property
Marcel Stör
@marcelstoer
Q4. I would argue that my example is probably more idomatic Jooby as all but the Kotlin Jackson module are part of the default object mapper you create in io.jooby.json.JacksonModule#create. The effect is the same, though.
Q5. I don't see how your example would work. I don't see a Context#send()implementation that accepts a generic type, only bytes, streams, etc. and string. Hence, I used Jackson to serialize my object first. I'm puzzled.
Q6. I'm using env.isActice("…") to guard calls against install to avoid installing extensions I don't need.
Edgar Espina
@jknack
Q5. Yea, so do ctx.render
Marcel Stör
@marcelstoer
Yep, that makes more sense.
Do you have any plans to migrate the metrics extension to 2.x?
Edgar Espina
@jknack
no plan yet
which metrics module exactly?
Marcel Stör
@marcelstoer
Marcel Stör
@marcelstoer

I'm slowly getting to terms with Jooby 2.x in my migration efforts :-/ DI is a bit of a mystery still but I want to preserve much of the Guice-based code I have.

I know I can/should migrate this

override fun configure(env: Env, conf: Config, binder: Binder) {
    binder.bind(Some::class.java).toInstance(Some())

to

override fun install(app: Jooby) {
    app.services.put(Some::class.java, Some())

However, what about classes that require Guice constructor injection and can thus not be instantiated directly and registered as a service? Example:

binder.bind(Some::class.java).`in`(Scopes.SINGLETON)
binder.bind(MyInterface::class.java).to(Some::class.java)
...
class Some @Inject constructor(foo: Foo) : MyInterface {

And what about invocations to the Guice multibinder while configuring/installing an extension? Current example: Multibinder.newSetBinder(binder, TransactionListener::class.java).addBinding().toInstance(MyTransactionLogger())

Edgar Espina
@jknack
@marcelstoer look at the guice example/doc: https://jooby.io/#dependency-injection-guice
You can do something like:
install(new GuiceModule(new MyGuiceModule(this)));
then MyGuiceModule will be something like:
import com.google.inject.AbstractModule;

class MyGuiceModule extends AbstractModule {
    private Jooby app;
    public MyGuiceModule(Jooby app) {
     this.app = app;
   }

  @Override
          protected void configure() {
              bind(Some::class.java).in(Scopes.SINGLETON);
          }
}
So if your module is already Guice friendly, I suggest you to extends AbstractModule (or implements Guice module) which give you access to the Binder already
No need to migrate them as Jooby Extension
cool?
Edgar Espina
@jknack
Hashim Sayyid
@Sayyiditow
Did 2.8.8 break the "ERR_TOO_MANY_REDIRECTS" issue that was fixed last time? After logging out, the app is now back to "ERR_TOO_MANY_REDIRECTS" whenever you visit any page. The issue in reference is #1737.
@jknack
Seems to be broken now, pac4j module doesnt work as expected. if you remove the pac4j module, the app is accessible, the moment you install the pac4j module, everything breaks with "ERR_TOO_MANY_REDIRECTS" on the web page.
Hashim Sayyid
@Sayyiditow
This could have been broken from 2.8.6 though, as I have jumped from 2.8.5 to 2.8.8. I will test 2.8.6 and 2.8.7.
2.8.6 is fine. The break happened on version 2.8.7 which was inherited to 2.8.8. I can't seem to see what changed in pac4j module on 2.8.7.
I'll open an issue.
LongkerDandy
@longkerdandy
Hi, I have a question about Cors, when using CorsHandler with MvcHandler, I added @Consumes(MediaType.JSON) to the mvc class, the Cors preflight request will result UnsupportedMediaType exception because the preflight request has null media type.
Right now I have to comment out the @Consumes annotation
Edgar Espina
@jknack
@longkerdandy can you file at github? Please add an example
Hashim Sayyid
@Sayyiditow
@jknack hi, for the "ERR_TOO_MANY_REDIRECTS" issue. I am not sure how to explain what is causing it. The moment I remove the line:
install(new Pac4jModule().client("/dashboard*", config -> new FormClient("/login", userAuthenticatorService)));
The app works, but if I install the module, the error comes back. Is it the redirect sending to the /login page which is causing this? The issue does not seem to be related with the sessionStore or csrfHandler as with/without them, the error still persists.
Yeah, I think there are too many redirects the the loginUrl (/login) which is related to the FormClient. When visiting any url, it tries to redirect to /login for some reason.
Edgar Espina
@jknack
williamjtodd
@williamjtodd
Hi, I feel like I'm missing something. I can't find docs for Mongo in V2? Is there no module in v2?
Edgar Espina
@jknack
Yea, there is no mongo module for v2
williamjtodd
@williamjtodd
Thanks. I have another question now:
I've created an extension for Mongo.
I'm not clear on how to do this, from any class or location I need it:
datastore = require(Datastore::class)
Is it possible, or only from an "App" that extends Kooby?
Edgar Espina
@jknack
@williamjtodd sorry for my late response
Extensions and Services are documented here: https://jooby.io/#extensions-and-services
services are a map-like strucuture where you can put a service, which is later retrieved using a require call
Alex B.
@k1ll1n
Hello!
Why am I getting an error while uploading a file to the server?
16:26:56.506 [eventloop-4-1] DEBUG app.App - body decoder destroy resulted in exception
io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1
    at io.netty.util.internal.ReferenceCountUpdater.toLiveRealRefCnt(ReferenceCountUpdater.java:74)
    at io.netty.util.internal.ReferenceCountUpdater.release(ReferenceCountUpdater.java:138)
    at io.netty.util.AbstractReferenceCounted.release(AbstractReferenceCounted.java:76)
    at io.netty.handler.codec.http.multipart.MixedFileUpload.release(MixedFileUpload.java:355)
    at io.netty.handler.codec.http.multipart.DefaultHttpDataFactory.cleanRequestHttpData(DefaultHttpDataFactory.java:308)
    at io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder.cleanFiles(HttpPostMultipartRequestDecoder.java:958)
    at io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder.destroy(HttpPostMultipartRequestDecoder.java:941)
    at io.jooby.internal.netty.NettyContext.destroy(NettyContext.java:719)
    at io.jooby.internal.netty.NettyContext.operationComplete(NettyContext.java:654)
    at io.jooby.internal.netty.NettyContext.operationComplete(NettyContext.java:105)
    at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:577)
    at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:551)
    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:490)
    at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:615)
    at io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:604)
    at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
    at io.netty.util.internal.PromiseNotificationUtil.trySuccess(PromiseNotificationUtil.java:48)
    at io.netty.channel.ChannelOutboundBuffer.safeSuccess(ChannelOutboundBuffer.java:717)
    at io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:272)
    at io.netty.channel.ChannelOutboundBuffer.removeBytes(ChannelOutboundBuffer.java:352)
    at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:414)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:930)
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:354)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:897)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1372)
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:742)
    at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:728)
    at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:125)
    at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:750)
    at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:765)
    at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1071)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasksFrom(SingleThreadEventExecutor.java:428)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:377)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:488)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:834)
But at the same time, the file is saved without problems.
My code
<form action="/upload/" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <input type="submit" name="submit" value="Submit" />
</form>
        val form = ctx.multipart()
        val upFile = form.file("file")
        val file = File("test.png")
        copyInputStreamToFile(upFile.stream(), file)
Alex B.
@k1ll1n
In the end, I just switched the server to Undertow and now everything is fine
Hashim Sayyid
@Sayyiditow
I think I had that issue with netty too. Undertow was ok for me.