Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-594

init-param not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • 2.3-RC1
    • 2.2.2.GA
    • jaxrs
    • None
    • Hide

      Test class:

      @Path("/test")
      public class TP {

      private static Logger log = Logger.getLogger(TP.class);

      @GET
      @Produces("text/plain")
      public String testContext(@Context ServletContext servletContext) {

      StringBuilder sb = new StringBuilder();
      sb.append("init parameters: \n\r");
      java.util.Enumeration penum = servletContext.getInitParameterNames();
      for ( ; penum.hasMoreElements()

      { String name = (String)penum.nextElement(); sb.append( name + "=" + servletContext.getInitParameter(name) + "\n\r" ); }

      return sb.toString();
      }
      }

      web.xml

      <web-app version="2.5" 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_2_5.xsd">
      <display-name>testing</display-name>
      <listener>
      <listener-class>
      org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
      </listener-class>
      </listener>

      <servlet>
      <servlet-name>Resteasy</servlet-name>
      <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
      <init-param>
      <param-name>aa</param-name>
      <param-value>pleasework</param-value>
      </init-param>
      </servlet>

      <servlet-mapping>
      <servlet-name>Resteasy</servlet-name>
      <url-pattern>/service/*</url-pattern>
      </servlet-mapping>

      <context-param>
      <param-name>resteasy.scan</param-name>
      <param-value>true</param-value>
      </context-param>

      <context-param>
      <param-name>resteasy.servlet.mapping.prefix</param-name>
      <param-value>/service</param-value>
      </context-param>

      </web-app>

      Show
      Test class: @Path("/test") public class TP { private static Logger log = Logger.getLogger(TP.class); @GET @Produces("text/plain") public String testContext(@Context ServletContext servletContext) { StringBuilder sb = new StringBuilder(); sb.append("init parameters: \n\r"); java.util.Enumeration penum = servletContext.getInitParameterNames(); for ( ; penum.hasMoreElements() { String name = (String)penum.nextElement(); sb.append( name + "=" + servletContext.getInitParameter(name) + "\n\r" ); } return sb.toString(); } } web.xml <web-app version="2.5" 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_2_5.xsd "> <display-name>testing</display-name> <listener> <listener-class> org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap </listener-class> </listener> <servlet> <servlet-name>Resteasy</servlet-name> <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> <init-param> <param-name>aa</param-name> <param-value>pleasework</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>Resteasy</servlet-name> <url-pattern>/service/*</url-pattern> </servlet-mapping> <context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>resteasy.servlet.mapping.prefix</param-name> <param-value>/service</param-value> </context-param> </web-app>

      A simple test of reading init params yields only:

      resteasy.servlet.mapping.prefix=/service
      resteasy.scan=true

      and not the one I have set in web.xml for org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher

              patriot1burke@gmail.com Bill Burke (Inactive)
              jharrop_jira Jason Harrop (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: