Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only 1 JAX-RS application should be used per application #82

Open
aguibert opened this issue Jun 13, 2019 · 5 comments
Open

Only 1 JAX-RS application should be used per application #82

aguibert opened this issue Jun 13, 2019 · 5 comments

Comments

@aguibert
Copy link

Currently this guide uses two different JAX-RS Applications, with different endpoints:

@ApplicationPath("system")
public class SystemApplication extends Application { }

and

@ApplicationPath("inventory")
public class InventoryApplication extends Application { }

Having 2 JAX-RS applications is not really defined by the JAX-RS spec, and we should not be demonstrating this pattern in one of our guides.

It also gives a confusing behavior because all resources are available under both application endpoints. Namely InventoryResource is bound to both /system/systems/ AND /inventory/systems. Likewise, SystemResource is bound to both /system/propertiesAND/inventory/properties`

@scottkurz
Copy link
Member

I can imagine maybe why this shortcut was taken: since this app is overloaded and used in multiple guides.

At least one, JWT does use a separate front-end and back-end server for each service and also drags in the complexity of a multi-module Maven build.

But agree, it can be confusing to realize how these paths are oddly-proliferating like you mentioned.

Maybe there's a better way to share the core Java files across these different guide projects to use the appropriate number of JAX-RS apps for each guide?

@aguibert
Copy link
Author

I don't think we should be optimizing for what is easiest to maintain via code re-use. Rather, we should be doing whatever makes the most sense for the guide.

In this case, both JAX-RS "applications" are deployed in a single .war file on the same server, so there is no need for a front-end/back-end or multi-module app IMO.

I would recommend having 1 JAX-RS Application with @ApplicationPath("/") and then change the @Path annotations on SystemResource and InventoryResource to include the old /system and /inventory prefixes so the endpoints remain unchanged.

@yeekangc
Copy link
Member

yeekangc commented Jun 17, 2019

I was thinking about what you suggested, Andy, as an option too. Should still make a note of 1 JAX-RS Application per application and that system and inventory are conceptually separate and can (should) be in 2 separate apps.

@jim-krueger
Copy link
Member

The problem is if you want 2 separate apps you must either package each separately or add the getClasses() method to each application class specifying the classes involved in each application. We talked about this and consider this to be a relatively ugly solution. Therefore I agree with Andy that this should be reduced to 1 JAX-RS application. Perhaps "system" and "inventory" should be added to their respective URL's with the 1 application given a more generic name.

@mulvd
Copy link

mulvd commented Feb 3, 2024

Came across this when I was looking at why my endpoints appeared for both paths.
Interesting the interpretation here was that it ought to have been supported : https://issues.redhat.com/browse/RESTEASY-650

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants