0

I tried the below code to access the "GreetingResource" using custom extension, but not able to access. sample code:

@BuildStep
void build(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
    additionalBeans.produce(
        AdditionalBeanBuildItem.unremovableOf(GreetingResource.class)
    );
}
Dmytro Chaban
  • 1,106
  • 1
  • 11
  • 19
abel saju
  • 31
  • 4
  • We will need a lot more information about what you are trying to do if we are to help – geoand Jun 13 '23 at 08:15
  • @geoand my requirement is create a generic end point, there we are doing some business logic. this extension need to add as dependency in other modules. – abel saju Jun 13 '23 at 08:19
  • What extensions are you using? – geoand Jun 13 '23 at 08:20
  • i am creating a custom extension for this generic end point.I tried the solution as per the below link : https://stackoverflow.com/questions/65033775/quarkus-custom-rest-extension-deployment but not worked for me – abel saju Jun 13 '23 at 08:22
  • Probably a better example to follow is https://quarkus.io/guides/building-my-first-extension. I think you have some of that code in your extension, judging from the class names, but I can't tell how much of it. Things like logs and what error code you see on the new custom endpoint would be helpful. – Holly Cummins Jun 15 '23 at 11:31
  • @HollyCummins, actually I created the custom extension from above link (that you mentioned) only. But instead of : ServletBuildItem createServlet() build step I used void build (BuildProducer additionalBeans) buildstep for getting the rest endpoint. – abel saju Jun 20 '23 at 05:33
  • Got it. And have you confirmed that if you run your `GreetingResource` as a normal application, rather than as an extension, you get the REST endpoint you want? – Holly Cummins Jun 20 '23 at 09:37
  • Currently I have a requirement that one rest endpoint and its business logic need to add as library to some projects, so that i created the endpoint in custom extension. – abel saju Jun 20 '23 at 11:31
  • Got one solution and it worked for me : @BuildStep ReflectiveClassBuildItem reflectiveClass() { return ReflectiveClassBuildItem.builder(GreetingResource.class).build(); } – abel saju Jun 21 '23 at 06:51

0 Answers0