最近有个朋友问我在集群环境中,内网的tomcat启动失败并报如下错误,如何破?
09:29:40.583 [localhost-startStop-1] WARN o.s.b.f.xml.XmlBeanDefinitionReader - Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/tx/spring-tx-4.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
解决过程如下:
分析这是由于无公网IP的机器无法访问外网连接导致,所以建议他先搭建个squid代理集群中的内网机器上网。
在squid服务器中设置完规则后,在客户端中的/etc/profile中加入:
http_proxy=ip:端口
https_proxy=ip:端口
export http_proxy https_proxy
然后source下,之后通过curl -I www.baidu.com 查看得到200,可以访问
但是启动tomcat的时候还是报同样的错,思考java引用的时候是不是没有走代理呢?
之后参考这篇文章中第一种解决方法 http://viralpatel.net/blogs/http-proxy-setting-java-setting-proxy-java/
在catalina.sh中加入了如下启动参数:
#------http proxy
CATALINA_OPTS="-DproxySet=true -DproxyHost=192.168.1.65 -DproxyPort=3128"
其中192.168.1.65为squid服务器ip,3128为端口,这样就指定了java使用代理
重新启动后正常引用,这只是一种方法。
其实应该把外部引用本地化,这样既避免了外部劫持,又可以防止GFW墙掉。
转载请注明:技术拾零 » java程序在内网环境中调用外网的spring时出错