JAX-RS Web服务在哪个容器中运行? [英] In which container do JAX-RS web services run?

查看:156
本文介绍了JAX-RS Web服务在哪个容器中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,java EE应用服务器主要有两种类型的容器。即Web容器和EJB容器。

As of my understanding java EE application servers have mainly two types of containers. Namely web container and EJB container.

我设法在Tomcat中运行一个使用Jersey作为其实现的JAX-RS应用程序。据我所知,Tomcat只是一个Web容器。为了在tomcat中运行web服务,必须将jersey jars捆绑到war文件中,因为开箱即用,Tomcat没有jersey jars。这提出了一个问题。

I managed to run a JAX-RS application which used Jersey as its implementation, in Tomcat. As I know Tomcat is only a web container. In order to run the web service in tomcat, the jersey jars had to be bundled into the war file because out of the box, Tomcat did not have the jersey jars. This raised me a question.

tomcat是否使用除Jersey之外的其他JAX-RS实现?如果是,它是什么?

Does tomcat uses another implementation of JAX-RS other than Jersey? If Yes what is it?

如果否,

我无法运行没有将jars捆绑到war文件中的Jax-RS应用程序,这意味着JAX-RS应用程序需要的东西比Web容器提供的更多。这意味着它们不会在Web容器中运行。然后在哪个容器中运行?

I could not run the Jax-RS application without the jars bundled into the war file, this means JAX-RS apps need something more than what the web containers offer. It means they do not run in a web container. then in which container does it run?

推荐答案


tomcat是否使用JAX-RS的另一个实现除了Jersey?

"Does tomcat uses another implementation of JAX-RS other than Jersey?"

我不知道你是否在询问Tomcat是否有实现或者是否能够运行泽西岛旁边的其他实施。

I don't know if you're asking if Tomcat has an implementation or if it is capable of running other implementations beside Jersey.

前者的答案是否定的。 Vanilla Tomcat不支持JAX-RS。它不是EE服务器,而只是一个Servlet容器。但 TomEE + (基于Tomcat构建)支持(使用CXF)。

The answer to the former is no. Vanilla Tomcat does not support JAX-RS out the box. It is not an EE server, but simply a Servlet container. But TomEE+ (built on Tomcat) has support (using CXF).

后者的答案是肯定的。您只需要添加实现jar并正确配置应用程序

The answer to the latter is yes. You just need to add that implementations jars and configure the app properly


如果没有捆绑的jar,我无法运行Jax-RS应用程序战争文件

"I could not run the Jax-RS application without the jars bundled into the war file"

是的,你不能。简单来说,没有实现来支持JAX-RS运行时。

Yup, you can't. For the simple fact there is no implementation to support the JAX-RS runtime.


这意味着它们不在Web容器中运行。那么它在哪个容器中运行?

"It means they do not run in a web container. then in which container does it run?"

它确实在Servlet容器中运行。 JAX-RS实际上是建立在Servlets之上的。对于Jersey,它使用 ServletContainer 。 Tomcat将向Jersey Servlet发送请求,Jersey将通过配置的提供者和资源处理请求,并将响应吐出回容器。容器将响应发送给客户端。 (请参阅下面的第一个链接)

It does run in the Servlet container. JAX-RS is actually built on top of Servlets. For Jersey, it uses the ServletContainer. Tomcat will ship off requests to the Jersey Servlet, and Jersey will process the request through configured provider and resources and spit out the response back to the container. The container will send the response to the client. (See first link below)

如果您正在寻找支持整个EE规范的Java EE应用服务器,你可以看看Glassfish(它使用Jersey作为它的实现),JBoss / Wildfly(它使用Resteasy),上面提到的TomEE +(使用CXF)

If you are looking for a Java EE application server, that supports the whole EE spec, you can look at Glassfish (it uses Jersey as it's implementation), JBoss/Wildfly (it uses Resteasy), TomEE+ mentioned above (uses CXF)

以下是一些您可能感兴趣的相关读物:

  • Confusion with JAX-RS and Jersey with JAX-RS
  • JAX-RS specification - 2.3 Publication
  • Java-ee REST server with IntelliJ and Tomcat
  • How to use Jersey as JAX-RS implementation without web.xml?

这篇关于JAX-RS Web服务在哪个容器中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆