Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 07 17:44
    @jameskleeh banned @GrantEllison15_twitter
  • Jan 06 01:27
    @jameskleeh banned @brittapop_twitter
  • Jan 06 01:19
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 18:47
    @jameskleeh banned @orubel
  • Jan 04 18:46
    @jameskleeh banned @orubel
  • Jan 04 18:41
    @jameskleeh banned @orubel
  • Jan 04 18:39
    @jameskleeh banned @orubel
  • Jan 04 18:32
    @jameskleeh banned @orubel
  • Jan 04 18:31
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 18:30
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 18:28
    @jameskleeh banned @orubel
  • Jan 04 18:23
    @jameskleeh banned @BeApi_io_twitter
  • Jan 04 18:20
    @jameskleeh banned @orubel
  • Jan 04 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
  • Mar 30 2020 08:44
    @graemerocher banned @orubel
rprinshu
@rprinshu
declerative client
image.png
Controller
every time i create a repository i need to specify the value of repo_slug in my application.yml file
7 replies
that shouldn't be the case with postman i should be able to create a repository with any name
which i can't . IT SAYS INTERNAL SERVER ERROR if the repo_slug value in application.yml and the name of repository in postman are different
can anyone tell me how can i solve the issue so i can create a repository with any name
rprinshu
@rprinshu
image.png
image.png
@ilopmar i did that but still giving me internal server error
1 reply
rprinshu
@rprinshu
image.png
Mengu Kagan
@mengu
hi all, hope everyone's having a great week.
Cosmin Marginean
@cosmin-marginean
This message was deleted

Hi, I'm trying to load everything in the config under bap.storage.search as beans and inject them in a controller:

bap:
    storage:
        search:
            config1:
                searchFields: n, g
            config2:
                searchFields: a, b

We then have:

@EachProperty("bap.storage.search")
@Introspected
data class ObjectSearchConfig(@Parameter val name: String,
                              val searchFields: List<String>)

@Controller("/")
class SearchController(private val storage: Storage,
                       private val searchConfigs: List<ObjectSearchConfig>) {

    init {
        log.info("Found ${searchConfigs.size} object search configs")
        searchConfigs.forEach { log.info("\t$it") }
    }

This however prints

c.b.bap.storage.SearchController - Found 2 object search configs
c.b.bap.storage.SearchController -  ObjectSearchConfig(name=config2, searchFields=[])
c.b.bap.storage.SearchController -  ObjectSearchConfig(name=config1, searchFields=[])

So the searchFields object is clearly not loaded.

James Kleeh
@jameskleeh
Try changing the yaml to search-fields
Mengu Kagan
@mengu

i'm trying to use multiple datasources however i'm having an error: Could not obtain transaction-synchronized Session for current thread

this only happens when i'm trying to use the other data source. everything works fine with the default data source.

this is my configuration: https://gist.github.com/mengu/79b858cabfdcfccd26b4679f573afbd5#file-application-yml
this is my domain class: https://gist.github.com/mengu/79b858cabfdcfccd26b4679f573afbd5#file-rule-kt
this is my service: https://gist.github.com/mengu/79b858cabfdcfccd26b4679f573afbd5#file-ruleservice-kt

can someone let me know what am i missing here? i've also tried using @TransactionalAdvice and it also didn't help.

4 replies
Iván López
@ilopmar
@cosmin-marginean also, is searchFields is a list, I think you need to declare the yaml as:
bap:
    storage:
        search:
            config1:
                searchFields: 
                  - n
                  - g
            config2:
                searchFields:
                  - a
                  - b
Cosmin Marginean
@cosmin-marginean

Try changing the yaml to search-fields

@jameskleeh That didn't work. I think it would be quite unorthodox if this was a default behaviour :)

@cosmin-marginean also, is searchFields is a list, I think you need to declare the yaml as:

bap:
    storage:
        search:
            config1:
                searchFields: 
                  - n
                  - g
            config2:
                searchFields:
                  - a
                  - b

@ilopmar That didn't help either, plus I tried with simple string fields and that actually went worse:


@EachProperty("bap.storage.search")
@Introspected
data class ObjectSearchConfig(@Parameter val name: String,
                              val searchFields: String)

outcome being:

Caused by: io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [searchFields] of class: com.blueanvil.bap.storage.ObjectSearchConfig
Jeff Scott Brown
@jeffbrown
@cosmin-marginean If you can share a simple sample project which demonstrates the problem, that would make it easier to troubleshoot.
Cosmin Marginean
@cosmin-marginean
Yes, it would take quite a bit to unpick this into a project, but I guess since it's clearly a bug it might need doing anyway.
8 replies
Thanks
Constantin
@jaecktec

Hey, we're facing an issue for a while and I'm not sure where to start debugging.

When running Junit5 tests that are annotated with @MicronautTest after just a few consecutive runs we get "No bean of type" errors.
If we're deleting the tmp folder from gradle build directory it starts working again.
We've tried to disable incremental annotation processing, gradle cache. Also the i.m.context.condition.Condition is not saying anything.

Any hint where I can research?

18 replies
Vishnu Govindan
@VishGov_twitter

Hi, I am using @Jacksonized with @Builder like below:

@Data
@NoArgsConstructor
@AllArgsConstructor
@Introspected
@Jacksonized
@Builder
public class Fruit {

    @NonNull
    @JsonProperty(value = "fruit_name", required = true)
    private String name;

    @NonNull
    @JsonProperty(value = "fruit_season", required = true)
    private String season;

}

I am getting the below error for it when I am trying to parse a JSON to this model via object mapper IN NATIVE IMAGE :

Builder class `Fruit$FruitBuilder` does not have build method (name: 'build')

The code is working when I run it from Intellij. Am I missing something here?

8 replies
Charles Harvey III
@charlie-harvey
Has anyone tried to get the random (-1) port assignment during testing into a declarative @Client("myservice")?
I thought this would do it but instead of the random port I got -1.
micronaut:
  server:
    port: -1
    # port: 7002
  http:
    services:
      myservice:
        url: http://localhost:${micronaut.server.port:7002}/
55 replies
Tubanter
@gijsleussink
How would you "unset" configuration when the environment is "test", for example? We want to unset kafka.sasl in that case. 🤔
James Kleeh
@jameskleeh
In general you wouldn’t. If config is not applicable to all environments it shouldn’t be in application.yml for example
Tubanter
@gijsleussink
Thank you @jameskleeh. So the YAGNI applies for configuration too. Makes sense.
Adam Wilder
@rawilder
I'm running Azure Functions locally for a Micronaut project. I have two Functions defined and it tries to load both but throws java.nio.file.FileSystemAlreadyExistsException: null. If I comment either one out, it runs just fine. Is there something I need to do to get them to run together or is that not supported?
1 reply
Mengu Kagan
@mengu
when i generate a micronaut application with jdk 15 and then decide to use graalvm 21, what should i change?
9 replies
simply switching jdk with sdkman is not enough as i get: ApplicationKt has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0
however i removed the whole build folder, ran ./gradlew clean
so i'm not sure where this compiled file is
Mengu Kagan
@mengu
let's see if purging ~/.gradle/caches helps
nope it didn't
Sachin Mittal
@101_mittal_twitter
I am trying to inject RxHttpClient in my class which is extending MicronautRequestHandler and I am getting Null Pointer exception
How I can resolve this?
Cosmin Marginean
@cosmin-marginean

Hi, we're using Thymeleaf to test a prototype with Micronaut Views and were looking at the way to present the query params on the view

<p th:text="${#request.getParameter('q')}">Test</p>

or, alternatively as per Thymeleaf docs:

<p th:text="${param.q}">Test</p>

This doesn't work though as the request params are empty when rendering the view (despite them being sent through the contoller path ...search?q=dan).

The question is about best practice here, and whether it's best to shove the request on the model from the Micronaut controller?
Or is there some other way to get Micronaut Views to pass these params to the view renderer (Thymeleaf)?

binoysankar
@binoysankar

Hi,

I am using @Jacksonized annotation with @Builder (lombok) as below

@Data
@NoArgsConstructor
@AllArgsConstructor
@Introspected
@Jacksonized
@Builder
@Schema(requiredProperties = {"metadata", "vehicle"})
public class Xyz {

    @NonNull
    @JsonProperty(value = "metadata", required = true)
    private Metadata metadata;

    @NonNull
    @JsonProperty(value = "vehicle", required = true)
    private Vehicle vehicle;

}

When run in JVM mode as I am getting and exception as below when metadata value is not set which is correct.

ERROR xxx.JsonParserUtil - Cannot construct instance of `com.xxx.Xyz$XyzBuilder`, problem: metadata is marked non-null but is null
ERROR c.d.m.d.e.h.ExceptionHandlerUtil - ERROR = {Mandatory field is missing. FIELD = {metadata}} ; EXCEPTION = {class com.xxx.exception.InvalidXyzException}

But when ran as native-image the exception gets changed to

ERROR [xxx.JsonParserUtil[Builder class `com.xxx.Xyz$XyzBuilder` does not have build method (name: 'build')
Sachin Mittal
@101_mittal_twitter
I am trying to inject RxHttpClient in my class which is extending MicronautRequestHandler and I am getting Null Pointer exception
How I can resolve this?
Sachin Mittal
@101_mittal_twitter

@Introspected
public class CustomEventHandler extends MicronautRequestHandler<Map<String, Object>, APIGatewayV2HTTPResponse> {

private static final Logger LOGGER = LoggerFactory.getLogger(CustomEventHandler.class);

@Inject
@Client("/")
public final RxHttpClient httpClient;

@Override
public APIGatewayV2HTTPResponse execute(Map<String, Object> input) {
String result = httpClient.toBlocking()
.retrieve(HttpRequest
.GET("http://test-api.com"));

final TestDto testDto;
try {
    testDto = HttpClientUtils.OBJECT_MAPPER.readValue(result, TestDto.class);
    return APIGatewayV2HTTPResponse.builder().withStatusCode(HttpStatus.SC_OK)
            .withBody(testDto.toString())
            .build();
} catch (JsonProcessingException e) {
    e.printStackTrace();
}
return APIGatewayV2HTTPResponse.builder().withStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR)
        .build();

}

Mengu Kagan
@mengu
hi, any ideas how can i get rid of the error ApplicationKt has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0 when i change jdks with sdkman?
i've ran ./gradlew clean, i've purged ~/.gradle but no luck so far. would that be because of dependencies?
seder001
@seder001
Good afternoon
Maybe this is a stupid question, but I have a Controller, which returns, depending on result, different kind of HTTPResponses. Now instead of getting stupid pages which look different on each browser, I want to provide customized 404/422/500 etc pages with custom messages. is this even possible?
binoysankar
@binoysankar

Hi,

I am using @Jacksonized annotation with @Builder (lombok) as below

@Data
@NoArgsConstructor
@AllArgsConstructor
@Introspected
@Jacksonized
@Builder
@Schema(requiredProperties = {"metadata", "vehicle"})
public class Xyz {

    @NonNull
    @JsonProperty(value = "metadata", required = true)
    private Metadata metadata;

    @NonNull
    @JsonProperty(value = "vehicle", required = true)
    private Vehicle vehicle;

}

When run in JVM mode as I am getting and exception as below when metadata value is not set which is correct.

ERROR xxx.JsonParserUtil - Cannot construct instance of `com.xxx.Xyz$XyzBuilder`, problem: metadata is marked non-null but is null
ERROR c.d.m.d.e.h.ExceptionHandlerUtil - ERROR = {Mandatory field is missing. FIELD = {metadata}} ; EXCEPTION = {class com.xxx.exception.InvalidXyzException}

But when ran as native-image the exception gets changed to

ERROR [xxx.JsonParserUtil[Builder class `com.xxx.Xyz$XyzBuilder` does not have build method (name: 'build')

Resolved this issue by having a reflect-config.json with below values

[
{
    "name": "com.xxx.Xyz$XyzBuilder[]"
  },
  {
    "name": "com.xxx.Xyz$XyzBuilder",
    "allDeclaredFields": true,
    "allPublicMethods": true,
    "allDeclaredConstructors": true
  },
  {
    "name": "com.xxx.Metadata$MetadataBuilder[]"
  },
  {
    "name": "com.xxx.Metadata$MetadataBuilder",
    "allDeclaredFields": true,
    "allPublicMethods": true,
    "allDeclaredConstructors": true
  },
  {
    "name": "com.xxx.Vehicle$VehicleBuilder[]"
  },
  {
    "name": "com.xxx.Vehicle$VehicleBuilder",
    "allDeclaredFields": true,
    "allPublicMethods": true,
    "allDeclaredConstructors": true
  }
]
James Kleeh
@jameskleeh
@seder001 Yes see the section of the docs about exception handling
seder001
@seder001
@jameskleeh if you mean, https://guides.micronaut.io/micronaut-error-handling/guide/index.html than this is not working as I expected, because @Error is not working for me
@Error(status = HttpStatus.NOT_FOUND, global = true)
--> Annotation Type expected
James Kleeh
@jameskleeh
seder001
@seder001
this link is strange, I land on different positions on the page every time I open that link
3 replies