Configuring Java™ applications that use Apache HTTP client libraries to use the HTTP proxy
Some Java™ applications use Apache HTTP client libraries to make HTTP requests. These libraries do not support the standard Java system property settings for HTTP proxies. In such cases, you must manually change the application to use proxy settings. As an alternative, the Java virtualization agent can be used to inject the proxy settings.
About this task
When a Java application sends HTTP(s) requests that are to be recorded or processed by a stub, the requests must be routed through the HCL DevOps Test Integrations and APIs (Test Integrations and APIs) HTTP/TCP proxy. In Test Integrations and APIs version 8.7 or earlier, you can use the HTTP proxy configuration injection tool that is provided with HCL DevOps Test Virtualization Control Panel (Test Virtualization Control Panel) for configuring the Java applications to use the HTTP proxy. The tool is deprecated starting with Test Integrations and APIs version 8.7.1 and removed starting with version 9.0.0. The proxy injection is now supported by the Java virtualization agent. To use the proxy injection feature, follow these steps:
Procedure
- Install the Java virtualization agent into the Java application or the server. For instructions, see Installing a Java virtualization agent into a Java application.
-
Using a text editor, open the
registration.xml
file for the Java virtualization agent. -
Uncomment the following code block in
registration.xml
and edit the values as necessary:<http-proxy-inject host="localhost" port="3128" https-host="" https-port=""> <inject apache-v3="off" apache-v4="off" system-props="off"/> </http-proxy-inject>
- host: Enter the hostname of the proxy.
- port: Enter the port number for the proxy.
- https-host (optional): If another proxy host is required for HTTPS requests, enter the hostname; otherwise, leave it blank.
- https-port (optional): If another proxy port is required for HTTPS requests, enter the port number; otherwise, leave it blank.
- apache-v3: When this parameter is set to "on", the proxy settings are inserted for Apache HTTP client v3 API usage.
- apache-v4: When this parameter is set to "on", the proxy settings are inserted for Apache HTTP client v4 API usage.
- system-props: When this parameter is set to "on", the standard Java HTTP proxy-related system properties are set through the code.
-
Save and close the
registration.xml
file. - Restart the Java™ application or server.