Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-20864

Jakarta REST applications with EJB endpoints with more than one interface results in a deployment error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • REST
    • None

      When a Jakarta REST endpoint is an EJB which implements more than one interface, the deployment fails. Below is an example deployment failure:

      10:54:35,537 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."file-upload.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."file-upload.war".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of deployment "file-upload.war"
      	at org.jboss.as.server@29.0.0.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
      	at org.jboss.msc@1.5.6.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1553)
      	at org.jboss.msc@1.5.6.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1516)
      	at org.jboss.msc@1.5.6.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1374)
      	at org.jboss.threads@3.9.1//org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
      	at org.jboss.threads@3.9.1//org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2651)
      	at org.jboss.threads@3.9.1//org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2630)
      	at org.jboss.threads@3.9.1//org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1622)
      	at org.jboss.threads@3.9.1//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1589)
      	at java.base/java.lang.Thread.run(Thread.java:1583)
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYRS0010: Jakarta RESTful Web Services resource [class dev.resteasy.examples.resources.EjbInjectionInterfaceResource] does not correspond to a view on the Jakarta Enterprise Beans EjbInjectionInterfaceResource. @Path annotations can only be placed on classes or interfaces that represent a local, remote or no-interface view of a Jakarta Enterprise Beans bean.
      	at org.jboss.as.jaxrs@38.0.0.Beta1-SNAPSHOT//org.jboss.as.jaxrs.deployment.JaxrsComponentDeployer.deploy(JaxrsComponentDeployer.java:123)
      	at org.jboss.as.server@29.0.0.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
      	... 9 more
      

      This is due to the org.jboss.as.jaxrs.deployment.JaxrsComponentDeployer requiring the interface view and the Jakarta REST resource have the sane class name. However, the Jakarta REST resource will be the implementation name and the JNDI view name will be the component views interface name.

      When processing the resources, we should check the components implementation if the Jakarta REST resource and the views name do not match.

      Create a deployment with the following and an activator for Jakarta REST and you should see the failure.

      GreetEjb.java
      @Local
      public interface GreetEjb {
      
          String hello();
      }
      
      GoodbyeEjb.java
      @Local
      public interface GoodbyeEjb {
      
          String goodbye();
      }
      
      LocalEjbImpl.java
      @Stateless
      @Local({GreetEjb.class, GoodbyeEjb.class})
      @Path("/")
      public class LocalEjbImpl implements GreetEjb, GoodbyeEjb {
      
          @Resource
          SessionContext ctx;
      
          @Override
          @GET
          @Path("hello")
          public String hello() {
              if (ctx == null) {
                  return "ctx is null";
              }
              return "Hello, World!";
          }
      
          @Override
          @GET
          @Path("goodbye")
          public String goodbye() {
              if (ctx == null) {
                  return "ctx is null";
              }
              return "Goodbye, World!";
          }
      }
      

              jperkins-rhn James Perkins
              jperkins-rhn James Perkins
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: