Categories
Computing Java SQL Server

DB2 Impressions

When I got my laptop at my new job it did not have a DBMS installed. Sad, but could be worse. Since the only free version of SQL Server is the MSDE, and the Oracle ‘personal’ edition is almost a gigabyte-sized download, I decided to check out the personal edition of DB2 – a mere 330MB.

The installation went pretty smooth but the first time I ran it I encountered a nagging missing DLL error thrown by the javaw. Weird because DB2 ships, runs and breaths its own JDK – IBM’s version 1.4.1. The error message recommended reinstalling the product, I did and things fared better – with the error going away. I did try to tell the installer to skip the IBM JDK installation but it ignored me. I do not care much because the system works.

DB2 is certainly a more mature product than SQL Server. It asks you for all sorts of information that has to do with tweaking its performance, from memory management limits to a variety of settings that have to do with automated optimization of the data stored on the server. What did bother me is that the wizards that are available in the DB2 Control Center application (parallel to Enterprise Manager in the SQL Server universe) – that are supposed to help you create databases, tables, etc. – do not seem to work too well.

The installation wizard ends with a ‘getting started’ window that encourages you to ‘create a database’. I tried that path and encountered a multitude of options that somehow – while using the defaults – failed to produce the promised database. What is also both neat and overwhelming is the fact that almost every operation that you try to make produces a result window that tells you if the operation succeeded. That’s all nice and well until you are returned an error. Each error reported is followed by a list of all the error codes that the error reports and it gets tedious when you look for the correct error.

I managed to create my database from a command line interface and then was able to use the wizard in the Control Center to create a table. Many things are really cool in DB2 – for example, you can ask a table what stored procedures or user defined functions use the table – an important feature when you are considering altering the table or modifying the stored procedure or UDF. Also neat it is the table creation wizard’s clean key definition – which in my opinion is superior to that of SQL Server.

Another thing I encountered was that as uncool a DBMS SQL Server is with Java, at least it produces readable error messages (most of the time…). DB2 provided me with this message when I violated a unique constraint on a column when I tried to insert a row:
SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 2;YZUKERMA.SUBMISSION
An A9 search on DB2 error codes lead me to the DB2 documentation page which is impressive in the amounts of information it provides. But all I want is a clear understanding what I did wrong, eh?

More impressions sooner than later…

Share
Categories
Java Web Development

Anti-Windows JBoss bug

The assignment my students have to complete has functionality that involves outputing an XML Document into a file. So nice of the DOM folks to NOT have that functionality in the Document object, but good enough, we have the Transformer object which can do just that.

Using the Transformer object’s transform() method that allows you to send the result of a transformation into an output stream – a file.

The students were asked to save the XML to a file in the home folder of the person grading the assignment – a property accessible by using the Java method:
System.getProperty("user.home")
In Windows, the property is mapped to:
[DRIVE]:\Documents and Settings\[USER NAME]
“Documents and Settings” have spaces between the words ‘Documents’, ‘and’ and ‘Settings’. That, is, an, issue, if, you, are, using JBoss on Windows – why?

Let’s go back to the Transformer: we are supposed to be able to use this code…

File file = new File([PATH WITH SPACES]);
Result result = new StreamResult(file);
transformer.transform([source xml], result);

On JBoss something this innocuous will produce a FileNotFoundException, saying it cannot find the file at [DRIVE]:\Documents%20and%20Settings\[USER NAME] – the file location is escaped as if the file location was a URL. This is a problem and appaerently there is/was an open bug on the JBoss JIRA server. JBoss 4.0.1sp1 still does not have it resolved and the issue is apparently rooted in the FileURLConnection that handles files in JBoss. Sorta uncool, eh?

Solution:
Instead of going the file route directly, how about we use a stream instread:

PrintWriter outStream = new PrintWriter(new FileOutputStream([FILE_LOCATION]));
StreamResult fileResult = new StreamResult(outStream);
transformer.transform(source, fileResult);

Hope this helps!

Share
Categories
Java Web Development

JBoss Ghosts

I am a teaching fellow for a J2EE class at the Harvard Extension this semester and we are using the JBoss Application Server v. 4.0.1. Today, while examining homework assignment submissions one of my peers sends me an EAR file asking me to try and deploy it. All EAR files for the assignment are expected to have the same name.

JBoss is supposed to allow you – assuming the EAR file is correctly packaged – to simply copy the EAR file into its $JBOSS_HOME/server/default/deploy and have it install the application automatically. An application with the same name as an application already there is supposed to overwrite the application that was already there.

Sure of that, I go ahead and overwrite the existing application EAR file. JBoss’ console shows that the application deployed OK and was started. I hence try to access the application in its URL and lo and behold – I get the JSP welcome page of the application I just deleted! OK… I follow the procedure that was developed with pain and tears and stop JBoss, delete the application EAR file from the aforementioned deploy folder; then proceed to delete anything with the same name as the EAR file from the $JBOSS_HOME/server/default/tmp/deploy.

I started JBoss again, accessed the application URL and got, as I expected, a 404 error. Deployed the application again and whoa – the OLD application’s ghost was still present – I got the old application’s welcome JSP page. This is WEIRD.

An e-mail flurry ensues, we research feverishly, until co-TF Martin comes up with the answer (documentation shmocumentation…): There is also a $JBOSS_HOME/server/default/work/jboss.web/[SERVER_NAME]/ folder which contains a folder for each of the deployed applications. It appears that the accessed JSPs are converted into classes there. A quick deletion of that folder solves the problem completely and the new application finally rears its pretty head. THANKS MARTIN!

Share
Share