Tomcat and proxy settings

前端 未结 6 1411
北海茫月
北海茫月 2021-01-04 10:40

There is a servlet running on tomcat7 and it makes a webservice call to a third party website. The call works fine from the windows machine but when run from tomcat it fails

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 11:02

    I do not agree with the usage of java.net.Proxy.

    What happens if you need to change it ? New build, new release. The setting of the proxy should be easy. It works well with both system properties or tomcat JAVA_OPTS. I used it in both ways. Just pay attention and be sure you know what JAVA_OPTS are loaded, what java is used and so on, because there are tomcats that have their own java version. Regardint the previous post, there is no way java can be used before was loaded :). So Tomcat cannot use it before the system properties are used...only if tomcat uses another JRE that does not read system properties.

    I just test this setup :

    set "JAVA_OPTS=%JAVA_OPTS% -Dhttp.proxyHost=proxy.com -Dhttp.proxyPort=8080 "
    

    in catalina.bat and works well.

提交回复
热议问题