GRoK This!
What Not To Do
Well, it's been a few weeks since I've blogged, and I'm still working on my My Book Library project. And, during that time, I committed a basic error. When making changes, especially big ones, minimize the number of changes so that if something goes wrong, you have less variables to sort through to determine the root cause. Well, I had most of the basic functionality done except for getting the list of distinct Categories from a user's library. The SQL statement wasn't working. So first I decided that it was maybe my version of MySQL that was the problem. I was running a beta version of 4.0.x. So, I decided to upgrade to 5.0. Well, short story is that didn't go well, but I did manage to get it upgraded to 4.1.x. This was on my development box only, and not the production box, so I just considered it practice.
At the same time, I decided to change the code from hand-rolled JDBC DAOs to Hibernate. Maybe that would solve the problem. Well, it got complicated, so I decided to try the Spring/Hibernate combo, which was supposed to be easier. This was my mistake. Now I had two major variables: the change in MySQL and the Spring/Hibernate change, and how was I going to get it working again?
I've muddled through most of the Spring/Hibernate stuff. There were some catches though. On the POJOs, for many-to-many associations, only one of the associations is supposed to be "inverse=true". The association would not persist, otherwise. Also, the many-to-many is supposed to be set to "cascade=none". I had a heck of a time setting up the session factory and the transaction manager. It turns out that the transaction manager for JBoss has a special JNDI name, and in the applicationContext.xml file, it should look like this:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="transactionManagerName" value="java:/TransactionManager"/> <property name="userTransactionName" value="UserTransaction"/> </bean>
Through all of this, though, XDoclet has been my indispensible friend.
I've gotten to the point where I can persist a single instance, and fetch out an instance, but adding an association still doesn't work. I'm pretty sure it's in the way I'm doing the transaction manager. I'll admit that transactions aren't my speciality. I've always let Struts or the app server handle them and have never dealt with them directly before. If I stop using transactions (via TransactionProxyFactoryBean) and just directly run the DAOs, it works. However, using TransactionProxyFactoryBean causes trouble. I set it up for JTA transations, but now am trying HibernateTransactionManager to see if that helps. Setting the transaction properties doesn't seem to help either:
<prop key="get*">PROPAGATION_REQUIRED,readOnly
Oh, well, I'll keep muddling through, using the ArcMind tutorial and anything I can crib off of the web.
Posted at 07:36PM Sep 19, 2006 by Gary Kephart in Computers | Comments[0]
My Book Library
The last few weeks I've been playing around with ISBNdb.com's site and creating a web app around it. ISBNdb is a site that contains information about millions of publications, and it has an API so that it can be accessed programmatically. The problem I've been trying to solve is having my list of books with me when I go to the bookstore. I want to avoid buying duplicates. I have a list of books at amazon.com, but have you ever tried to access that site on a PDA? So, I decided to create my own web app that stores my library, is easy on a PDA, and is vendor-independent (not tied to a book-seller). So, come on over and give My Book Library a try. It's very much in beta mode, but comments are welcome.
Posted at 10:05PM Aug 01, 2006 by Gary Kephart in Computers | Comments[0]
Firefox Backers Create 'Destroy IE' Campaign
Yahoo! News - A group of self-titled "political activists" in Massachusetts has started an aggressive campaign to get browser users to switch from Microsoft's Internet Explorer to Mozilla's Firefox.
Taking advantage of a new program by Google, the campaign, called Explorer Destroyer, pays users $1 for each referral to Firefox made through Google Toolbar, according to the group's Web site.
Posted at 07:59PM Apr 25, 2006 by Gary Kephart in Computers | Comments[0]
Next up: When firewalls and web servers attack!
ZoneAlarm has been a blessing and a curse. I've used it for a long time. I started out with the free version, but somewhere along the line, bought the Pro version. At around version 5.x or so, it started having problems with the Apache web server. The server would serve up pages for a while, and then simple stop doing so. There was a lot of discussion of it on the ZoneLabs user forums. It was supposedly fixed eventually, but I had decided to downgrade and keep the version that works. Every time I forgot about the problem and upgraded, I ran into the problem again and swore never to upgrade again. Well, I recently forgot about my promise to myself and upgraded ZoneAlarm, and of course I ran into the same problem. This time, I decided that I'd had enough. I posted my problem on the ZoneAlarm user forums, waited a day, and then switched over to Norton Personal Firewall. Goodbye, ZoneAlarm, it's been fun, but when I have web visitors emailing me that they can't get into Encyclopaedia WoT, I need to do something.
Posted at 10:37AM Apr 06, 2006 by Gary Kephart in Computers | Comments[0]
Live Thumbnails
As part of being a software engineer, I go out and read as much as possible about what's out there and available for me to use. Sometimes, I come across some really cool but simple things. Such is the case with Live Thumbnails: Watch 'em Grow. I've liberally stolen their JavaScript and added it to my Photo Album. Right now, I only have updated the Skate Park pictures, but go ahead and check those out.
Posted at 06:51AM Mar 02, 2006 by Gary Kephart in Computers | Comments[0]
Security and Class.getResourceAsStream
Just to let all of you Java developers know, when you pass in an empty string into Class.getResourceAsStream, you get a directory listing. Well, at least you do with WebLogic. And it's a directory listing of where WebLogic start up. This could be very bad if instead you were looking for some file on the classpath and were sending the contents of said file somewhere outside of your system. In this case, the directory listing would be sent.
Posted at 07:07PM Feb 26, 2006 by Gary Kephart in Computers | Comments[0]
Re: Domain objects are dumb
In an earlier post, I stated how domain objects are now dumb, and today I finally ran into Martin Fowler's AnemicDomainModel anti-pattern, which basically says the same thing.
Posted at 10:56AM Dec 19, 2005 by Gary Kephart in Computers | Comments[0]
The Negative Nature of Software Development
I had a small epiphany yesterday. If the databases always worked, if the user always entered exactly what he/she was supposed to, if everything else worked just the way it's supposed to, then our job as software developers would be pretty easy. Instead, we deal with a whole lot of negative issues. What if the user doesn't enter a numeric value here? What if the database goes offline? What if the database is corrupted? What if we don't have all of or the right set of requirements? What if we decide to change from WebLogic to JBoss or MySQL to Oracle? What if, what if, what if? We add code to our product to protect it, which makes the code more complex. We also use third-party code that already has that complexity built in, which makes it harder to use. That's why we get paid the big bucks. Our experience and our ability to pass that experience on to beginner programmers so that they can do better programming faster.
Posted at 11:50AM Nov 24, 2005 by Gary Kephart in Computers | Comments[0]
Domain objects are dumb
I was at the OCJUG meeting last week when one of the comments there got me thinking. At the very beginning of programming, we have functional programming, where behavior was paramount. We then went to the other end to data-driven programming, and then we finally blended the two in object-oriented programming, where an object had both data and behavior. A "loan" object, for example, would know how to persist itself. It would also contain all of its own business logic. Now, however, with a layered architecture (and I don't think that this is specific to Java), domain objects have become dumb. They no longer have behavior, just data. Now we have persistence layer that has only behavior and knows how to persist all sorts of domain objects that are passed to it. We have a presentation layer that only knows how to present the domain objects that it is given. And of course we have a service/business layer which contains all of the business logic.
Why does this seem not object-oriented?
Posted at 03:03PM Nov 17, 2005 by Gary Kephart in Computers | Comments[0]
TransformerException: stylesheet requires attribute: version
I've been working on a Wiki that uses XML for its data and uses XSL to format it. No JSPs. This XMLWiki is for my Encyclopaedia WoT (EWoT). I haven't found a Wiki out there that did exactly this, so I made it. I eventually ran into the problem that is the subject of this entry. I searched the web for the answer, and found hints of it being that I had to "setNamespaceAware(true)". But where? Here's some code snippets that show the answer:
public class DefaultPageService
{
public String getPageContent(String pageName, boolean replaceLinks) throws PageServiceException
{
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setURIResolver(new PageUriResolver());
Source stylesheet = transformerFactory.getAssociatedStylesheet(source, null, null, null); // error thrown here
Transformer transformer = transformerFactory.newTransformer(stylesheet);
transformer.transform(source, result);
// etc
}
}
public class PageURIResolver implements URIResolver
{
public Source resolve(String href, String base) throws TransformerException
{
File file = ...
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true); // THE MISSING LINE!!!
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document stylesheet = this.builder.parse(file);
return new DOMSource(stylesheet);
}
}
...and all was right with the world - for now.
Posted at 06:32PM Aug 29, 2005 by Gary Kephart in Computers | Comments[2]
Details, details, details
So I've been working the last few weeks in order to get Dr Dee up and running again this year. I got it to work on my development machine, capital, but when I try to get it to run on my production machine, I kept getting security errors. So, I checked that my username and password were correct in the database. I checked that I had the proper role and therefore authorization. I checked that the XML database descriptor for the MySQL database was correct. I checked that the JNLP web start file was correct. All looked good and still I had the error. I finally remembered that I'm running the Swing client app on RMI over HTTP on JBoss. I remembered that I had to fool with the JBOSS_HOME\server\default\deploy\http-invoker.sar\META-INF\jboss-service.xml file to get it to work. So, I finally decided to take a look at that file today. Lo and behold, there was my problem. I was using http://www.photeus.com:8080 when I should have been using http://photeus.com:8080. That little change, the "www." was causing the problem. And why was this? It was because during this last year I modified my account on dyndns.org. www.photeus.com now points exclusively to my web server, so specifying a port beyond that just messes things up. I can either use photeus.com:8080 or I can use jboss.photeus.com. I'll stick with the former. Now that that problem is solved, I can focus on the next one.
Posted at 09:29PM Mar 21, 2005 by Gary Kephart in Computers | Comments[0]
Another problem with ZoneAlarm
In the beginning, I picked ZoneAlarm because it was free and it was also recommended by Steve Gibson when I visited his "Shields Up!" page. I happily used it for some time without any hassles. I've even upgraded to the Pro version, which I had to buy.
Then things started to change. I'm not sure when. Maybe it was version 5. As I've reported here, I'm having problems with ZoneAlarm and BeyondTV. Yesterday, I found out that there's problems with it and Apache HTTP server as well. Apache will work just fine for a few minutes and then it will stop responding to HTTP requests. I had to downgrade until I found a version that would work. That involved going from version 5.5.062.011, to 5.1.011, to 5.0.590.043, and finally to 4.5.594.000. So, now Encyclopaedia WoT is available again.
And I think I'll start the search for another firewall product.
Posted at 07:06AM Mar 13, 2005 by Gary Kephart in Computers | Comments[0]
XDoclet and EJBs
Note to self: when using XDoclet to generate your ejb-jar.xml and jboss.xml, and you have some abstract superclasses that your beans extend, don't put ejb.env-entry, ejb.resource-ref, or jboss.resource-ref tags in your superclass unless you want them to also show up in your bean's XML. You could end up with double of those tags and when you go to deploy, you'll get an error saying that the bean is already deployed.
Posted at 05:24AM Feb 23, 2005 by Gary Kephart in Computers | Comments[0]
My Computer Was Suffocating
or, How I Spent My Presidents' Day Holiday
I was planning to have a nice quiet day at home, doing some computer stuff. I knew I had to buy some RAM for one of my computers, and I decided I'd buy a new KVM switch as well, since the hot keys of the old one weren't working. Since I was at it, I might as well buy another USB hub. I knew that I needed to get more RAM because my development computer (Capital, as opposed to the public one called Photeus) kept page swapping - a lot. It was getting so that I couldn't get much work done without waiting for the computer to catch up. In essence, it was suffocating. It didn't have enough RAM, and so had to use the hard disk, which is much slower than RAM. I hadn't checked to see how much RAM was currently in the computer (I had forgotten), but I do have a clear side panel and saw that there was only one RAM module and I had room for two more. I assumed that the one was a 1GB module, and that I could go buy two more 1GB modules and bring it up to 3GB, because compusa.com showed that they carried 1GB modules. However, when I finally checked my computer, I found out I had only 512MB! For a software developer, that's not a lot, considering that I've got servers running and an IDE as well. No wonder it was page swapping. When I arrived at CompUSA, though, I was told that they only carried the 512MB modules in stock. The 1GB were only available on the web. Well, I wanted my RAM now, so I settled for two of those. That would give me a total of 1.5GB of RAM, which is good enough. I also bought Belkin's 2 port OmniView SOHO Series KVM Switch with Audio, PS/2, USB and VGA KVM switch. A bit much, but what the heck. Turns out that it cost quite a bit more than I expected ($100), but since I was already at the checkout, I bit the bullet and bought it. I also bought a Cat6 network cable to replace a shorter one that I was using. I was used to using Cat5 cables. I didn't even know that Cat6 were made, but it looks like they're now the standard. I had stopped at OfficeMax to return an ink cartridge, and I bought a 4 port USB hub there - a real one, not like the tiny unpowered one that I was using.
So, I brought all of that home and started to install. Wouldn't you know, something went wrong. Something was interfering with my mouse and caused it to freeze after a few minutes of work. I found out that it was the new KVM switch when I replaced it with the old one and the mouse worked fine. It probably didn't work because the new KVM switch had USB capabilities, and my mouse was a USB mouse plugged into a USB-to-serial converter, which was plugged into the KVM switch. I'm guessing that the USB stuff got confused somehow. Oh, and when I put the old KVM switch back in, I found out that somehoe the hot keys were working again. So, I went back to CompUSA and returned the new KVM switch, getting my $100 back. Now, everything went fine. The memory upgrade went without a hitch, and I thought that would have given me more trouble than anything else.
Posted at 02:50PM Feb 21, 2005 by Gary Kephart in Computers | Comments[0]