Entries from November 2006 ↓

NIS Works!

I spent a few more minutes on Google tonight looking for reasons why NIS might not work on my home network. I’m still not sure why it didn’t work but I did get it working. On my Fedora 5 client I changed /etc/nsswitch.conf to contain the lines:

passwd: compat
shadow: compat
group: compat

Those lines previously contained:

passwd: files nis
shadow: files nis
group: files nis

I don’t think making this change was the fix, but I can go back and change it to “files nis” again to see if it breaks. I think the real fix was executing yppasswd [username] as root on the NIS client machine. After changing the password I was able to su to that user from another user account and log in from gdm.

I’m glad that battle is over. Now I just have to remember to change the NIS password of user accounts in the future. The next task is to set up an NFS home directory for NIS clients.

Quick Ant/JUnit status

I’m trying to get Ant to run my JUnit tests now but I keep getting

Testsuite: net.anthonychaves.test.geoip.locator.LocatorHelpersTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

Caused an ERROR
net.anthonychaves.test.geoip.locator.LocatorHelpersTest
java.lang.ClassNotFoundException: net.anthonychaves.test.geoip.locator.LocatorHelpersTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)

I’m not sure how that can happen because the JUnit section of build.xml file looks like this:

[junit printsummary=”yes” fork=”yes” dir=”${basedir}/build/classes/”]
[classpath]
[pathelement path=”/home/anthony/jboss-4.0.4.GA/client/jboss-j2ee.jar”/]
[pathelement path=”/home/anthony/eclipse/plugins/org.junit_3.8.1/junit.jar”/]
[pathelement path=”/m2/ark/code/mysql-connector-java-3.1.12/mysql-connector-java-3.1.12-bin.jar”/]
[fileset dir=”${basedir}/build/classes/”]
[include name=”**/*Test.class”/]
[/fileset]
[/classpath]
[formatter type=”plain”/]
[batchtest todir=”/home/anthony/junit/reports” ]
[fileset dir=”${basedir}/test/”]
[include name=”**/*Test.java”/]
[/fileset]
[/batchtest]
[/junit]

I’m not sure why it can’t find the class at this point and I don’t have enough time to debug it tonight. It’s finding the class name well enough to try to run the test, but it’s not finding the class to do it. I guess I’ll have something to think about on my train ride tomorrow. Any suggestions would be helpful!

IP Address Locator Update

I made two quick changes to IP Address Locator tonight.  The first fix was to the LookupService class I talked about a few nights ago to introduce an upper bounds check on the IP number before performing the lookup.  This check in the code eliminates the need to check against the end_ip_number in the database because of the structure of that data.  Because the start_ip_number of one block of IP addresses will never be below the end_ip_number of the preceeding block the query can only look at the start_ip_number and perform significantly better.   When checking that the IP number is between the start_ip_number and end_ip_number the query typically takes between 0.85 and 1.10 seconds.  When it’s only checking against the start_ip_number it takes less than 0.01 seconds.  I’d call that an amazing improvement and it only took imposing one upper bounds check to make sure the value to look up didn’t cross the end of the data.  This query is now taking tremendous advantage of the structure of the data in the table.

The second change I made tonight was a change in the way country name lookups were performed.  I thought the country name cache was a good candidate to be implemented as a Singleton.  I chose the implementation that relies on the JVM to execute static initializers when a class is initialized.  Doing it this way produces an up-front performance hit but once the class is initialized that hit will never happen again.  I did this to eliminate the need for synchronization on the method producing a (tiny) performance hit each time the instance is needed.  I am aware that Java 5 correctly allows for a double checked locking implementation but I chose to pass on that way for now even though I am a big fan of Brian Goetz’s talks on threading and the volatile keyword in Java 5.

That’s all for now.  Please download the IP Address Locator project and check it out.  Feel free to post any questions or comments you have.

Eclipse Wish List

A few days ago I wrote about importing an EJB client project into Eclipse from Subversion. Unfortunately it’s not as easy as I thought. My goal was to import both the EJB project and the EJB client jar project and create an ear file from the two. While it’s possible to to check out both projects from Subversion getting them to work together in my workspace is not straight forward. With the client project checked out it is not possible to create an EJB client jar project via the Eclipse interface because a project with that name already exists. If I specify a different name during client jar creation then it’s a different client project associated with the EJB project than the one in Subversion. Since it’s not the one in Subversion then it’s not worth creating an EJB client jar from the Eclipse interface. On the other hand if I check out the EJB client project from Subversion then it’s not associated with the EJB project as a client jar. I’m not sure how else to proceed with attaining the desired outcome here. If anyone has any suggestions please let me know.  I have updated my wiki page on this as well.

Weekend Update - Ant, Locator, NIS

This weekend I updated the javadoc comments in the IP address locator project. I also started a build.xml file to automate building the project outside of an Eclipse IDE. This is the first time I have used Ant’s manifest nested element of a jar element to create the manifest file inline. Since I only needed two lines in my manifest file creating it inline works great. At this point I would only change back to an external manifest file when I need it explicitly versioned in Subversion and/or when it becomes too large to manage in a build.xml file. The next tasks for my build.xml file are to put a JUnit tag in to run the unit tests and to run the javadoc tag before the jar file is created. In order to run JUnit from within Ant I have to create a classpath element that has the junit.jar file in it. Please download the IPAddressLocatorEAR.ear file and review my work. I’m always interested in questions and comments.

I wasted an incredible amount of time this weekend trying to get my Fedora Core 5 VMWare image to use NIS for account logins to no avail. The output of ypcat passwd.byname shows my database of users but when I su - to a different user I get “incorrect password” as the resposne. As root I can su - to a user listed in the NIS passwd file but not as my user account. I found a post staying that it might be because my user account was not part of the wheel group, but even after adding it the NIS login still doesn’t work. At this point I don’t care, especially since I can’t get those 4 hours of my life back. I’m glad I do most of my “experimental work” in VMWare images that have backups. I rm’d my /etc/passwd file ensuring that no users existed in the instance hoping it would be forced to go to the NIS server. What really happened was that I couldn’t sudo or log in as root to put the file back. The quick fix was blowing away that writable instance and replacing it with a backup taken last week. The funny thing is that hosts are picked up from the NIS server without a problem. Does anyone have some advice on how to get NIS remote logins to work?