- Internet Alchemy Talis, Web 2.0 and All That
“…Web 2.0 is an attitude not a technology. It’s about enabling and encouraging participation through open applications and services.”
(categories: web2.0) - O’Reilly Radar > Not 2.0?
“…the key to success in this next stage of the web’s evolution is leveraging collective intelligence.”
(categories: oreilly web2.0)
All posts by ajohnson
eBay Java / C# SOAP Examples
At the start of this year I worked with some guys at eBay to further develop their code samples. Some, but not all of the twelve examples I wrote went live in the recently launched Community Codebase. You can download all the Java examples (of which I wrote three) or browse the Subversion repository. I wrote the SOAPAddItem, SOAPGetItem, and SOAPGetUser items in the Java source tree.
The examples I wrote were different from the majority of the (then) existing examples in that I didn’t make any IDE assumptions (most of the Java examples have JBuilder .jpx files and Eclipse .project files, the .NET projects contain the Visual Studio artifacts.. tsk tsk.) and as such, all the examples I wrote contain comprehensive Ant / NAnt build files which means you can get up and running without having to setup your fancy schmancy IDE. But the biggest difference was that all the examples I wrote used either Ant (with WSDL2Java) or NAnt (with NAntContrib) tasks to conditionally download the eBay WSDL, generate the client stub(s), and compile the resulting code, which makes for a prettier source code repository (generated stubs aren’t checked into source) and gives you compile time checking of your code against the API.
If you’re interested in how you can use Ant or NAnt in a build environment where you access SOAP services, you should check it out!
Java Class.forName(String className) and JDBC
A reader asked a question via a comment a couple months ago that I didn’t really have an answer for (and had always kind of wondered the same thing). In the original post (which showed how to use JDBC with ColdFusion), I used the following snippet of code:
Class.forName("jdbc.DriverXYZ");
Connection con = DriverManager.getConnection(url,
"myLogin", "myPassword");
and the reader wanted to know what the Class.forName(..) method did. The most common answer you’ll hear is that it loads the database driver, which, while technically true, is shallow. Where does it get loaded? How does it happen? And why?
To answer the question I started with the JavaDoc for the Class.forName() method. According to the documentation, the method:
… attempts to locate, load, and link the class or interface
I wasn’t perfectly clear on what “locate, load, and link” meant, so I did a little digging through the Java Language Specification. According to chapter 12 of the JLS:
Loading refers to the process of finding the binary form of a class or interface type with a particular name, perhaps by computing it on the fly, but more typically by retrieving a binary representation previously computed from source code by a compiler, and constructing, from that binary form, a Class object to represent the class or interface.
Next, again according to the JLS, it must be transformed from it’s binary representation to something the Java virtual machine can use, this process is called linking. Finally, the class is initialized, which is the process that executes the static initializer and the initializers for static fields declared in the class.
So then back to the original problem, when Class.forName() is called with an argument like this:
Class.forName("org.gjt.mm.mysql.Driver");
the classloader attempts to load and link the Driver class in the “org.gjt.mm.mysql” package and if successful, the static initializer is run. The MySQL Driver (download the source code) static initializer looks like this:
static {
try {
java.sql.DriverManager.registerDriver(new Driver());
} catch (SQLException E) {
throw new RuntimeException("Can't register driver!");
}
}
So it calls a static method in the java.sql.DriverManager class which apparently registers a copy of itself when it loads.
So now I understand the where and the how, what about why? To understand the why you have to look at the next line in the initial code example:
Connection con = DriverManager.getConnection(url,
"myLogin", "myPassword");
The DriverManager class (view DriverManager source here) returns a database connection given a JDBC URL string, a username and a password. In order to create that connection, the DriverManager class has to know which database driver you want to use. It does that by iterating over the array (internally a Vector) of drivers that have registered with it (ie: the registerDriver(Driver driver) method illustrated above) and calls the acceptsURL(url)) method on each driver in the array, effectively asking the driver to tell it whether or not it can handle the JDBC URL.
So there you have it. Class.forName explained.
Links: 7-29-2005
- DHTML Spell Checker
Pretty nice looking, it doesn’t like apostrophes though.
(categories: ajax dhtml javascript spelling ) - Django | The Web framework for perfectionists with deadlines
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
(categories: framework python web ) - Java Reference Guide: Troubleshooting Java Memory Issues
a 30,000 view of object cycling and lingering references
(categories: collection garbage java memory ) - Java Reference Guide: Java Performance Tuning
Big-Oh.
(categories: java tuning ) - Wired 13.08: We Are the Web
“Three thousand years from now, when keen minds review the past, I believe that our ancient time, here at the cusp of the third millennium, will be seen as another such era. In the years roughly coincidental with the Netscape IPO, humans began animating i
(categories: The_Machine )
Adaptive Path interview with Jared Spool: how to ask questions
Great story from an interview that Adapative Path’s Peter Merholz did with the founder of User Interface Engineering Jared Spool:
PM: Any other mistakes, in terms of how tests are structured?
JS: There are many problems I see in terms of people not
understanding the effects of testing affecting results.
Here’s a simple example that we discovered. We were working with a
client, testing a website that sold furniture. And the client had
already done some testing. They had created some simple tasks, and
one of the tasks was basically asking users to come to the site and buy
a bookcase they might want to buy.Every user in that study went to the search box, and typed in the word “bookcase,” immediately. So they were off trying to improve the hits on the word “bookcase,” and get the results better. We did a subsequent test, and instead of asking people to look for a bookcase, we gave them a slightly different task.
We said imagine you have 300 different paperback and hardcover books in
cardboard boxes, all strewn through your living room. You need a way to
organize this stuff such that you can find the stuff you like, and
people who come over can be impressed with your collection. What do you
do? People would go to the site, and then click on links. They’d click
on furniture links; they’d type into the search engine storage systems,
and then type in shelves. Not a single user in our phase of the study
typed in the word bookcase. So by changing the description of the task,
we got a completely different result.
Links: 7-27-2005
- ACME Updates – JavaScript web server
A HTTP server written using JavaScript. More information here: http://www.acme.com/software/js_httpd/
(categories: http javascript )
del.icio.us poster
Last month I wrote about a quick utility which uses the delicious-java and Apache XML-RPC libraries to grab posts from my del.icio.us account and post them to my Metaweblog enabled (in my case Movable Type) blog. I’m not sure that it’s useful unless you have your own server or always on desktop PC, but I wasn’t satisfied with the original product, so I updated it with better documentation, a license (GPL), an Ant build file and the ability to edit the format of the posts using a Velocity template. Oh, and it’s all in Subversion now. You can read all about it by checking out the del.icio.us poster project page.
Links: 7-19-2005
- TrimPath – Trac
Open source JavaScript stuff including a spreadsheet and a client side JavaScript query engine with SQL-like syntax. You have to see it to believe it.
(categories: ajax javascript query spreadsheet sql )
Links: 7-11-2005
- Visa USA | Small Business & Merchants | Cardholder Information Security Program
Visa’s security program for merchants and service providers. If the company you work for stores credit card numbers, you should be doing all the stuff they mention already, but given recent events it’s probably time to check up on your security.
(categories: cisp security visa ) - Google Earth KML Documentation
Full documentation for KML format.
(categories: earth google keyhole kml ) - Google Code: Google Earth KML Tutorial
KML is the XML format used by Google Earth (formerly Keyhole) that allows you to import places into Google Earth.
(categories: earth google keyhole kml ) - Home | MasterCard Site Data Protection Program
Same thing as the Visa CISP (below)
(categories: mastercard pci sdp security )
ASP.NET: The resource cannot be found.
Spent some time today buried in IIS trying to figure out why an ASP.NET application would throw the following error message for every single page that existed in an application within a website:
Server Error in ‘/myapp’ Application.
—————————————————-
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested Url: /myapp/default.aspx
—————————————————-
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Googled for “resource cannot be found” and found this link on the third result page. In it Jarrett mentions that he solved the problem by reading this experts-exchange.com question which suggests setting up the application as a Virtual Directory in IIS instead of simply marking the folder in the website as an application, which of course solved the problem for me as well. Since a picture is worth a thousand words, here’s the difference between a Virtual Directory (which is an application in and of itself) and directory in IIS that has been marked as an application:


My suspicion is that the problem has to do with ASP.NET configuration inheritance settings with Virtual Directories not inheriting from parent directories like a folder marked as an application would, but there isn’t much to go on. Any Microsoft IIS experts out there want to talk about the difference between a Virtual Directory and a folder that has been marked as an application from a configuration standpoint?