perl: warning: Please check that your locale settings:LANGUAGE = (unset),LC_ALL = (unset), ubuntu

Problem

Was getting the following locale error when I try run a script that displays the output on the terminal or update the server’s packages:


perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),

Solution

Solution was to set the Locale for LANGUAGE and LC_ALL since those are the 2 locales that had not been set. I used the update-locale app that writes to the /etc/default/locale file:


imela@whiscardz:$ less /etc/default/locale
# File generated by update-locale
LANG=en_US.UTF-8

imela@whiscardz:$ sudo update-locale LANGUAGE=en_US.UTF-8
[sudo] password for imela:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

imela@whiscardz:$ sudo update-locale LC_ALL=en_US.UTF-8
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US.UTF-8",
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").

imela@whiscardz:$ cat /etc/default/locale
# File generated by update-locale
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8

You just need to set the Locales that were unset so in my case this was LANGUAGE and LC_ALL then check the /etc/default/locale file to see if your locales are now set.

References

Configure Locales in Ubuntu

Perl warning Setting locale failed in Debian

How do I fix my locale issue?

method driver /usr/lib/apt/methods/https// could not be found

Problem

Every time I would run apt-get update, I would get the error below:


implementer@whiscardz ~ $ sudo apt-get update

Reading package lists... Done
E: The method driver /usr/lib/apt/methods/https// could not be found.
E: Failed to fetch https//://deb.opera.com/opera-developer/dists/stable/InRelease
E: Some index files failed to download. They have been ignored, or old ones used instead.

Solution

And this was affecting the opera developer source list.

If you look closely at the url you’ll notice there is a typo the : should come before //

E: Failed to fetch https//://deb.opera.com/opera-developer/dists/stable/InRelease

Solution was to therefore edit the file:


implementer@whiscardz ~ $ sudo vim /etc/apt/sources.list.d/opera
opera-developer.list opera.list
implementer@whiscardz ~ $ sudo vim /etc/apt/sources.list.d/opera-developer.list

deb https://deb.opera.com/opera-developer/ stable non-free #Opera Browser (final releases)
implementer@whiscardz ~ $ sudo apt-get update

This time cache update runs fine without errors.

References

How do I fix a “E: The method driver /usr/lib/apt/methods/http could not be found.” error?

Install Multiple Java versions and Setup Maven to Use one – Java 1.7

Problem

I was running Java 1.8 by default but I needed to build some modules that require Java 1.7

Solution

Check the default version of Java installed as well as the version of Java that maven is using:


implementer@whiscardz ~ $ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

implementer@whiscardz ~ $ mvn -v
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-78-generic", arch: "amd64", family: "unix" 
  • Install Java 1.7 as instructed in this link.
  • Create a .mavenrc file in your home directory and then add the JAVA_HOME of Java 1.7 In my case this would be JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
implementer@whiscardz ~ $ vim .mavenrc

JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
  • Optional, Run the maven file to assign the JAVA variable on the current terminal
implementer@whiscardz ~ $ source .mavenrc
  • Check version of Java Maven is now using:
implementer@whiscardz ~ $ mvn -version
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-78-generic", arch: "amd64", family: "unix"

References

Create .mavenrc file

How to change maven java home

Manually Install Tomcat7 on Ubuntu 16.04

Problem

Tomcat7 in the Ubuntu 16.04 repository was compiled using Java8 and this caused a problem with OpenMRS that needed Java7.

This issue has been mentioned also on stackoverflow and also apache bugzilla.

Solution

The solution was to download Apache manually. I used Apache v7.0.70. You can download and extract the folder in the tmp folder:

root@whiscardz # cd /tmp/
root@whiscardz /tmp # curl -O http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz 
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 8715k 100 8715k 0 0 2155k 0 0:00:04 0:00:04 --:--:-- 2155k

root@whiscardz /tmp # ll apache-tomcat-7.0.70.tar.gz 
-rw-r--r-- 1 root root 8924465 Jan 13 13:00 apache-tomcat-7.0.70.tar.gz
root@whiscardz /tmp # tar xzvf apache-tomcat-7*tar.gz -C /opt/tomcat --strip-components=1

root@whiscardz /tmp # ll /opt/tomcat/
total 124
drwxr-xr-x 9 root root 4096 Jan 13 13:01 ./
drwxr-xr-x 11 root root 4096 Jan 13 12:55 ../
drwxr-xr-x 2 root root 4096 Jan 13 13:01 bin/
drwxr-xr-x 2 root root 4096 Jun 15 2016 conf/
drwxr-xr-x 2 root root 4096 Jan 13 13:01 lib/
-rw-r--r-- 1 root root 56846 Jun 15 2016 LICENSE
drwxr-xr-x 2 root root 4096 Jun 15 2016 logs/
-rw-r--r-- 1 root root 1239 Jun 15 2016 NOTICE
-rw-r--r-- 1 root root 8965 Jun 15 2016 RELEASE-NOTES
-rw-r--r-- 1 root root 16195 Jun 15 2016 RUNNING.txt
drwxr-xr-x 2 root root 4096 Jan 13 13:01 temp/
drwxr-xr-x 7 root root 4096 Jun 15 2016 webapps/
drwxr-xr-x 2 root root 4096 Jun 15 2016 work/
root@whiscardz /tmp # 

Create a tomcat user and group:

root@whiscardz # groupadd tomcat
root@whiscardz # useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

cd to the directory and then change the owner and permissions and group of the files and directories:

root@whiscardz # cd /opt/tomcat/

root@whiscardz /opt/tomcat # chgrp -R tomcat conf
root@whiscardz /opt/tomcat # chmod g+rwx conf
root@whiscardz /opt/tomcat # chmod g+r conf/*
root@whiscardz /opt/tomcat # chown -R tomcat work/ temp/ logs/ 

Then check the path of Java. This will be used in the JAVA_HOME env variable only appending /jre to the end of the result.

See JAVA_HOME Environment variable in the systemd service file below:

root@whiscardz ~ # update-java-alternatives -l
java-7-oracle 1 /usr/lib/jvm/java-7-oracle 

Create a systemd service file below. Make sure to edit the JAVA_HOME;CATALINA_PID;  CATALINA_HOME; CATALINA_BASE; CATALINA_OPTS; ExecStart and ExecStop Variables to suite your environment

root@whiscardz ~ # vim /etc/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment='CATALINA_OPTS=-Xmx2048M -Xms2048M -XX:PermSize=512m -XX:MaxPermSize=512m -XX:NewSize=256m -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

Reload the systemd daemon so that it picks up your tomcat.service file above. Then you can start tomcat. You can also stop tomcat and check if it stops.

Then you can enable the service so that it is started when the machine is rebooted :

root@whiscardz ~ # systemctl daemon-reload
root@whiscardz ~ # systemctl start tomcat

root@whiscardz ~ # systemctl stop tomcat
root@whiscardz ~ # systemctl enable tomcat 

Incase you should down tomcat using the shutdown.sh script alone and it doesnt shutdown, check out this post.

Resources

How To Install Apache Tomcat 8 on Ubuntu 16.04

Install Apache Tomcat 9 on CentOS 7 / RHEL 7 / Ubuntu 16.04

How to Install Tomcat 7.0.68 Server on Ubuntu, Debian & LinuxMint

Tomcat shutdown does not kill process

Tomcat doesn’t stop. How can I debug this?

Tomcat 7 doesn’t shut down, process keeps running?

Apache Tomcat 8 Start stop script init.d script

Starting, Stopping, and Restarting Tomcat