Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 01 17:58
    @graemerocher banned @gomezcalvin20_gitlab
  • Apr 28 15:29
    @graemerocher banned @andrew903:matrix.org
  • Apr 12 01:32
    @jameskleeh banned @1948_your_tlv_homo_1488:swirl.funny.cl
  • Aug 17 2021 05:28
    @jameskleeh banned @zxvdgs:jonasled.de
  • Jan 07 2021 17:44
    @jameskleeh banned @GrantEllison15_twitter
  • Jan 06 2021 01:27
    @jameskleeh banned @brittapop_twitter
  • Jan 06 2021 01:19
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 2021 18:47
    @jameskleeh banned @orubel
  • Jan 04 2021 18:46
    @jameskleeh banned @orubel
  • Jan 04 2021 18:41
    @jameskleeh banned @orubel
  • Jan 04 2021 18:39
    @jameskleeh banned @orubel
  • Jan 04 2021 18:32
    @jameskleeh banned @orubel
  • Jan 04 2021 18:31
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 2021 18:30
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 2021 18:28
    @jameskleeh banned @orubel
  • Jan 04 2021 18:23
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 2021 18:20
    @jameskleeh banned @orubel
  • Jan 04 2021 18:10
    @jameskleeh banned @BeApi_io_twitter
  • Apr 03 2020 13:09
    @jameskleeh banned @orubel
  • Mar 30 2020 18:40
    @graemerocher banned @BeApi_io_twitter
Luís Duarte
@driverpt

Hey everyone,

has anyone ever had this issue:

java: cannot find symbol
  symbol:   method onConstructor_()
  location: @interface lombok.RequiredArgsConstructor
1 reply
Code:
@Singleton
@RequiredArgsConstructor(onConstructor_ = @Inject)
public class SomeClass {
  private final SomeDependency dependency;
}
Sam Gammon
@sgammon
hello friends
i have a quick question about the docker integration with Gradle
what are the tasks i should invoke to make the Dockerfile buildable via regular docker build?
Sam Gammon
@sgammon
if i do optimizedDockerfileNative, and optimizedBuildNativeLayersTask, it doesn't have the JARs ready to build -- otherwise it seems complete
Ivan Knapp
@ivanknapp
hi everyone, i plug in caffeine cache to my micronaut project, i set expire-after-write: PT5S and get data with schedule in 5sec, too
first call invocate real method, but second and third, etc invocations, get cached data,
i expect that cache will invalidate itself,
What i do wrong? please help
1 reply
darthvader42
@darthvader42:matrix.org
[m]
If using both @Secured on controllers and a intercept-url-map - which one takes precedence?
lancekf
@lancekf
I'm trying to serve some static resources with micronaut.router.static-resources. Running the app locally works fine - I can load the static files from the browser. When deployed to my AWS Lambda, I keep getting a 404. Is there some other configuration I'm missing?
lancekf
@lancekf
I could be reading this wrong but I don't see how the StaticResourceResolver in https://github.com/micronaut-projects/micronaut-aws/blob/master/function-aws-api-proxy/src/main/java/io/micronaut/function/aws/proxy/MicronautLambdaContainerHandler.java is ever used. It's a private field and isn't exposed via any methods. Bug?
It appears that there's already been an issue raised for it - micronaut-projects/micronaut-aws#1361
lancekf
@lancekf
It looks like the code for resolving static resources was removed. Not sure why. Added a comment to the PR.
bouceka
@bouceka
Hi all, I'm relatively new to Micronaut and I try to integrate NATS. When I specify cluster in @NatsListener I get this error: Error starting Micronaut server: No bean of type [io.nats.client.Connection] exists for the given qualifier: @Named('abcd'). Can anyone help me to identify the issue? I'm grateful for any help! Thanks
2 replies
Marcos F. Lobo
@marcosflobo:matrix.org
[m]
Hello team! quick question. The Netty parameters to tune the number of threads to use https://docs.micronaut.io/latest/guide/#threadPools. Do they apply for gRPC server as well?
Daniel Nord
@dniel

Hi, Im trying to use coroutines in Micronaut and struggle a bit with a endpoint returning Flow. Its just returning the first element in the flow and not the rest,

    @Get("/changes")
    @Produces(MediaType.APPLICATION_JSON_STREAM)
    override suspend fun changeEventUpdates() =
        flow<ChangeEvent> {
            emit(ChangeEvent("event1",1))
            emit(ChangeEvent("event2",2))
            emit(ChangeEvent("event3",3))
        }

and curl -v -H "Accept: application/x-json-stream" http://localhost:8080/changes only prints

< HTTP/1.1 200 OK
< date: Sun, 20 Nov 2022 10:39:17 GMT
< Content-Type: application/x-json-stream
< content-length: 43
< connection: keep-alive
< 
{
  "payload" : "event1",
  "version" : 1
* Connection #0 to host localhost left intact
}

Shouldnt that have streamed all of the values from the flow?

2 replies
Logan Kulinski
@lbkulinski
Matthew Planchant
@mplanchant

I'm trying to use Client Credentials flow with my app to authenticate (https://micronaut-projects.github.io/micronaut-security/latest/guide/#clientecredentialshttpclient)

I'm getting the following error:

- Bean [Definition: io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHeaderTokenPropagator] will not be loaded due to failing conditions:
 - * Client credentials header token handler disabled due to a lack of configuration
 - * Custom condition [class io.micronaut.security.oauth2.client.clientcredentials.propagation.ClientCredentialsHeaderPropagatorEnabled] failed evaluation

What am I missing from my config?

 micronaut:
   application:
     name: my-app
   http:
     services:
       my-dev:
         urls:
           - https://my-dev.com
   security:
     filter:
       enabled: false
     oauth2:
       clients:
         auth-dev:
           grant-type: client_credentials
           client-id: myId
           client-secret: mySecret
           client-credentials:
             service-id-regex: 'my-dev'
             scope: myScope
           token:
             url: https://auth-dev.com/oauth2/token
             auth-method: client_secret_post
2 replies
Chris Warth
@csw2_gitlab
newbie to frameworks like micronaut and Spring. I would really like to use this JdbcOperations to stream query results. I see example usage in jdbc-example-java (https://github.com/micronaut-projects/micronaut-data/blob/master/doc-examples/jdbc-example-java/src/main/java/example/AbstractBookRepository.java) , but I can’t figure out how jdbcOperations gets initialized and passed in to AbstractBookRepository. I don't actually see any uses of the AbstractBookRepository class in that project. Including @JdbcRepository annotations in my own code does not cause errors, but also does not initialize and pass jdbcOperations to the constructor.
How can I configure my service to use JdbcOperations in micronaut?
7 replies
Nahuel Rodríguez
@Nahuel92

Hi everyone, I am struggling with the following situation, and I would like to see if any of you could give me a hand:
I am building a service that exposes unprotected endpoints, but it calls another service that does require authentication and authorization via JWT.
Since the callers of my new service will be sending a JWT token, my idea is to use JWT token propagation to reduce boilerplate code (as of now, I have done it manually, receiving a @Header("Authorization") final String auth parameter in each controller handler), but I don't know how to properly configure my service to grab the JWT token and propagate it without asking for authentication at the endpoints level.
I tried adding the dependency:

<dependency>
    <groupId>io.micronaut.security</groupId>
    <artifactId>micronaut-security-jwt</artifactId>
    <scope>compile</scope>
</dependency>
  • annotating the endpoints with @Secured(SecurityRule.IS_ANONYMOUS) + adding security.token.propagation.enabled: true in the application.yml file +
<annotationProcessorPaths>
   <path>
     <groupId>io.micronaut.security</groupId>
       <artifactId>micronaut-security-annotations</artifactId>
   </path>
</annotationProcessorPaths>

But I still receive 401 Unauthorized.
Any help and/or example will be welcomed. Thank you.

14 replies
Logan Kulinski
@lbkulinski
joshblease
@joshblease
Hi team, is there anyway I can access properties defined in application.yaml from the logback config? I have attempted to add <property resource="application.yml"/> with no luck.
Noé Fernández
@noeFernandez

Hi, is it possible with micronaut data to use different data sources for different repositories? Something like this

datasources:
  default:
    url: 'blah'
    username: 'blah'
    ... rest of the config ...
  lowPrio:
    url: 'blah'
    ... rest of the config ...

And then I have two repositories

 @Repository
 public interface RepositoryA extends CrudRepository<EntityA, EntityAKey> {}

  @Repository
  public interface RepositoryB extends CrudRepository<EntityB, EntityAKey> {}

would be possible to configure jpa to use the lowPrio pool whenever I save something with RepositoryB and use the default pool when doing so with RepositoryA?

Patrick Lightbody
@lightbody
Hey -- does anyone have any advice on how to best use OpenTelemetry with Micrometer? We've got the basics going, but I really would like all the IO instrumentation that comes with the Java agent (https://github.com/open-telemetry/opentelemetry-java-instrumentation). The issue I'm finding is that when I incorporate that, it loads up the otel configuration prior to Micronaut starting up and thus it doesn't use the config in my application.yml. Any advice? (Also I'm curious what the posture is on this instrumentation given that it uses bytecode manipulation, which Micronaut tends to shun)
1 reply
Patrick Lightbody
@lightbody
s/Micrometere/Micronaut =P
Logan Kulinski
@lbkulinski
Is anyone using Google AutoValue or Immutables with Micronaut request beans? I keep running into an InstantiationError likely due to no public constructors. Is there an easy way around this?
Patrick Lightbody
@lightbody
Follow-up question on Micrometer/OpenTracing: we're seeing that the span for HTTP requests are getting the name from HttpAttributes.ROUTE_INFO, which has variables in it and makes grouping impossible for any dynamic route. It seems like it would have been better off using HttpAttributes.URI_TEMPLATE. Unfortunately, it's not easy to swap this logic out because it's wedged into MicronautHttpServerAttributesGetter which is a package-protected enum marked with @Internal. But what I can do is make a high precedence filter that replaces HttpAttributes.ROUTE_INFO contents in the request attributes with the contents of HttpAttributes.URI_TEMPLATE, but I worry that this might break other things. Any ideas on what other options I have?
1 reply
Marcel Linnenfelser
@macmillancodes:matrix.org
[m]
Hey -- I started using test-resources. In most cases it is helpful, but I am not able to deactivate it by configuration in application-<env>.yml. Is there a way to accomplish that other than commenting it out in build.gradle?
Patrick Lightbody
@lightbody
Another Micronaut/OpenTracing question: how does one disable the tracing module, such as during testing?
1 reply
Hallvard Trætteberg
@hallvard
I’m experimenting with Micronaut in combination with JavaFX ala SupernautFX. I’ve implemented a custom scope and corresponding annotation for views, so I can have several instances of a workbench-like pane. It works well, so far. However, I haven’t found a way to register a manually created scope «singleton», a bit like BeanContext.registerSingleton, but it should be registered on the current scope. Is there an API for this?
Fabio Rafael da Rosa
@pid42
Hi all, good day. Im trying to find information about how to use micronaut rabbit/kafka and reactive consumers ... using coroutines to be more precise, but I cannot find any documentation or example. Can someone point me to where I can find that info (or if thats no currently supported) ?
asantare
@asantare
Hello,
Is there an easy way to copy the body from one HttpResponse (R1) to a new HttpMutableResponse (R2)?
Where the R1 content is Json but got as raw to avoid decoding and R2 has json contentType but avoids encoding?
(kind of proxy, but I don't want use the ProxyHttpClient as it seems the connection reusing is not happening)
1 reply
juzweb
@juzweb
can someone point me to example to setup kafka testcontainers using maven?
David
@klap_twitter

Hi guys, question, I'm getting a 403 when trying to change the log level by using the loggers endpoint. Basically if I don't send the Bearer token I get a 401, and if I send a valid token, I get a 403, no useful info in the DEBUG log. Any idea?

2022-11-24T11:04:58.957562+00:00 app[web.1]: 11:04:58.957 [default-nioEventLoopGroup-1-10] DEBUG i.m.s.rules.InterceptUrlMapRule - No url map pattern exact match found for path [/loggers/io.micronaut.security.token] and method [POST]. Searching in patterns with no defined method.
2022-11-24T11:04:58.957669+00:00 app[web.1]: 11:04:58.957 [default-nioEventLoopGroup-1-10] DEBUG i.m.s.rules.InterceptUrlMapRule - No url map pattern match found for path [/loggers/io.micronaut.security.token]. Returning unknown.
2022-11-24T11:04:58.957880+00:00 app[web.1]: 11:04:58.957 [default-nioEventLoopGroup-1-10] DEBUG i.m.security.filters.SecurityFilter - Authorized request POST /loggers/io.micronaut.security.token. No rule provider authorized or rejected the request.
2022-11-24T11:04:58.961546+00:00 at=info method=POST path="/loggers/io.micronaut.security.token" host=myhost.com request_id=9164-4072-87f1-3f017bcd5741 fwd="147.161.190.208" service=12ms status=403 bytes=115 protocol=https

This is my endpoint loggers config:

endpoints:
  health:
    enabled: true
    sensitive: false
    details-visible: ANONYMOUS
  loggers:
    enabled: true
    sensitive: false
    write-sensitive: false

Thanks

4 replies
francesco-monorchio
@francesco-monorchio

Hi guys, I have updated micronaut version from 3.6.3 to 3.7.4 and now, during the gradle build each module log some debug info. See here:

> Task :sources:services:user-service:compileGroovy
14:40:37.531 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.DefaultEnvironment - Environment deduction is using the default of: true
14:40:37.533 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] INFO io.micronaut.context.env.DefaultEnvironment - Established active environments: [gcp, cloud]
14:40:37.535 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.DefaultEnvironment - Starting environment io.micronaut.openapi.visitor.AnnProcessorEnvironment@f86f03 for active names [gcp, cloud]
14:40:37.539 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.AbstractPropertySourceLoader - No PropertySource found for file name: application.VCAP_APPLICATION
14:40:37.539 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.AbstractPropertySourceLoader - No PropertySource found for file name: application-gcp.VCAP_APPLICATION
14:40:37.539 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.AbstractPropertySourceLoader - No PropertySource found for file name: application-cloud.VCAP_APPLICATION
14:40:37.540 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.AbstractPropertySourceLoader - No PropertySource found for file name: application.json
14:40:37.540 [/127.0.0.1:40150 to /127.0.0.1:34787 workers] DEBUG io.micronaut.context.env.AbstractPropertySourceLoader - No PropertySource found for file name: application-gcp.json

Can these be disabled? I have tried to disable gradle log and my logback.xml print only INFO.

Matthew Planchant
@mplanchant
I'm following the guidelines (https://micronaut-projects.github.io/micronaut-test/latest/guide/#kotest5) for 'Mocking Collaborators' with kotest but the collaborator bean is used in the @PostConstruct of the bean under test. This is failing as it seems that the mock has not been injected at this point. Is there a work around I can use here?
Sergio del Amo
@sdelamo:matrix.org
[m]
You can always create a bean in your test class path annotate it with @Replaces and @Requires and replace the bean you want to mock in a test
Matthew Planchant
@mplanchant
Thanks @sdelamo:matrix.org. I'll check this out.
Sergio del Amo
@sdelamo:matrix.org
[m]
do you have a reproducible example with a failing test?
Sergio del Amo
@sdelamo:matrix.org
[m]
micronaut security by design respond 401 or 403 (if authenticated if you are authenticated) for 404. We do that to give an attacker less information about which routes exists or not. There is a setting you can toggle if you prefer to receive 404 instead.
Stijepo Vrdoljak
@svrdoljak__twitter

Hi, I'm having issues parsing a body from a HttpClientResponseException:

    @Error
    public HttpResponse<InvalidPathSegmentProblem> error(HttpRequest<?> r, InvalidPathSegmentProblem e) {
        return HttpResponse.<String>status(HttpStatus.BAD_REQUEST).body(e);
    }

I'm throwing a custom exception and then transform it to a BAD REQUEST and attach the exception to the body.
BUT it's always empty on the other side:

        client.exchange(payload, Argument.of(Payload.class), Argument.of(InvalidPathSegmentProblem.class))
            .test()
            .awaitDone(5, TimeUnit.SECONDS)
            .assertError(throwable -> {
                assertThat(throwable).isInstanceOf(HttpClientResponseException.class);
                var httpClientResponseException = (HttpClientResponseException) throwable;
                var err = httpClientResponseException.getResponse().getBody(InvalidPathSegmentProblem.class).get();
                System.out.println("BODY: " + err);
                return true;
            });
Stijepo Vrdoljak
@svrdoljak__twitter
I also tried with the blocking approach like in your documentation. Same result...
@Test
public void afterAnHttpClientExceptionTheResponseBodyCanBeBoundToAPOJO() {
    try {
        client.toBlocking().exchange(HttpRequest.GET("/books/1680502395"),
                Argument.of(Book.class), // 
                Argument.of(CustomError.class)); // 
    } catch (HttpClientResponseException e) {
        assertEquals(HttpStatus.UNAUTHORIZED, e.getResponse().getStatus());
        Optional<CustomError> jsonError = e.getResponse().getBody(CustomError.class);
        assertTrue(jsonError.isPresent());
        assertEquals(401, jsonError.get().status);
        assertEquals("Unauthorized", jsonError.get().error);
        assertEquals("No message available", jsonError.get().message);
        assertEquals("/books/1680502395", jsonError.get().path);
    }
}
Sergio del Amo
@sdelamo:matrix.org
[m]

Have you verified by logging with

<logger name="io.micronaut.http.client" level="TRACE"/>

the error body payload is being returned

Stijepo Vrdoljak
@svrdoljak__twitter
Hmmm...interesting
Cannot construct instance of `InvalidPathSegmentProblem` (no Creators, like default constructor, exist): Throwable needs a default constructor, a single-String-arg constructor; or explicit @JsonCreator
Error decoding HTTP error response body:
Sergio del Amo
@sdelamo:matrix.org
[m]
if InvalidPathSegmentProblem has multiple constructors annotate the one you want to use in deserialization with @Creator
or an empty constructor
from the error messsage
Stijepo Vrdoljak
@svrdoljak__twitter
We are using problem+json from zalando. There are a lot of constructors.
Andrew Malyhin
@katoquro

Hello! Is there a something like inter-service auth in security?
I use security sessions, and I'd like to propagate info about user to other micro-services.

  • Let's say we have a case when service A have to retrieve some secure info about user from service B.
  • User have session and interact with the A. the A have to send request to the B but should prove that it isn't just crafted by 3rd party.
  • So, looks like we have to have a layer when user session is replaces to something like JWT (signed by the A) and is used to make request to the B (user info is propagated).

If there are no such mechanics, how can I create something similar to it?

2 replies