Tinkering the Java classpath to fix ClassNotFoundException

So I recently got an annoying ClassNotFoundException. I browsed the net and I found the solution here at IBM website by Elliotte Rusty Harold. I copy here the article, just in case the original article disappear.


The classpath is the connection between the Java runtime and the filesystem. It defines where the interpreter looks for .class files to load. The basic idea is that the filesystem hierarchy mirrors the Java package hierarchy, and the classpath specifies which directories in the filesystem serve as roots for the Java package hierarchy.
Unfortunately, file systems are complex and very platform dependent, and they don't perfectly match Java packages. Consequently, the classpath has been a thorn in the side of both new users and experienced Java programmers for years. It isn't the pretty part of the Java platform. It is the annoying glitch that keeps you working well past 5 p.m., trying to debug a small problem that stubbornly refuses solution.
A good IDE like Eclipse can shield you from some of the difficulties of managing the classpath, but only somewhat, and only as long as nothing goes wrong (and something always goes wrong). Consequently, it is essential that every Java programmer fully understand the classpath. Only with in-depth understanding can you hope to debug the thorny problems that arise from the classpath.
In this article, I lay out everything you need to know about the Java classpath (and the associated sourcepath) on UNIX, Linux, and Mac OS X. In the companion article, I demonstrate similar techniques for Windows. Following the procedures outlined here will serve as a guide along the way, and should cure most classpath problems.
Package structure
Mastering the classpath begins with the source code. Every class belongs in a package, and this package must follow the standard naming conventions. To briefly review: A package name begins with a two-level reversed domain name such ascom.example or edu.poly. This is followed by at least one more word that describes the contents of the package. For example, because I own the domain name elharo.com, if I were to write a Fraction class, I might place it in one of the following packages:
  • com.elharo.math
  • com.elharo.numbers
  • com.elharo.math.algebra.fields
After the reversed domain name, use only single-word subpackage names. Do not abbreviate, and do spell all words correctly. Use a spell checker if you need to. A large percentage of classpath-related problems are caused by using one word in the source code and a slightly different spelling or abbreviation of that word in the filesystem. The only sensible choice is to always use correctly spelled, unabbreviated names.
The entire package name should be lowercase, even for proper names and acronyms that are normally capitalized. The package name should be composed exclusively of ASCII characters. While the compiler accepts package names written in Hebrew, Cyrillic, Greek, and other scripts, many file systems don't. As you'll see shortly, these package names will have to serve double duty as directory names. Consequently, package (and class) names should be limited to ASCII. (While Java package and class names are Unicode, many file systems are not yet Unicode-savvy. Simply copying a file to a system with a different default encoding can keep the compiler and interpreter from finding the right classes.)

Throwaway code

If you're just writing a single class to test your intuition about an API and you will throw it away immediately after running it once, then you don't have to put it in a package. However, any class that will be used more than once should be in a package.
Do not skimp on your package name! It will only lead to disaster in the long run. If you need a domain name, buy one. If the names are too long, buy a shorter one. (I once bought xom.nu so my package prefix was only six characters long.) Do not place your classes in the default package (the package you get if you don't include a package statement in the class). If package access prevents objects from communicating, add more public methods to the classes. Every class you use more than once must be in a package.
Directory structure
The next step is to organize your source files to match the package structure. Create a clean, empty directory somewhere. For the purposes of this article, I'll name it project. Inside this directory, create two more directories: bin and src. (Some people prefer to name these build and source, respectively.)
Next, inside the src directory, make a hierarchy that mirrors your package hierarchy. For example, given a class namedcom.elharo.math.Fraction, I would place a com directory in the src directory. Then I would create an elharo directory inside the com directory. Then I would put a math directory inside the elharo directory. Finally, I would put Fraction.java inside this math directory, as shown in Figure 1:

Figure 1. Directory structure follows the package structure



You can do this with one mkdir -p command:
$ mkdir -p com/elharo/math

Very important: Never put anything other than source code in your src directory. Usually the only files you put there are .java files. On occasion, you may place .html files (for Javadoc) or other types of source code in this directory. However, you never want to put .class files or other compiled, generated artifacts in this hierarchy. Doing so is a recipe for disaster. Sadly, the javac compiler will do exactly that unless you're careful. In the next section, I'll show you how to fix that.
Compiling
Compiling Java code is tricky because you need to keep track of several related but different things:
  • The target file you're compiling.
  • The directory where the compiler looks for .java files that the target file imports.
  • The directory where the compiler looks for .class files the target file imports.
  • The directory where the compiler puts the compiled output.
By default, the javac compiler thinks all of these are the current working directory, which is almost never what you want. Consequently, you need to explicitly specify each of these elements when you compile.
The file to compile
The first thing you specify is the .java file you're going to compile. This is given as a path to that file from the current working directory. For example, suppose you are in the project directory shown in Figure 1. This directory contains an src directory. The src directory contains a com directory, which contains the example directory, which contains the Fraction.java file. The following command line compiles it:
$ javac src/com/elharo/math/Fraction.java

If the path is incorrect, you'll get an error message like this one:
error: cannot read: src/com/example/mtah/Fraction.java

If you see this error message, check each piece of the path to make sure it's spelled correctly. Then check that the file really is where it's supposed to be by doing an ls like the one shown here:
$ ls src/com/example/math
ls: src/com/example/math: No such file or directory

This problem usually indicates a mistyped path, but it can also mean that you're not in the directory you think you're in. In this example, you'd check to see that the current working directory is the project directory. The pwd command is helpful here. For example, the following tells me that I'm actually in the project/src instead of the project directory:
$ pwd
/Users/elharo/documents/articles/classpath/project/src

I need to cd .. before compiling.
Where the output goes
Assuming there are no syntax errors, javac places the compiled .class file in the same directory where the .java file is. You do not want this. Mixing .class and .java files makes it very hard to clean up the compiled files without accidentally deleting .java files you want to keep. This makes clean builds problematic and tends to result in versioning problems. It also makes it hard to jar up just the compiled .class files when distributing a binary. Therefore, you need to tell the compiler to put the compiled output in a completely different directory. The -d switch specifies the output directory (usually called bin, build, or classes):
$ javac -d bin src/com/elharo/math/Fraction.java

Now the output is as shown in Figure 2. Notice that javac has created the complete com/elharo/math hierarchy of directories. You do not need to do it manually.

Figure 2. Parallel source and compiled hierarchies



The sourcepath
The directory where Java looks for source files is called the sourcepath. In the scheme outlined here, this is the src directory. It is the directory that contains the hierarchy of source files, organized into their own directories. It is not the com directory or the src/com/elharo/math directory.
Most projects use more than one class and more than one package. These are connected by import statements and fully package-qualified class names. For example, suppose you now create a new MainFrame class in the com.elharo.guipackage, as shown in Listing 1:

Listing 1. A class in one package can import a class in another
package com.elharo.gui;

import com.elharo.math.*;

public class MainFrame {

public static void main(String[] args) {
Fraction f = new Fraction();
// ...
}

}

This class uses the com.elharo.math.Fraction class in a different package from the MainFrame class. The source setup is now as shown in Figure 3. (I have deleted the compiled output from the previous step. I can always compile it again.)

Figure 3. Source structure for several packages


Now let's see what happens when I try to compile MainFrame.java like I did before:

Listing 2. Compiling MainFrame.java
$ javac -d bin src/com/elharo/gui/MainFrame.java
src/com/elharo/gui/MainFrame.java:3: package com.elharo.math does not exist
import com.elharo.math.*;
^
src/com/elharo/gui/MainFrame.java:7: cannot find symbol
symbol : class Fraction
location: class com.elharo.gui.MainFrame
private Fraction f = new Fraction();
^
src/com/elharo/gui/MainFrame.java:7: cannot find symbol
symbol : class Fraction
location: class com.elharo.gui.MainFrame
private Fraction f = new Fraction();
^
3 errors

The errors in Listing 2 happened because although javac knew where to find MainFrame.java, it didn't know where to find Fraction.java. (You'd think it would be smart enough to notice the matching package hierarchies, but it's not.) To clue it in, I have to specify the sourcepath. This specifies the directories where the compiler looks for the hierarchy of source files. In Listing 2, that's src. So I use the -sourcepath option, like so:
$ javac -d bin -sourcepath src src/com/elharo/gui/MainFrame.java

Now the program compiles without error and produces the output shown in Figure 4. Notice that javac also compiled the file Fraction.java, referenced by the file I was compiling.

Figure 4. Multiclass output



Compiling multiple directories in the sourcepath
You can actually have more than one directory in your sourcepath, separated by colons, though this is usually not necessary. For example, if I want to include both the local src directory and the directory /Users/elharo/Projects/XOM/src where I keep the source code for another project, I can compile like this:
$ javac -d bin -sourcepath src:/Users/elharo/Projects/XOM/src
src/com/elharo/gui/MainFrame.java

This command does not compile every file found in either of those hierarchies. It only compiles the files referenced directly or indirectly by the single .java file I explicitly ask to be compiled.
Much more commonly, you'll have a single source directory for .java files, but multiple directories for classes or JAR archives where precompiled third party libraries are placed. This is the role of the classpath.
Setting the classpath
In medium-to-large projects, recompiling every file every time can be time-consuming. You can ease this burden by separately compiling and storing independent parts of the same project in different classes or bin directories. These directories are added to the classpath.
There are several ways to add a class to the classpath. The -classpath command-line switch is the only one you should use, however. For example, suppose I want to import files from another project that I've previously compiled into the directory /Users/elharo/classes. Then I would add -classpath /Users/elharo/classes to the command line like so:
$ javac -d bin -sourcepath src -classpath /Users/elharo/classes
src/com/elharo/gui/MainFrame.java

Now suppose I need to add two directories, /Users/elharo/project1/classes and /Users/elharo/project2/classes. Then I would include them both separated by a colon, like this:
$ javac -d bin -sourcepath src
-classpath /Users/elharo/project1/classes:/Users/elharo/project2/classes
src/com/elharo/gui/MainFrame.java


Top-level directories

Notice that the directories I reference here are all top-level directories that contain a hierarchy like com/elharo/foo/bar or nu/xom/util. Directories whose names match package names (com, elharo, math, etc.) are never included directly in the sourcepath or classpath.




Of course, you can use various forms of relative paths if you prefer. For instance, if project1 and project2 are siblings of the current working directory (that is, they have the same parent directory), then I could reference them like this:
$ javac -d bin -sourcepath src
-classpath ../project1/classes:../project2/classes
src/com/elharo/gui/MainFrame.java

So far, I've assumed the program is complete onto itself and does not use any separately compiled third-party libraries. If it does, you'll need to add them to the classpath too. Libraries are usually distributed as JAR files such as junit.jar or icu4j.jar. In this case, it is the JAR file itself that you add to the classpath, not the directory that contains it. (In essence, the JAR file acts as a directory that contains compiled .class files.) For example, the following command adds three things to the classpath: the directory /Users/elharo/classes, the file icu4j.jar in the current working directory, and the file junit.jar in /Users/elharo/lib:
$ javac -d bin -sourcepath src
-classpath /Users/elharo/classes:icu4j.jar:/Users/elharo/lib/junit.jar
src/com/elharo/gui/MainFrame.java

JAR files are only used for .class files and the classpath, not for .java files and the sourcepath.
Running the program
You have now successfully compiled your program, and are ready to run it. This is similar to but simpler than compiling. When running a program, you only need to specify two things:
  • The classpath.
  • The fully package qualified name of the class that contains your main() method.
You do not need to specify the sourcepath.
Usually the classpath is the same classpath you used to compile the program, with the addition of the directory where the compiled output was placed. For example, if the compile command was this:
$ javac -d bin -sourcepath src
-classpath /Users/elharo/classes:/Users/elharo/lib/junit.jar
src/com/elharo/gui/MainFrame.java

and the main() method was in the class com.elharo.gui.MainFrame, then you would run the program like this:
$ java
-classpath bin:/Users/elharo/classes:/Users/elharo/lib/junit.jar
com.elharo.gui.MainFrame

Take careful note that the last item on the command line is a class name. It is not a file name. It does not end in .java or .class. This class must be found somewhere on the classpath.
Other places classes reside
I strongly recommend that you always explicitly specify the classpath when you compile and when you run. There are other places you can put files so that they are added to the classpath and found by both the javac compiler and the java interpreter. These options save only a little amount of typing, and they do so at the expense of a large amount of debugging when -- not if -- you accidentally place an old version of a class in the classpath.
In this section, I'll show you some of the places you might expect to find classes hiding, that unexpectedly pop into your classpath and cause problems. This is especially likely to happen on machines you don't control, such as a server.
The current working directory
The compiler uses the current working directory (.) as the default classpath. However, as soon as you set the classpath in some other way--e.g. with -classpath or the CLASSPATH environment variable--this is no longer automatic. You have to add the current working directory to the classpath just like any other directory. In either case, it's too easy to forget what is or isn't in the same directory as you are. Thus, try to avoid putting any classes or hierarchies into your project or home directory. Instead, always keep things neatly separated into src directories for .java files and bin directories for .class files.
CLASSPATH
After a while, you may get tired of manually adding the bin directories and JAR archives to the classpath. You may then discover the CLASSPATH environment variable. You can add directories and JAR archives just once to the CLASSPATH environment variable. Then you don't have to type their paths every time you run javac or java.
Resist this temptation. It will cause problems when you load the wrong class or the wrong version of a class. Any time you save typing now will be taken back from you a hundred times over in debugging problems caused by accidentally loading the wrong classes. There are better ways to automate classpaths and avoid typing.
jre/lib/ext
JAR archives placed in your jre/lib/ext directory are added to the classpath of all applications run with that virtual machine. While this seems convenient, it is also a long-term mistake akin to adding directories to the CLASSPATH environment variable. Sooner or later (probably sooner), you'll load the wrong version of a class from a place you aren't even thinking about and waste hours debugging.
This problem is especially serious when deploying server-side applications. Be very careful that the server you're deploying to doesn't have any extra JARs in its jre/lib/ext directory. Problems caused by the wrong version of a JAR archive in the classpath can be extremely hard to debug if you don't recognize the symptoms or know just what to look for. To avoid these problems, some frameworks have even gone so far as to write their own class loaders that bypass Java code's usual class loading mechanisms.
jre/lib/endorsed
JAR files in the jre/lib/endorsed directory are also added to the classpath of all applications run with that virtual machine. The difference is that these files are actually added to the bootclasspath rather than the usual classpath and can replace the standard classes shipped with the JDK. This approach is especially useful for upgrading the XML parser and fixing bugs in the VM.
Once again, though, while this technique seems convenient, it is also a long-term mistake for the same reason. If you need to replace JDK classes, use the -Xbootclasspath/p option at runtime to avoid accidentally loading the wrong version of a class:
$ java -classpath /Users/elharo/classes
-Xbootclasspath/p:xercesImpl.jar com.elharo.gui.MainFrame

Automating classpath management
You should learn to use a hammer before you pick up a nail gun. Likewise, you should become comfortable managing classes manually before you try to use more powerful tools. However, there are tools designed to alleviate the pain of dealing with the sourcepath and classpath. Mostly they do this by organizing files for you along the lines I've laid out in this article.
IDEs
Most integrated development environments such as Eclipse and NetBeans automate and assist with some aspects of classpath management. For instance, when you change a package name, Eclipse offers to move the corresponding .java file to match, as shown in Figure 5:

Figure 5. Quick fix for the classpath in Eclipse


Keep in mind, however, that these IDEs still sit on top of a filesystem that must be set up properly, especially if you need to integrate with other tools and other IDEs. The main contribution of these tools is that GUI dialogs, tree views, and tabs replace command-line switches; but the basic file structure is the same.
Ant
Ant is the de facto standard tool for automating the build process. Unlike putting directories in jre/lib/ext or the CLASSPATHenvironment variable, Ant really does let you create one-step build processes. You still need to set up the classpath in your Ant build.xml file and manually put the source files in the right directories, but at least you don't need to keep respecifying it every time you compile.
Maven
Maven goes even further than Ant in organizing and automating the build process and associated classpath issues. Maven provides a reasonable default setup that enables you to build simple projects with just a few lines of code, as long as you put the source files where Maven expects to find them. You still have to coordinate the filesystem hierarchy and the package hierarchy. Maven is especially good at managing dependencies on third-party libraries, though it's not as easily customizable as Ant.
In conclusion
As troublesome as the classpath is, you can tame it with a few simple rules. In particular:
  • Place every class in a package.
  • Rigorously follow package and class naming and capitalization conventions.
  • Make sure your package hierarchy matches the directory hierarchy.
  • Always use the -d option to javac.
  • Never put anything in jre/lib/ext.
  • Never put anything in jre/lib/endorsed.
  • Never put .java files in the same directory as .class files.
  • Never put any .java or .class files in the current working directory.
One final tip: A lot of time-killing problems with the classpath revolve around simple errors like misspelling a directory name or compiling from the wrong directory. If you just can't figure out what's going wrong, ask a friend or colleague to look at your problem. Often I find I'm too close to the problem to see a bug in my setup that's immediately obvious to anyone else. A second pair of eyes is a very effective debugging technique.
The classpath is certainly not easy, but there is a method to its madness and it is manageable. A bit of care and some attention paid to naming conventions, command-line arguments, and directory structures should enable you to compile and run programs with a minimum of fuss.

Resources
Learn

Disabling annoying popup notification on Gnome Ubuntu

So I'm on Ubuntu and I use Pidgin and Tweetdeck. Everytime someone sends a chat message to me, or someone I follow tweets, a black notification message pops up on upper right corner of my screen, showing what who they are and what they say. And because I follow almost 500 people on Twitter, this notification pops up very frequently and becomes annoying distraction. I needed to rid them.

This is what I did, which worked for me:
sudo apt-get -y remove notification-daemon
sudo apt-get -y remove notify-osd pidgin-libnotify

Source: http://www.uluga.ubuntuforums.org/showthread.php?t=1360080

Turning rpm package into deb package.

So recently I had to install Libre Office on my Ubuntu machine but it came only in rpm package. The "dpkg -i *.deb" only works for deb packages, not rpm. So I needed a way to convert these rpm packages into deb. The utility to do that is called "alien".

Run the following to install alien and the necessary packages:
sudo apt-get install alien dpkg-dev debhelper build-essential

To convert a package from rpm to debian format, use this command syntax. The sudo may not be necessary, but we’ll include it just in case.
sudo alien packagename.rpm

To install the package, you’ll use the dpkg utility, which is the internal package management tool behind debian and Ubuntu.
sudo dpkg -i packagename.deb

Auto complete, Code Assist does not work in Eclipse

I checked out project from SVN into Eclipse. I tried to work on it, but when I hit Ctrl+Space, the expected Code Assist did not show up. What went wrong?
It turned out that Eclipse did not recognize the newly checked out project as Java Project. I right clicked and chose Properties, and I could not find the option to set the Java build path and lib.
To solve it, I had to delete the project from workspace. Only from workspace, not from disk. Then I reopened the project with: New project with existing source. And I tweaked the lib and build path. And there, Code Assist showed up again :)

Enabling SSL on Ubuntu and the problem thereafter.

Recently I had to test our product on secured site, so I tried to install SSL on localhost. The config file for SSL site has been installed in /etc/apache2/sites-available. So I simply had to enable it and modify it. I first issued this to enable the SSL module:

sudo a2enmod ssl

And then I enabled the SSL config by:

sudo a2ensite default-ssl

After the above command is issued, a symlink to /etc/apache2/sites-available/default-ssl will be created and called /etc/apache2/sites-enabled/default-ssl. I edited it and uncommented the following lines:

SSLEngine on

SSLCertificateFile /home/ISA.REALOBJECTS/firman/Documents/ssl/linuxdev8.nc.crt
SSLCertificateKeyFile /home/ISA.REALOBJECTS/firman/Documents/ssl/linuxdev8.nc.key

The certificate (.crt file) and the key (.key file)  are snakeoil, so to say, I created them using OpenSSL. The commands I used to create them are the following:

openssl genrsa -des3 -out linuxdev8.nc.key 1024
openssl req -new -key linuxdev8.nc.key -x509 -out linuxdev8.nc.crt

After that, I restarted Apache, at which point I was asked to input the key phrase:

sudo /etc/init.d/apache2 restart

And lo and behold, I can now connect to http://127.0.0.1 and https://127.0.0.1

The problem happens after Ubuntu is restarted. Apache refuses to start, and throws up the following error message instead:

Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs!

I googled for 3 days and tried all of the solutions I found, but my problem persisted. I have no clue what went wrong! I'm not a wizard when it comes to Apache directives but I guess there's something wrong somewhere in the config file. What I found to be a pseudo-solution was this:

Before restarting Ubuntu, disable the SSL site first by issuing this:

sudo a2dissite default-ssl

And then proceed to restarting Ubuntu. After computer is restarted, re-enable the SSL site and restart Apache:

sudo a2ensite default-ssl
sudo /etc/init.d/apache2 restart

That's it :)

BTW in case you wanna know my config files, the following are my /etc/apache2/ports.conf, /etc/apache2/sites-available/default, and /etc/apache2/sites-available/default-ssl, in that order:


NameVirtualHost *:80
Listen 80


    # SSL name based virtual hosts are not yet supported, therefore no
    # NameVirtualHost statement here
    Listen 443




ServerAdmin webmaster@localhost

DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
  






ServerAdmin webmaster@localhost

DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/ssl_access.log combined

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128


#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on

#   A self-signed (snakeoil) certificate can be created by installing
#   the ssl-cert package. See
#   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
#   If both key and certificate are stored in the same file, only the
#   SSLCertificateFile directive is needed.
SSLCertificateFile    /home/ISA.REALOBJECTS/firman/Documents/ssl/linuxdev8.isa.nc.crt
SSLCertificateKeyFile /home/ISA.REALOBJECTS/firman/Documents/ssl/linuxdev8.isa.nc.key

#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt

#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
#   Note: Inside SSLCACertificatePath you need hash symlinks
#         to point to the certificate files. Use the provided
#         Makefile to update the hash symlinks after changes.
#SSLCACertificatePath /etc/ssl/certs/
#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

#   Certificate Revocation Lists (CRL):
#   Set the CA revocation path where to find CA CRLs for client
#   authentication or alternatively one huge file containing all
#   of them (file must be PEM encoded)
#   Note: Inside SSLCARevocationPath you need hash symlinks
#         to point to the certificate files. Use the provided
#         Makefile to update the hash symlinks after changes.
#SSLCARevocationPath /etc/apache2/ssl.crl/
#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

#   Client Authentication (Type):
#   Client certificate verification type and depth.  Types are
#   none, optional, require and optional_no_ca.  Depth is a
#   number which specifies how deeply to verify the certificate
#   issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth  10

#   Access Control:
#   With SSLRequire you can do per-directory access control based
#   on arbitrary complex boolean expressions containing server
#   variable checks and other lookup directives.  The syntax is a
#   mixture between C and Perl.  See the mod_ssl documentation
#   for more details.
#
#SSLRequire (    %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
#            and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
#            and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
#            and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
#            and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20       ) \
#           or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#

#   SSL Engine Options:
#   Set various options for the SSL engine.
#   o FakeBasicAuth:
#     Translate the client X.509 into a Basic Authorisation.  This means that
#     the standard Auth/DBMAuth methods can be used for access control.  The
#     user name is the `one line' version of the client's X.509 certificate.
#     Note that no password is obtained from the user. Every entry in the user
#     file needs this password: `xxj31ZMTZzkVA'.
#   o ExportCertData:
#     This exports two additional environment variables: SSL_CLIENT_CERT and
#     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
#     server (always existing) and the client (only existing when client
#     authentication is used). This can be used to import the certificates
#     into CGI scripts.
#   o StdEnvVars:
#     This exports the standard SSL/TLS related `SSL_*' environment variables.
#     Per default this exportation is switched off for performance reasons,
#     because the extraction step is an expensive operation and is usually
#     useless for serving static content. So one usually enables the
#     exportation for CGI and SSI requests only.
#   o StrictRequire:
#     This denies access when "SSLRequireSSL" or "SSLRequire" applied even
#     under a "Satisfy any" situation, i.e. when it applies access is denied
#     and no other module can change it.
#   o OptRenegotiate:
#     This enables optimized SSL connection renegotiation handling when SSL
#     directives are used in per-directory context.
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire

SSLOptions +StdEnvVars


SSLOptions +StdEnvVars


#   SSL Protocol Adjustments:
#   The safe and default but still SSL/TLS standard compliant shutdown
#   approach is that mod_ssl sends the close notify alert but doesn't wait for
#   the close notify alert from client. When you need a different shutdown
#   approach you can use one of the following variables:
#   o ssl-unclean-shutdown:
#     This forces an unclean shutdown when the connection is closed, i.e. no
#     SSL close notify alert is send or allowed to received.  This violates
#     the SSL/TLS standard but is needed for some brain-dead browsers. Use
#     this when you receive I/O errors because of the standard approach where
#     mod_ssl sends the close notify alert.
#   o ssl-accurate-shutdown:
#     This forces an accurate shutdown when the connection is closed, i.e. a
#     SSL close notify alert is send and mod_ssl waits for the close notify
#     alert of the client. This is 100% SSL/TLS standard compliant, but in
#     practice often causes hanging connections with brain-dead browsers. Use
#     this only for browsers where you know that their SSL implementation
#     works correctly.
#   Notice: Most problems of broken clients are also related to the HTTP
#   keep-alive facility, so you usually additionally want to disable
#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
#   "force-response-1.0" for this.
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0

Ubuntu stucks at "Starting Winbind daemon"

My Ubuntu hanged. I restarted it. But it got stuck at  "Starting Winbind daemon" point. I restarted it again. It stuck there again. I randomly pressed keys, and what got it moving was the classics Ctrl+Alt+Del. It did not restart Ubuntu. On the contrary, it helped Ubuntu pass the "Starting Winbind daemon" point and proceed normally into the login prompt. By the way, I'm using the Jaunty Jackalope.