Tuesday, February 3, 2015

Learning Ant

I understand that there are probably many problems with the way I have my project set up. One of these is that, there are multiple project that are dependent of each other (This is not by itself a problem), but rather than referencing the actual project, I have to export it to a jar, and put it in my tomcat lib folder (this is the part that I believe is probably not ideal). This ofter involves me realizing I forgot to run eclipse as an adminstrator, and having to restart the program. After this happening one to many times I decided to try find a way to automate my build process, and copy the files for me. And so I found Ant.

I had seen Ant as an option in eclipse, but I never new anything about it. When I was searching for a solution to my problem though, it looked as though Ant is what I needed so I decided to try to learn what it can do. I was able to use a tutorial I found here, To get a pretty basic understanding of how to use a basic ant script to build a library. That was all I needed to do for my base projects, that doesn't depend on any of my other projects, but for the ones that depended on it, I had to do a little extra searching to figure out how to copy a file (the *.jar), to my lib folder. The answer was just a copy tag, with a fileset child, i.e.
   <copy todir="${lib.dir}">
      <fileset dir="${util.dir}">
   </fileset>
    </copy>

After writting one of these for each of my projects, I began looking into how to get the all to run at once. It looked like it was just a matter of referencing the other Ant files I wanted to run, and giving them dependencies on each other so they run in the correct order. But then I realized that they are run in the directory of the first file, so the relative paths were incorrect. I spent a little time looking for how to do an equivilent of cd, but most sites said I shouldn't need to. So I believe this is another instance were the structure of my project is causing some problems. I also at that point saw some people recomending using Maven instead of Ant. I think I will make do with multiple ant files for now, but if I ever decided that that is to much of a hassle as well, I fill start looking into trying to learn the basics of Maven as well.

I think my next step will be to add Google Authentication to my application, so that I can give users different levels of access to various features.

Friday, January 9, 2015

Finally done with the setup

I was finishing getting my rasp pi, and by using the walkthrough here: http://www.git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server, I was able to get the server set up how I needed. I did run into a little difficulty, because I am using a Windows, rather than linux as my client. Since I don't currently understand Git as well as tfs or svn, I decided to learn a little more, before looking into getting a third party GUI, so to start I had to learn Git GUI which was included with the Git install. after running the program, I used it to create a New Repository in the folders that I wanted to add, commit the files, and then push the local repository to the bare one that I had set up on the raspberry pi. I chose accidentally chose to have Git use open ssh rather than putty, which is what I normally use, and I was unable to import the existing rsa key from putty to the Git GUI, so I had to generate a new one.

After getting that set up, I decided to look into integration with Eclipse, as that is the IDE I use when developing in Java. I found Egit pretty quickly, and was able to get it set up with very minimal problems. At that point I was able to get back to writting my code. The first thing I started doing was writing methods to act as linq equivilents. I'll talk about that more next time.

Tuesday, December 16, 2014

Taking two steps back

Since my last post, I have lost progress unfortunatly, although not much. 

I was going to setup my git repository, and I wanted to set ownership of the relevant files to a new user. But the flashdrive that I was planning on using was mounted in fat32, which doesn't support owners. so I reformated the drive, and had to change the ID in my fstab. When I tried to reboot, to check that the changes worked, It put me into emergency mode, asking for root credentials, which I had forgot. So I realized I had to reinstall the OS. Luckily, this is really simple with NOOBS on the raspberry pi. This time while installing, I decided I wouldn't need the graphical interface, and tried to use the headless mode. After logging on the first time, I remembered that I had used the graphical interface to setup wireless, but thought I was up for the challenge of configuring it without. 

After much searching on google, finding results for different distros, and different versions of distros, I was eventually able to find a set of commands that at least made me feel like I was making progress. I started by running iwconfig, which told me that wlan0 was my wireless adapter, I then ran 
sudo iwlist wlan0 scanning | grep ESSID to find all availible ESSID's. I already knew mine, but I figuredthis was something that may be important to know later on. At this point, the guide I was using explaned how to connect with WEP, but I use WPA, so I had to look for a couple different options. Everything I found required installing wpa_supplement, but I was pretty convinced that there had to be a way to do it without needing another library, but I couldn't find anything else, so I went ahead and tried to install it, only to realize that it was already there.

After I had decided to use wpa_supplement, I ran sudo  bash -c 'wpa_passphrase SSID password > /etc/wpa_supplicant/SSID.config' to store the configuration in a file to be used by wpa_supplicant, then sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/SSID.config, which ran fine. The guide said that all that was left to do was to get an ip through dhcp, so I ran dhclient wlan0, and that succedded, so I figured I should be good to go. After trying to ping my main laptop, I realized that was not the case.

So I started going through the troubleshooting steps again, and realized that when I ran iwconfig, wlan0 still had a status of DOWN, which i figured was a problem. When trying to figure out how to remedy this, all the sources I found said I needed to run ifconfig wlan0 up. Unfortunately, ifconfig didn't exist. A couple people mentioned that I may just need the full path to it (i.e. /sbin/ifconfig) however, it didn't exist there either. eventually I realized that what I needed was ifup wlan0, which gave me the error configuration for wlan0 not found. I recalled while I was looking around some that I had seen some files in /etc/sysconfig/network-scripts/ that had one for lo and eth0, but not wlan0. So I copied ifcfg-eth0 to ifcfg-wlan0, and changed the first line from DEVICE=eth0 to DEVICE=wlan0, an ran ifup wlan0 again. This time the command seemed to run to completion, but iwconfig still reported that wlan0 was DOWN. At this point I decided it would be easier to boot to a graphical, and use the GUI. I looked in the inittab file (I remembered how to do that part from a class in college), which told me that the system uses targets instead of runlevels, so I needed to run
ln -sf /lib/systemd/system/<target name (for me it was graphical)>.target /etc/systemd/system/default.target. Then after running a shutdown -r now, I was able to log in and connect with just a couple mouse clicks, making me feel like I had wasted the past couple hours. 

Once the pi was online, I wanted to verify that I could still connect via ssh. First I tried to ping it, to verify my laptop could resolve the host name. For the most part its fine, but occassionally it appears to resolve to the ip that was given to the pi  before I reinstalled. Since I gave it the same hostname it had before, I'm assuming that my laptop has cached the ip, and that it will get better with a little time. Putty prompted me to verify the rsa key again, so I had to run ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub, but there weren't any other problems with connecting via ssh.

Still need to add my flashdrive to my fstab, and reinstall git, then set that all up, but I was frustrated enough with the wifi setup, that I think it will be a while before I get back to this.

Monday, December 1, 2014

Fixed it

I was able to get my project working again, while still using Lucene. I attempted to switch to MySQL, but after trying to install it on my Raspberry Pi, the Pi no longer turns on. I mentioned to a co-worker that I was having this issue, and they pointed out that a sql server needs a fair amount of resources, so I'm not sure if my Raspberry Pi will be able to handle it. I don't expect the database to be very large, but that might still be a problem. Anyway, I need to get that started up, so thats bonna be my next step.

Once I noticed that the pi wasn't able to start up, I was too lazy to move the pi, to somewhere I can use a monitor, mouse, and keyboard, so I went back to work on trying to fix my problem with lucene. I started by looking for Luke again, which would allow me to view the lucene index. When I first started working on this, but at the time I wasn't able to find it for the version of Luke I was using. I was able to find it this time however.

By using Luke I was able to determine that my problem was that the id on my objects was not the same as the id that is indexed. I generated the id by using a hash of the path to the file, but during the refactor, I changed the implementation of what I store for the path, which caused the hash to change. This was causing the id that was searched for to not exist, and return no results. I fixed this by using the id from the lucene document if thats how it was created.

So now my site is working properly, I will not be touching it again, until I get it in source control, but to do that I have to get my Raspberry Pi to a point where it can start up, so it can be my GIT server.

Tuesday, November 4, 2014

Cleaning up a refactor

I am currently in the process of working on developing a personal website using Java. Although I know asp.net fairly well, I decided not to use it, so I wouldn't be bound to hosting on a Windows server. As far as I know, asp.Net is limited to Windows, but if it turns out that is incorrect, at this point I've made enough progress, I'm not going to be going back.

I have been a little distracted by my other hobbies (mostly Video Games and Netflix) and hadn't made much progress in the last month or so. The last change I had made was a fairly large refactor to one of my librarys. I finished the refactor, and realized that it would have been nice to have the previous version in source control, in-case the change didn't work. So for now my current goals are to get the website working with the new library, and then get it in source control immediately.

I'm currently running into an issue with using the Lucene library for indexing. I'm starting to think my webite would be better served using a database. There are parts where full text indexing would be nice, but for now I think those lose out to the simplicity of using a traditional database. Because I did a farily good job of extracting the implamentation in the last refactor, it shouldn't be to big of a problem to switch. For now I will leave the Lucene implementation I have in there, even though it doesn't work. Maybe eventually I will figure out what my issue is and be able to get the best of both worlds!

Thats all for now. Since this is my first post I think I should mention that I have tried starting a blog before, but it didn't last to long. I'm planning on keeping this one going a little longer, but we will se how that goes.