java - Is Tomcat a JAX-RS aware Servlet Container -


from textbook "restful java jax-rs" can read:

if our application server jax-rs-aware or, in other words, tightly integrated jax-r declare our shoppingapplication class servlet:

<?xml version="1.0"?>  <web-app>  <servlet>  <servlet-name>rest</servlet-name>  <servlet-class>  com.restfully.shop.services.shoppingapplication  </servlet-class>  </servlet>  <servlet-mapping>  <servlet-name>rest</servlet-name>  <url-pattern>/*</url-pattern>  </servlet-mapping>  </web-app>  

if our application server not jax-rs-aware, have specify jax-rs provider’s servlet handles jax-rs invocations. application class should specified init-param of servlet:

now question is: tomcat jax-rs aware servlet container? how distinguish servlet container jax-rs aware 1 wich not jax-rs aware? why in first case it's possible use custom class wich extends javax.ws.rs.core.application servlet?

"is tomcat jax-rs aware servlet container?"

no.

"how distinguish servlet container jax-rs aware 1 wich not jax-rs aware?"

the fact servlet container, should tell not "jax-rs aware". jax-rs part of java ee specification. servlet containers supports name implies; container servlets. might have support other little features jsp, not support entire ee spec. not part of design. if want use jax-rs in servlet container, need add implementation, jersey or resteasy

when servlet container think of servers jetty, tomcat, undertow, grizzly. if want full java ee support need actual java ee application server supports entire spec, jboss/wildfly, glassfish, tomee, websphere, weblogic.

"why in first case it's possible use custom class wich extends javax.ws.rs.core.application servlet?"

tl;dr

if "tightly integrated jax-rs", author means server default compliant jax-rs spec (pretty java ee application sever), following statement (along corresponding web.xml configuration) is false:

"if our application server jax-rs-aware or, in other words, tightly integrated jax-rs declare our shoppingapplication class servlet:"


i not able produce working example either glassfish 4.0 or wildfly 8.1, nor specified anywhere in jax-rs specification. in glassfish, i'll exception shoppingapplication not being servlet, , in wildfly i'll notfoundexception, meaning application never loaded.

the closest thing find book states, specify name of application class <servlet-name> (which is part of jax-rs spec, not @ dependent on being deployed java ee server)

<servlet>     <servlet-name>com.restfully.shop.services.shoppingapplication</servlet-name> </servlet> <servlet-mapping>     <servlet-name>com.restfully.shop.services.shoppingapplication</servlet-name>     <url-pattern>/api/*</url-pattern> </servlet-mapping> 

this jax-rs spec

if application subclass present not being handled existing servlet servlet added containerinitializer must named qualified name of application subclass.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -