JAX-RS Jersey on Glassfish 3.0.1: Can I have an empty webapp element in my web.xml?

I understand that Glassfish 3 is compatible with JEE6 and jax-rs, and therefore I should not include the jersey servlet container and display in my web.xml file. Here I was hoping my web.xml might look like

<webapp>
</webapp>

This does not work, although I get 404 when I try to hit my jax-rs dependent resources. It works fine when I enable the servlet adapter, for example:

<webapp>
  <servlet>
    <servlet-name>ServletAdaptor</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servle
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>ServletAdaptor</servlet-name>
    <url-pattern>/*</url-pattern>
  </servlet-mapping>
</webapp>

Is it possible to have an empty webapp element using glass fish jersey 3.0.1?

+3
source share
2 answers

JAX-RS, Java EE 6, , :

  • javax.ws.rs.core.Application -.
  • @javax.ws.rs.ApplicationPath("/*") .

. , @Path/@Provider, , , @ApplicationPath . web.xml.

web.xml , JAX-RS , ( url) . , / URL-, @Path/@Provider Application.getClasses().

+4

web-fragment.xml, , web.xml. , .

web.xml, - ee6 Netbeans.

<web-app version="3.0"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
</web-app>
0

Source: https://habr.com/ru/post/1750832/


All Articles