Open Lars5678 opened 4 years ago
Hi Lars,
This fell through the cracks for a reply.
Can you try on the latest version. I tried the following and I don't have any problem.
@Path("/api/hello")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.TEXT_PLAIN)
@RegisterRestClient // Required to enable injection of this interface
@RequestScoped
public interface HelloService {
@Path("{name}")
@GET
String hello(@PathParam("name") String name);
}
And using it
@RequestScoped
public class ClientResource {
@Inject
@RestClient
private HelloService helloService;
Thanks Regards Rudy
I'm sorry about it. Unfortunately, I can not longer reproduce the problem. I have tested it with the 5.2020.3 as well as with the 5.201 each FULL and have no more exception. Maybe I've changed something in the meantime.
Only the messages mentioned above continue to appear. I think this issue can be closed as not reproduceable.
Yes the message appears because of conflicting rules around JAX-RS and MicroProfile Rest.
Closing it as functionality is ok.
@rdebusscher I was able to recreate the problem. The problem always occurs if no scope is specified. If I give RequestScoped or Dependent it works.
As I said, in Payara Micro it works without specifying a scope. In Payara Full, unfortunately, only with the specification of a scope.
Why it works in the micro but not in the full I don't know. But my understanding was that @RegisterRestClient automatically sets the service Dependent.
This works both in Payara Micro and Full
@RegisterRestClient
@Path("/v1/maintenance")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
@ClientHeaderParam(name = "Authorization", value = "{generateAuthHeader}")
@Dependent
public interface ConfigResourceService
This works only in Payara Micro but not in Full
@RegisterRestClient
@Path("/v1/maintenance")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
@ClientHeaderParam(name = "Authorization", value = "{generateAuthHeader}")
public interface ConfigResourceService
So try to remove the Scope from HelloService and try with Micro and then with Full
Hi Lars,
Removing the scope still results in a deployment without exceptions. I tried with a few variations around the scope of the JAX-RS resource where the 'interface' is injected and beans.xml. But no luck.
Can you upload a small, simple reproducer that shows the problem?
Thanks Rudy
Strange. I'm trying to provide a small reproducer.
https://github.com/LarsBrenker/pay4704
Enclosed the reproducer. Just check out and build the image (with the Payara Full). Then it should come to the error. If the annotation @Dependent is commented in the class de.larsbrenker.reproducer.ConfigResourceService, the error is gone. In Payara Micro you can also do without the annotation.
I hope it works. It is my first public GitHub Project
Hi Lars,
Thank you for the reproducer and yes, the Github repo is fine.
I see that you want to inject in a Faces defined CDI bean. We have to investigate this more in-depth as this is an unforeseen factor for the MP RestClient spec. I also see no beans.xml defined which also can have an influence.
I'll keep you updated on my research results later on.
Best Regards Rudy
Hi Rudy,
I adjusted the reproducer.
Maybe it's related to the beans.xml. But as I said: There has to be a difference between Payara Micro and Payara Server.
Hi Lars,
When I add a beans.xml with bean-discovery-mode="annotated"
(or all
) there is no longer a difference between Payara Server and Payara Micro.
I'll investigate this further, also in the light of a possible Jakarta Web Profile certification of Payara Micro.
Regards Rudy
Hi @LarsBrenker, I was able to reproduce the issue in the latest release, so I made an internal ticket FISH-764
.
Hi @rdebusscher ,
I lost sight of this ticket a bit.
I added the beans.xml. For me it only works with the Bean Discovery Mode "all". With "annotated" I also get the error.
The CDI Spec says "It is strongly recommended you use" annotated "." it would be nice if we can find a solution for this.
I adjusted the reproducer. Beans.xml added and the Payara Image 5.2021.4 used
Unfortunately, the error still exists in the current version 5.2022.2
Description
As described under https://docs.payara.fish/docs/5.201/documentation/microprofile/rest-client.html I registered an MP Rest Client as an interface. This is injected into a CDI bean.
If I start the application in a Payara Micro, the application starts up and works perfectly. However, I get a warning:
Component of class interface de.xx.prototype.jsf.clients.ConfigResourceService cannot be instantiated and will be ignored.
Is the message correct?
However, this is just a warning but everything works.
But....
When I start the application in Payara Full I get a deployment exception and the application will not be deployed.
Expected Outcome
Same behavior like in Payara Micro. Just a warning but application will be deployed. Optimally, no misleading warning either.
Current Outcome
Payara Micro - Warning:
Component of class interface de.xx.prototype.jsf.clients.ConfigResourceService cannot be instantiated and will be ignored.
Payara Full - Exception:
` [#|2020-06-08T14:35:23.712+0200|SCHWERWIEGEND|Payara 5.201|javax.enterprise.system.core|_ThreadID=1;_ThreadName=main;_TimeMillis=1591619723712;_LevelValue=1000;_MessageID=NCLS-CORE-00026;| Exception during lifecycle processing org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type ConfigResourceService with qualifiers @RestClient at injection point [UnbackedAnnotatedField] @Inject @RestClient private de.xx.prototype.jsf.admin.AdminController.configResourceService at de.xx.prototype.jsf.admin.AdminController.configResourceService(AdminController.java:0) -- WELD-001408: Unsatisfied dependencies for type ConfigResourceService with qualifiers @RestClient at injection point [UnbackedAnnotatedField] @Inject @RestClient private de.xx.prototype.jsf.admin.AdminController.configResourceService at de.xx.prototype.jsf.admin.AdminController.configResourceService(AdminController.java:0)
`
Steps to reproduce (Only for bug reports)
1 -** Create an Interface as MP Rest Client
2 -** Inject in CDI Bean
3 -** Start runtime
4 -** See server logs
Samples
Environment