apt-get update – W: Failed to fetch http://archive.canonical

I have a confession to make; I am obsessed with problem solving….. I know you’re probably looking forward to seeing how I solved the problem, but I figured you might be interested in some background information before we proceed. I was in the process of installing a digital repository tool (DSpace) and it so happens that Oracle Java JDK 6+ is one of the prerequisite software required; the result of not installing Oracle’s JDK is below 🙁

dspace@PHRLIG001:/usr/local/dspace/bin$ /usr/local/dspace/bin/dspace create-administrator
 Exception in thread "main" java.lang.NoClassDefFoundError: org/dspace/kernel/DSpaceKernel|
 at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:48)
 Caused by: java.lang.ClassNotFoundException: org.dspace.kernel.DSpaceKernel
 at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
 ... 1 more

Unfortunately, Ubuntu 10.10 comes bundled with OpenJDK instead. I initially thought installing the Oracle JDK would be a straight forward process… boy was I wrong. The apt-get update couldn’t get through to a couple of repositories and as a result, I was unable to download the JDK.

Err http://archive.canonical.com maverick Release.gpg
 Could not connect to archive.canonical.com:80 (, connection timed out
 Err http://archive.canonical.com/ubuntu/ maverick/partner Translation-en
 Unable to connect to archive.canonical.com:http:
 Err http://archive.canonical.com/ubuntu/ maverick/partner Translation-en_ZA
 Unable to connect to archive.canonical.com:http:
 Err http://archive.canonical.com lucid Release.gpg

I literally tried almost all solutions offered online and finally stumbled upon one that worked for me. I basically sit behind a proxy server and had to explicitly tell apt-get where to find proxy details.

phiri@PHRLIG001:/etc/apt$ sudo vi apt.conf

Change contents of apt.conf file to below.

Acquire::http::Proxy "http://localhost:1328/";

I have CNTLM configured on my machine, but you could just as well replace the contents with actual details of the proxy server you connect through; if that is the case, replace the contents of the apt.conf file with the code below.

Acquire::http::Proxy http://username:user-password@proxy-server-address:8080/

I hope this helps.