You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Chet Hosey (JIRA)" <ji...@apache.org> on 2013/02/05 23:43:12 UTC

[jira] [Created] (TOMEE-757) UriInfo given by embedded CXF-RS uses wrong port on AJP connections

Chet Hosey created TOMEE-757:
--------------------------------

             Summary: UriInfo given by embedded CXF-RS uses wrong port on AJP connections
                 Key: TOMEE-757
                 URL: https://issues.apache.org/jira/browse/TOMEE-757
             Project: TomEE
          Issue Type: Improvement
    Affects Versions: 1.5.1
         Environment: TomEE JAX-RS 1.5.1 on Java 1.7.0_11 64-bit, proxied through Apache httpd 2.2.23 and mod_jk 1.2.37 using AJP, running on Debian stable
            Reporter: Chet Hosey
            Priority: Minor


The UriInfo object provided by @Context injection under JAX-RS provides URIs based on the Tomcat server.xml configuration. The host name can be changed from "localhost" by changing the virtual host configuration. However there's no clear way to change the port number returned by the UriInfo methods, other than to change the actual HTTP connector port in server.xml to the desired value.

This has the unfortunate result that each TomEE instance would have to listen on its own IP address to get the port numbers to match, if the calculated URIs need to be consistent across instances. And each TomEE instance would also need elevated privileges to bind to port 80, if that is the desired URI port.

In my mind the least surprising behavior would be to match the values available via a @Context HttpServletRequest object, such as getServerName() and getServerPort(), at least for AJP connections.

Below is sample output from UriInfo, HttpHeaders, and HttpServletRequest objects passed to a JAX-RS method:

   uriInfo.getAbsolutePath(): http://localhost:8081/sample-app-1.0-SNAPSHOT/
   uriInfo.getBaseUri(): http://localhost:8081/sample-app-1.0-SNAPSHOT
   uriInfo.getRequestUri(): http://localhost:8081/sample-app-1.0-SNAPSHOT/
   httpServletRequest.getLocalAddr(): 1.2.3.4
   httpServletRequest.getLocalName(): www.example.com
   httpServletRequest.getLocalPort(): 8081
   httpServletRequest.getServerName(): www.example.com
   httpServletRequest.getServerPort(): 8081

   host:
       www.example.com:8081

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira