Words of Java RSS Feed
Words of Java

Words of Java

High and low about Java and Web programming

 
 
 
 

Struts2 + Eclipse + Maven

This was was not a good combination earlier but now with the Sonatype Eclipse add-on m2eclipse it is easy to start or import a maven project into Eclipse. Either import as is or use one of many archetypes for Struts2 or other well known frameworks.

The tools also gives you nice tools for dependency hierarchy and graph in the GUI. For a non-techncal develper as me this is quite nice. But even if this is nice it could always be misused and bad in developing performance among others.

Continuous Integration by Martin Fowler

It’s all about communication, reducing risk, removing blank spots, increasing quaility, find and eliminate bugs faster and feel safe to make changes to your code base.

This article by Martin Fowler is quite old but still holds even though you would like to see some alternatives to CruiseControl / Cruise and Ant.

http://martinfowler.com/articles/continuousIntegration.html

Good reading for everybody that works with software today.

Are you really sure your are going to use framework X?

Before you rush into next project using web framework X you should consult the comparison page found at Wikipedia. I’m quite impressed I must say. Good work guys!

http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks

Quickstart - HelloWorld with Java, Maven2 och Jetty

This tutorial shows a simple way to get started with a Java web application at Jetty server with maven2 as build tool. Ok, so it’s for Windows but it should not be hard to port the non platform independent commands to other platforms.

1) Install Java

Download a Java Jdk version from http://java.sun.com/javase/downloads/, for example Java SE Development Kit (JDK) 6 Update 11
Install in your preferred location, for example “C:\Java\jdk1.6.0_11\”.

2) Install Maven2

Download apache-maven-2.0.9 (http://maven.apache.org/download.html) and unzip to c:\tools\apache-maven-2.0.9
Create the directories C:\tools\.m2 and c:\tools\.m2\repository

Create the environment variable M2_HOME=C:\tools\apache-maven-2.0.9
Add %M2_HOME%\bin to the environment variable PATH
Create the environment variable M2_REPO=c:\tools\.m2\repository
Create the environment variable JAVA_HOME=C:\Program\Java\jdk1.6.0_11
Add %JAVA_HOME%\bin to the environment variable PATH

Verify maven installation

>mvn -version

Should display something like:

Maven version: 2.0.9
Java version: 1.6.0_11
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"

Verify Java version:

>java -version
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)

3) Create workspace location

cd to your workspace location (or other of your choice where you wish to add the project) and open a command prompt, for example C:\ws

> cd C:

> mkdir ws

> cd C:\ws

4) Create the maven project

>mvn archetype:create -DgroupId=se.javanews.helloworld -DartifactId=helloworld -DarchetypeArtifactId=maven-archetype-webapp

5) Edit pom.xml

Go to helloworld and open pom.xml and add the <plugins> element in the <build> element
<build>

<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
</plugins>
</build>
6) Create deploy shortcut

Create the file deploy.bat with content
@echo off
%M2_HOME%\bin\mvn jetty:run

7) Install application

run

> mvn install

9) Deploy application at Jetty

run
> mvn jetty:run
or
execute deploy.bat (doubleclick)

10) Try it out

Open http://localhost:8080/helloworld/ in a browser at your choice and test the page

Good luck!

Please inform me of any problems or mistakes in this tutorial!

JBoss in no time at all

Nice little tutorial on how to get started with a HelloWorld with Java / JBoss

http://www.centerkey.com/jboss/

I wonder how this would look like for the combination maven2, java, jetty. Maybe I’ll try to figure this out and come back with a post later.

OutOfMemory error for maven reporting plugin

I tried adding a few extra maven reporting plugins (findbugs, clover, javancss and some more) but ran into problem when running

>mvn site

or even

> mvn -DMAVEN_OPTS=”-Xmx1024m -Xms512m” site

Stacktrace:

[INFO] Generating “Plugin Management” report.
[INFO] Generating “Mailing Lists” report.
[INFO] Generating “Continuous Integration” report.
[INFO] Generating “Project License” report.
[INFO] Generating “Project Team” report.
[INFO] Generating “Source Repository” report.
[INFO] Generating “About” report.
[INFO] Generating “Issue Tracking” report.
[INFO] Generating “Project Summary” report.
[INFO] Generating “Project Plugins” report.
[INFO] Generating “Dependencies” report.
[INFO] ————————————————————————
[ERROR] FATAL ERROR
[INFO] ————————————————————————
[INFO] Java heap space
[INFO] ————————————————————————
[INFO] Trace
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.
java:100)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:515
)

….

Any ideas?

Oh my god

… installing plugins for Hudson is soooo simple and fast. Period.

Java, Hudson and Subversion (updated)

Took a look at this today and spent pretty much all day in this area. Ofcourse, when you install new software you often have to install other software for all kinds of dependencies or other needs. So, outside the core of what I meant to fix I also got my hands dirty with :

cygwin,

notepad++,

service wrappers,

and more…

Well, at last I got the setup alright and run CI via a pull from Hudson against the subversion repository. I tried to add the subversion post-commit hook to run :

wget -b http://localhost:8090/job/Struts2-kickstart/build > /dev/null

but somehow this did not work at all. Not even when running the command in the prompt. Will have to get back to this one.

Problem solved :

a) cygwin version had problems and my wget did not work at all and I installed it again with better result.

b) I tried to mix bash and cygwin and windows to much. Instead I just have one .bat file (post-commit.bat) with the following content

“C:\cygwin\bin\wget.exe -b http://localhost:8090/job/Struts2-kickstart/build”

Now it all works out fine!

Even though I had some problems with setting up subversion server and getting this running as a service and all - and some problems not getting the post-commit hook to work - I think I’m going to like the Hudson Subversion combination.

Now I have to add some plugins and set all the rules for breaking builds, emailing and other cool stuff that this engine should manage.

By the way : just finished reading “Maven, the definitive guide” from Sonatype and I found it excellent. Good writing and good reading!

Devoxx08

Took a look at some of the slides from Devoxx08 and found a few very interresting things (http://www.devoxx.com/display/JV08/Conference+slides). Among others, “Zero Turnaround in Java Development - by Jevgeni Kabanov” that you really should act on.

I’m joining a new project this week and I’ll try to add some pressure in this area if I get the chance (and you always get the chance…) if it is not good enough . My Y2009 should be about better quality and result, and not using the best methods / processes that is will break this right away… so I’ll try to help myself (and others) to see this.

Struts 2 and Servlet 3.0

At first glance it looks quite promising but I won’t say to much before I have done more testing for myself.  I like the more slim way of doing stuff so I would like to get the time to dig deeper into this.

Another promising new release will be Servlet 3.0 (in JEE6) with the mission “easy of development” including annotations instead of XML, more POJO-based and overall much less overhead. In combination with Struts 2.0 or other equivalent frameworks this could be nice.