Monday, March 27, 2006

Please vote for this java bug

Please vote for this java bug:

This is related to the hotswap feature of java vm. This is very essential because hotswap allows the programmer to make changes in the code and see the results immediately without restarting the application servers or anything else. Rapid feedback enables rapid development.

To add your comments on this feature please use this sun forum:


Sunday, March 26, 2006

Spring 2.0: New Features

New Spring 2.0 features are great. That will surely make a new leap towards simplification of quality software development. Download the presentation given by Rod Johnson -founder of Spring- to learn about new features of Spring 2.0: Spring Update: Introducing Spring 2.0


Calling Ruby Scripts From Java Through Spring

The new Spring 2.0 carries a very interesting feature: binding scripts through dependency injection. It enables to load scripted objects into the Spring application context and call them as if they were java objects. I wonder whether the reverse is possible too? Look at the Spring-Loaded blog for more information.


Saturday, March 25, 2006

maven2-jetty6 plugin problem

I was trying to develop a new web application based on equinox-1.6. New versions of equinox are built with maven2. This is good because maven makes build management very easy. I ran equinox with jetty6 plugin. Brett Porter explains in his blog entry why jetty6-plugin is such a life saver for web application developers. But somehow I received the following error:

:INFO: NO JSP Support for /login, did not find org.apache.jasper.servlet.JspServlet

I am not sure what caused this error. Probably there is a classpath error. I tried to run some other applications with jetty6-plugin. They were ok. Even another equinox-1.6 based application was running properly. Then I changed the version of jetty6-plugin to the previous version (6.0.0beta12) and fortunately the problem was solved. I am not sure but probably there is a classpath related error with dependencies of jetty6, jasper-compiler etc..


Friday, March 24, 2006

Using Standalone Ant Tasks in Java Code

Ant is a very good build management and automation tool. Moreover Ant tasks are very easy to use in java code as well. I mean, you don't have to write build.xml files in order to benefit from Ant tasks. You can as well use Ant tasks from java code directly.

Here is an example of code:

Project project = new Project();
project.setName("DbUnit Test");
SQLExec sqlExec = new SQLExec();
File createTable = new File("db/create-table.sql");
sqlExec.addText("" +
" INSERT INTO app_user (id, first_name, last_name) \n" +
" values (5, 'Julie', 'Raible');\n" +
" INSERT INTO app_user (id, first_name, last_name) \n" +
" values (6, 'Abbie', 'Raible');\n");

This is the same as the following build.xml excerpt:

<sql driver=\"${jdbc.driverClassName}\" url=\"${jdbc.url}\"
userid=\"${jdbc.username}\" password=\"${jdbc.password}\">
<classpath refid=\"compile.classpath\"/>
INSERT INTO app_user (id, first_name, last_name)
values (5, \'Julie\', \'Raible\');
INSERT INTO app_user (id, first_name, last_name)
values (6, \'Abbie\', \'Raible\');

Although xml code is shorter, java code has some adequate use cases. For example, you want to reuse SQLExec's functions in your own application. You can reuse any of the Ant tasks which is a large library full with utilities.

But beware that all Ant tasks depend on a wrapping Project object. Therefore the first line in the above java code instantiates a dummy Project object.


Monday, March 20, 2006

IntelliJ IDEA Blog Opened

IntelliJ IDEA Blog The official group blog of IntelliJ Idea. My favorite IDE and software...


Sunday, March 19, 2006

Maven2 - Simplification of Build Management

Maven2 has made a great improvement in simplification of build management. It is only one step to generate a skeleton application with Maven2. This is as easy as Ruby-on-Rails code generators. Maven2 does not only provide lots of code generators. It helps also greatly in testing, deploying, dependency management and all other project management issues.

An example. You have a project generated by maven2. Then you want to create a project file for IntelliJ Idea. Normally you would open Idea and adjust the settings on classpath, source path etc. With maven2, you only give a command: mvn idea:idea. Maven2 handles all the settings for you.


Jetty and Appfuse

Appfuse-1.9 works on Jetty-6.0-beta without any configuration. Just dropping appfuse.war into webapps folder of jetty works without any warning/errors. Well normally this shouldn't surprise any java developer, but after struggling with so many small but not-easy-to-understand migration problems this was surprising to me.


Very Simple Jetty Configuration

I like Jetty as a web server. It is pretty small, fast and easy to configure. Here is my very simple web application configuration on jetty 4.2.2 (you can try it on any java ide):

1. Put the following files into the classpath: jasper-compiler.jar, jasper-runtime.jar, javax.servlet.jar, org.apache.jasper.jar, org.mortbay.jetty.jar (these files are included in jetty 4.2.x distributions)

2. Create a web page welcome.html and put it into {project.dir}/resources folder.

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
<html xmlns=\"\" xml:lang=\"tr\">
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />
<script type=\"text/javascript\">

3. Compile and run the following java class (the working folder should be {project.dir}):

public class Start {
private static Logger log = Logger.getLogger("start");
public static void main(String[] args) {
Server jettyServer = null;
jettyServer = new Server();
SocketListener socketListener = new SocketListener();
jettyServer.addWebApplication("/test", "resources");
catch (Exception e) {"Could not start the Jetty server: " + e);
if (jettyServer != null) {
try { jettyServer.stop();
} catch (InterruptedException e1) {"Unable to stop the jetty server: " + e1); }

4. Go to http://localhost:8080/test/welcome.html

Here you can download the code as an IntelliJ Idea project, excluding the jetty-4.2.x distribution.


Welcome - Selam

Hi everybody, this is my 7th weblog. I know that this makes everything a little more confused. But this is better than big up front design. You can't make everything as organized from the start. This weblog is specifically dedicated to the small things in software development. I don't want to clutter my other weblogs with these small issues. I will write in this blog more freqeuntly, I hope. And this weblog will be mixed in Turkish and English.

Here comes the Turkish introduction:

Merhaba, bu benim 7. weblogum. İngilizce kısmını okuyanlar için bu Türkçe giriş tekrar mahiyetinde olacak. Diğer webloglarımı kalabalıklaştırmamak için, özellikle yazılım geliştirmede karşılaştığım küçük meselelere burada değineceğim.