On Mon, Mar 7, 2016 at 5:48 PM, Sean Dawson <seandawson2...@gmail.com> wrote:
> > > On Mon, Mar 7, 2016 at 5:44 PM, David Kerber <dcker...@verizon.net> wrote: > >> On 3/7/2016 5:11 PM, Sean Dawson wrote: >> >>> On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawson <seandawson2...@gmail.com> >>> wrote: >>> >>> Tomcat 8_32 >>>> Windows 7 >>>> Java 8_51 >>>> RestEasy 3.0.11.Final >>>> GWT 2.7.0 (Jetty jetty-9.3.5.v20151012) >>>> >>>> Servlet code makes a RestEasy call to another servlet (same container) - >>>> second servlet sets the 'Warning' HTTP header on response. Would like >>>> to >>>> access that in first servlet but when running in Tomcat, that header is >>>> not >>>> included. >>>> >>>> Code to get header in first servlet: >>>> >>>> Object headers = ((ClientResponseFailure) >>>> e).getResponse().getResponseHeaders().get("Warning"); >>>> >>>> Also tried: getHeaders(), getStringHeaders(), and getHeaderString(). >>>> >>>> When running GWT in superdev mode in IntelliJ (15.0.4) using Jetty, the >>>> above returns a List with one item that contains the warning string. >>>> When >>>> remote debugging Tomcat, that call returns null. >>>> >>>> Added this to web app xml, and also tried Tomcat conf/web.xml... >>>> >>>> <filter> >>>> <filter-name>CorsFilter</filter-name> >>>> >>>> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> >>>> <init-param> >>>> <param-name>cors.exposed.headers</param-name> >>>> <param-value>Warning</param-value> >>>> </init-param> >>>> </filter> >>>> <filter-mapping> >>>> <filter-name>CorsFilter</filter-name> >>>> <url-pattern>/*</url-pattern> >>>> </filter-mapping> >>>> >>>> Also tried cors.allowed.headers. >>>> >>>> Any pointers? >>>> >>>> >>>> Alright, lets try this again. Simple reproducible testcase... >>> >>> - download latest Tomcat 8 for Windows 64-bit zip >>> >>> http://mirrors.ocf.berkeley.edu/apache/tomcat/tomcat-8/v8.0.32/bin/apache-tomcat-8.0.32-windows-x64.zip >>> - extract somewhere >>> - delete everything in webapps folder >>> - build project below, put in webapps folder >>> - go to: http://localhost:8080/one >>> - check response headers... no Warning header >>> >>> ** pom.xml ** >>> >>> <project xmlns="http://maven.apache.org/POM/4.0.0" >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 >>> http://maven.apache.org/maven-v4_0_0.xsd"> >>> <modelVersion>4.0.0</modelVersion> >>> >>> <groupId>test</groupId> >>> <artifactId>tcTest</artifactId> >>> <packaging>war</packaging> >>> <version>1.0-SNAPSHOT</version> >>> >>> <name>tcTest Maven Webapp</name> >>> <url>http://maven.apache.org</url> >>> >>> <dependencies> >>> <dependency> >>> <groupId>org.glassfish</groupId> >>> <artifactId>javax.servlet</artifactId> >>> <version>3.1.1</version> >>> </dependency> >>> <dependency> >>> <groupId>org.jboss.resteasy</groupId> >>> <artifactId>resteasy-client</artifactId> >>> <version>3.0.11.Final</version> >>> </dependency> >>> </dependencies> >>> >> >> If you're adding Maven, Glassfish and JBoss, you're adding a LOT of >> complexity to your "simple" reproducible! I've never used any of them, so >> would have no hope of reproducing your issue. And there's a fair chance >> that it has nothing to do with Tomcat anyway, given all the other stuff >> around it... >> >> > I could remove JBoss from the equation - and maven, although I'm pretty > sure that's not adding much complexity. If I run it on jetty instead of > tomcat, it works fine. So I'm leaning toward Tomcat (or something extra I > need to do for Tomcat) as the issue. > > Ok using httpclient instead of RestEasy shows the header. Strange that RestEasy passes headers in the Jetty case but not the Tomcat one. But I'll see if I can get help from them. Thanks. >> >> >>> <build> >>> <finalName>ROOT</finalName> >>> </build> >>> </project> >>> >>> >>> ** web.xml ** >>> >>> >>> <!DOCTYPE web-app PUBLIC >>> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" >>> "http://java.sun.com/dtd/web-app_2_3.dtd" > >>> >>> <web-app> >>> <display-name>Archetype Created Web Application</display-name> >>> >>> <servlet> >>> <servlet-name>One</servlet-name> >>> <servlet-class>pkg.ServletOne</servlet-class> >>> </servlet> >>> >>> <servlet-mapping> >>> <servlet-name>One</servlet-name> >>> <url-pattern>/one/*</url-pattern> >>> </servlet-mapping> >>> >>> <servlet> >>> <servlet-name>Two</servlet-name> >>> <servlet-class>pkg.ServletTwo</servlet-class> >>> </servlet> >>> >>> <servlet-mapping> >>> <servlet-name>Two</servlet-name> >>> <url-pattern>/two/*</url-pattern> >>> </servlet-mapping> >>> </web-app> >>> >>> >>> ** index.html ** >>> >>> >>> <html> >>> <body> >>> <h2>Hello World!</h2> >>> </body> >>> </html> >>> >>> >>> ** Caller interface ** >>> >>> >>> package pkg; >>> >>> import javax.ws.rs.GET; >>> import javax.ws.rs.Path; >>> >>> public interface Caller >>> { >>> @GET >>> @Path("two") >>> String makeCall(); >>> } >>> >>> >>> >>> ** Servlet one ** >>> >>> >>> package pkg; >>> >>> import java.io.IOException; >>> >>> import javax.servlet.ServletException; >>> import javax.servlet.http.HttpServlet; >>> import javax.servlet.http.HttpServletRequest; >>> import javax.servlet.http.HttpServletResponse; >>> import javax.ws.rs.core.MediaType; >>> >>> import org.jboss.resteasy.client.ProxyBuilder; >>> >>> public class ServletOne extends HttpServlet >>> { >>> Caller caller; >>> >>> @Override >>> public void init() throws ServletException >>> { >>> caller = ProxyBuilder.build(Caller.class, >>> "http://localhost:8080").now(); >>> } >>> >>> @Override >>> protected void doGet(HttpServletRequest request, >>> HttpServletResponse response) throws ServletException, IOException >>> { >>> String result = caller.makeCall(); >>> response.getWriter().println(result); >>> } >>> } >>> >>> >>> ** Servlet two ** >>> >>> >>> package pkg; >>> >>> import java.io.IOException; >>> >>> import javax.servlet.ServletException; >>> import javax.servlet.http.HttpServlet; >>> import javax.servlet.http.HttpServletRequest; >>> import javax.servlet.http.HttpServletResponse; >>> >>> public class ServletTwo extends HttpServlet >>> { >>> @Override >>> protected void doGet(HttpServletRequest request, >>> HttpServletResponse response) throws ServletException, IOException >>> { >>> addHeader(response); >>> response.getWriter().println("Ok"); >>> } >>> >>> void addHeader(HttpServletResponse response) >>> { >>> response.setHeader("Warning", "This is a warning"); // also >>> tried addHeader() >>> } >>> } >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org >> For additional commands, e-mail: users-h...@tomcat.apache.org >> >> >