Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 谷歌地图API不适用于Openshift_Java_Google Maps_Openshift - Fatal编程技术网

Java 谷歌地图API不适用于Openshift

Java 谷歌地图API不适用于Openshift,java,google-maps,openshift,Java,Google Maps,Openshift,我正在为我的应用程序使用谷歌地图API。当它调用GoogleMapsAPI服务器时,我得到了“权限被拒绝”错误。似乎需要为调用提供代理设置 高级地理编码器类 公共类AdvancedGeoCoder扩展了Geocoder{ 私有HttpClient HttpClient; 公共高级地理编码器(最终HttpClient HttpClient){ this.httpClient=httpClient; } 公共高级地理编码器(){ 这(新的HttpClient(新的多线程HttpConnectionM

我正在为我的应用程序使用谷歌地图API。当它调用GoogleMapsAPI服务器时,我得到了“权限被拒绝”错误。似乎需要为调用提供代理设置

高级地理编码器类

公共类AdvancedGeoCoder扩展了Geocoder{
私有HttpClient HttpClient;
公共高级地理编码器(最终HttpClient HttpClient){
this.httpClient=httpClient;
}
公共高级地理编码器(){
这(新的HttpClient(新的多线程HttpConnectionManager());
}
公共高级地理编码器(字符串代理主机、int代理端口、int超时){
超级();
this.httpClient=新的httpClient(新的多线程httpconnectionmanager());
httpClient.getHostConfiguration().setProxy(proxyHost,proxyPort);
httpClient.getParams().setParameter(HttpMethodParams.SO_超时,60*超时);
}
公共高级地理编码器(最终字符串clientId,最终字符串clientKey)引发InvalidKeyException{
super(clientId,clientKey);
httpClient=新的httpClient(新的多线程HttpConnectionManager());
}
公共高级地理编码器(最终HttpClient HttpClient、最终字符串clientId、最终字符串clientKey)引发InvalidKeyException{
super(clientId,clientKey);
this.httpClient=httpClient;
}
受保护的GeocodeResponse请求(最终Gson Gson,最终字符串urlString)引发IOException{
最终GetMethod=newgetMethod(urlString);
试一试{
httpClient.executeMethod(getMethod);
最终读取器=新的InputStreamReader(getMethod.getResponseBodyAsStream(),getMethod.getResponseCharSet());
返回gson.fromJson(reader,GeocodeResponse.class);
}最后{
getMethod.releaseConnection();
}
}
}
地理编码器类

公共类地理编码器{
私有静态最终记录器Logger=LoggerFactory.getLogger(Geocoder.class);
私有静态最终字符串GEOCODE\u REQUEST\u HOST=“maps.googleapis.com”;
私有静态最终字符串GEOCODE\u REQUEST\u SERVER\u HTTP=“HTTP://”+GEOCODE\u REQUEST\u HOST;
私有静态最终字符串GEOCODE\u REQUEST\u SERVER\u HTTPS=“HTTPS://”+GEOCODE\u REQUEST\u HOST;
私有静态最终字符串GEOCODE_REQUEST_QUERY_BASIC=“/maps/api/GEOCODE/json?sensor=false”;
私有静态最终字符串编码=“UTF-8”;
私有最终字符串clientId;
专用最终Mac;
私有字符串服务器密钥;
公共字符串getServerKey(){
返回serverKey;
}
public void setServerKey(字符串serverKey){
this.serverKey=serverKey;
}
公共地理编码器(){
clientId=null;
mac=null;
}
公共地理编码器(最终字符串clientId,最终字符串clientKey)引发InvalidKeyException{
if(clientId==null | | clientId.length()==0){
抛出新的IllegalArgumentException(“未定义ClientId”);
}
if(clientKey==null | | clientKey.length()==0){
抛出新的IllegalArgumentException(“未定义ClientKey”);
}
this.clientId=clientId;
this.mac=getMAC(clientKey);
}
公共GeocodeResponse geocode(最终GeocoderRequest GeocoderRequest)引发IOException{
final Gson Gson=new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_,带下划线)。create();
最终字符串urlString=getURL(geocoderRequest);
返回请求(gson、urlString);
}
受保护的GeocodeResponse请求(Gson Gson,字符串urlString)引发IOException{
最终URL=新URL(URL字符串);
最终读取器=新的BufferedReader(新的InputStreamReader(url.openStream(),ENCODING));
试一试{
返回gson.fromJson(reader,GeocodeResponse.class);
}最后{
reader.close();
}
}
公共静态字符串getGeocoderHost(){
返回地理编码请求主机;
}
受保护字符串getURL(最终GeocoderRequest GeocoderRequest)引发不支持的DencodingException{
trace(“请求{}”,geocoderRequest);
最终StringBuilder url=getURLQuery(geocoderRequest);
如果(mac==null){
//将服务器名称添加到URL
插入(0,地理编码\请求\服务器\ HTTP);
}否则{
addClientAndSignUrl(url);
//将服务器名称添加到URL
插入(0,地理编码\请求\服务器\ HTTPS);
}
trace(“完整请求URL:{}”,URL);
返回url.toString();
}
受保护的StringBuilder getURLQuery(GeocoderRequest GeocoderRequest)引发不支持的DencodingException{
最终字符串通道=geocoderRequest.getChannel();
最终字符串地址=geocoderRequest.getAddress();
最终LatLngBounds bounds=geocoderRequest.getBounds();
最终字符串语言=geocoderRequest.getLanguage();
最终字符串region=geocoderRequest.getRegion();
最终LatLng位置=geocoderRequest.getLocation();
final EnumMap components=geocoderRequest.getComponents();
最终StringBuilder url=新StringBuilder(地理编码\u请求\u查询\u基本);
if(channel!=null&&channel.length()>0){
url.append(“&channel=”).append(urlcoder.encode(channel,ENCODING));
}
if(address!=null&&address.length()>0){
url.append(“&address=”).append(urlcoder.encode(address,ENCODING));
}else if(位置!=null){
append(“&latlng=”).append(urlcoder.encode(location.toUrlValue(),ENCODING));
}否则{
抛出新的IllegalArgumentException(“必须定义地址或位置”);
}
if(language!=null&&language.length()>0){
url.append(“&language=”).append(urlcoder.encode(语言,编码));
}
如果(区域!=null&®
2014/12/18 08:46:39,906 INFO  [org.apache.commons.httpclient.HttpMethodDirector] (http--127.13.128.129-8080-2) I/O exception (java.net.BindException) caught when processing request: Permission denied
2014/12/18 08:46:39,907 INFO  [org.apache.commons.httpclient.HttpMethodDirector] (http--127.13.128.129-8080-2) Retrying request
2014/12/18 08:46:39,909 INFO  [org.apache.commons.httpclient.HttpMethodDirector] (http--127.13.128.129-8080-2) I/O exception (java.net.BindException) caught when processing request: Permission denied
2014/12/18 08:46:39,912 INFO  [org.apache.commons.httpclient.HttpMethodDirector] (http--127.13.128.129-8080-2) Retrying request
2014/12/18 08:46:39,914 INFO  [org.apache.commons.httpclient.HttpMethodDirector] (http--127.13.128.129-8080-2) I/O exception (java.net.BindException) caught when processing request: Permission denied
2014/12/18 08:46:39,917 INFO  [org.apache.commons.httpclient.HttpMethodDirector] (http--127.13.128.129-8080-2) Retrying request
2014/12/18 08:46:39,938 ERROR [stderr] (http--127.13.128.129-8080-2) java.net.BindException: Permission denied
2014/12/18 08:46:39,940 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.net.PlainSocketImpl.socketBind(Native Method)
2014/12/18 08:46:39,943 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
2014/12/18 08:46:39,944 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.net.Socket.bind(Socket.java:631)
2014/12/18 08:46:39,945 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.net.Socket.<init>(Socket.java:423)
2014/12/18 08:46:39,946 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.net.Socket.<init>(Socket.java:280)
2014/12/18 08:46:39,947 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
2014/12/18 08:46:39,949 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
2014/12/18 08:46:39,950 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
2014/12/18 08:46:39,951 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
2014/12/18 08:46:39,954 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
2014/12/18 08:46:39,955 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
2014/12/18 08:46:39,956 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
2014/12/18 08:46:39,958 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
2014/12/18 08:46:39,959 ERROR [stderr] (http--127.13.128.129-8080-2)    at com.ndgits.geocoder.AdvancedGeoCoder.request(AdvancedGeoCoder.java:53)
2014/12/18 08:46:39,960 ERROR [stderr] (http--127.13.128.129-8080-2)    at com.ndgits.geocoder.Geocoder.geocode(Geocoder.java:73)
2014/12/18 08:46:39,961 ERROR [stderr] (http--127.13.128.129-8080-2)    at com.ndgits.rh.services.GeocodingServiceImpl.getAddress(GeocodingServiceImpl.java:65)
2014/12/18 08:46:39,962 ERROR [stderr] (http--127.13.128.129-8080-2)    at com.ndgits.rh.web.controller.PersonalInfoController.savePersonalInfo(PersonalInfoController.java:89)
2014/12/18 08:46:39,963 ERROR [stderr] (http--127.13.128.129-8080-2)    at com.ndgits.rh.web.controller.PersonalInfoController$$FastClassByCGLIB$$60c8ea34.invoke(<generated>)
2014/12/18 08:46:39,964 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
2014/12/18 08:46:39,965 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701)
2014/12/18 08:46:39,966 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
2014/12/18 08:46:39,971 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51)
2014/12/18 08:46:39,972 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2014/12/18 08:46:39,976 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
2014/12/18 08:46:39,981 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2014/12/18 08:46:39,982 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
2014/12/18 08:46:39,983 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2014/12/18 08:46:39,985 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:634)
2014/12/18 08:46:39,989 ERROR [stderr] (http--127.13.128.129-8080-2)    at com.ndgits.rh.web.controller.PersonalInfoController$$EnhancerByCGLIB$$f30f4c6e.savePersonalInfo(<generated>)
2014/12/18 08:46:39,991 ERROR [stderr] (http--127.13.128.129-8080-2)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2014/12/18 08:46:39,992 ERROR [stderr] (http--127.13.128.129-8080-2)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2014/12/18 08:46:39,993 ERROR [stderr] (http--127.13.128.129-8080-2)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2014/12/18 08:46:39,994 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.lang.reflect.Method.invoke(Method.java:606)
2014/12/18 08:46:39,995 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
2014/12/18 08:46:39,996 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
2014/12/18 08:46:39,997 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
2014/12/18 08:46:39,999 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
2014/12/18 08:46:40,000 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
2014/12/18 08:46:40,002 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
2014/12/18 08:46:40,003 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
2014/12/18 08:46:40,004 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
2014/12/18 08:46:40,033 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
2014/12/18 08:46:40,034 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)
2014/12/18 08:46:40,035 ERROR [stderr] (http--127.13.128.129-8080-2)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
2014/12/18 08:46:40,036 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
2014/12/18 08:46:40,037 ERROR [stderr] (http--127.13.128.129-8080-2)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
2014/12/18 08:46:40,038 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
2014/12/18 08:46:40,039 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
2014/12/18 08:46:40,041 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
2014/12/18 08:46:40,042 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
2014/12/18 08:46:40,043 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
2014/12/18 08:46:40,044 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
2014/12/18 08:46:40,046 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
2014/12/18 08:46:40,047 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2014/12/18 08:46:40,048 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2014/12/18 08:46:40,049 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
2014/12/18 08:46:40,050 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
2014/12/18 08:46:40,051 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
2014/12/18 08:46:40,052 ERROR [stderr] (http--127.13.128.129-8080-2)    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
2014/12/18 08:46:40,053 ERROR [stderr] (http--127.13.128.129-8080-2)    at java.lang.Thread.run(Thread.java:745)