This article documents how to configure the IP Geocoder module to start without an Internet connection. By default, this module must be connected to the Internet during the startup process. However, for some customers, it is not possible to have any connectivity and the environment remains unconnected to the web. Others require a proxy connection as an alternative; refer to Preconfiguring LCS to Connect Through a Proxy section.
The reason for the need for a web connection is that on startup, a file called GeoIPCity.dat
is downloaded automatically into the application server's newly created /../liferay/geoip
folder. (For example, in Apache Tomcat, the folder is located /temp/liferay/geoip
folder.)
Otherwise, during the startup process, the following errors will occur:
13:01:34,728 ERROR [main][IPGeocoderImpl:108] Unable to activate Liferay IP Geocoder java.net.ConnectException: Connection timed out (Connection timed out) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.http.HttpClient.(HttpClient.java:211) at sun.net.www.http.HttpClient.New(HttpClient.java:308) at sun.net.www.http.HttpClient.New(HttpClient.java:326) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at com.liferay.ip.geocoder.internal.IPGeocoderImpl.getIPGeocoderFile(IPGeocoderImpl.java:138) at com.liferay.ip.geocoder.internal.IPGeocoderImpl.configure(IPGeocoderImpl.java:101) at com.liferay.ip.geocoder.internal.IPGeocoderImpl.activate(IPGeocoderImpl.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224) at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617) at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501) at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:302) at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:294) at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:297) at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:108) at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906) at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879) at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:823) at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212) at java.security.AccessController.doPrivileged(Native Method)
Resolution
In this specific use case, system administrators must download the GeoLiteCity.dat.xz
from GeoLite Legacy Downloadable Databases.
As noted above, by default, this file is downloaded automatically but because it is downloaded into a temporary folder that is deleted when clearing the application server's cache. System administrators must take the following steps:
- Stop the application server before applying any changes.
- Extract the
.xz
to any folder other than the cache folder. - In the
/osgi/configs
folder, create a file calledcom.liferay.ip.geocoder.internal.IPGeocoderConfiguration.cfg
. - Using a text editor, open the
com.liferay.ip.geocoder.internal.IPGeocoderConfiguration.cfg
file. - Enter the following:
filePath=/path/to/permanent/location/of/GeoLiteCity.dat
(e.g. /opt/liferay/geoip/GeoLiteCity.dat
). - Save the file.
- Delete the
/osgi/state
folder. - Start the application server.
Applying these steps will allow the platform to start without the need for an Internet connection.