DoTaL

My repository for development tidbits, and a few personal anecdotes

Archive for April, 2008

Why Open Source Rocks!!

Posted by doubleA on April 23, 2008

This week I have had one of those experiences that makes you love open source even more. Yes, open source is commonplace for Java developers but sometimes we forget how awesome open source can be.

This is not a post about some new whiz bang utility, a new version of an Ajax toolkit, or anything spectactular. It’s about the little things in deveoper life that allow you to be productive.

The story:
This week I have been working on some web services integration with Informatica. Informatica has a published set of WSDL files for running workflows and getting status information. I started with a new project and began with the login service. Obviously, a user has to login to the system before they can run workflows. When running the services I continually received an IndexOutOfBounds error. After digging into the CXF documentation and mailing lists, I found a variety of options, but none of them worked. At this point I was about 6-8 hours into the testing and was getting frustrated.

I then decided to post on the users mailing list which is the start of the “Rocks” part of this post.

Within 20 minutes I got a response from one of the lead developers on the toolkit. We had a couple of email exchanges over the next hour and the end result is that he identified a bug. He was going to work on the bug the next day and give me an update.

The next day, I got an email just after lunch stating that the fix is implemented and deployed in the latest Maven Snapshot.

I simply opened up my Maven pom.xml file and changed my versions to the new snapshot version. After downloading the new version, PRESTO, my code ran without errors and I was able to login to Informatica through the web services.

From the time of me posting on the mailing list to the deployed bug fix was less than 24 hours. Try that with Microsoft, IBM, Oracle, or anyone else with a proprietary product. They would take 24 hours to get to level 3 support and you would almost never email directly with the lead developers.

Posted in Java Development | Leave a Comment »

Creating a new Maven archetype

Posted by doubleA on April 7, 2008

The latest version of the Maven archetype plugin allows you to create an archetype from an existing project. The alpha-3 version is required if you are creating an archetype from a multi module project. This is very important and it requires you to configure some additional repositories in order to download the alpha-3 version.

Below are the steps and issues I ran into:

Configuration
1. Edit settings.xml to add new repositories. Since archetype is a plugin and a core maven feature, you have to setup a repository and plugin repository.

Repository Configuration – add this under the repositories tag:

  1. <repository>

  2. 	<id>snapshots</id>

  3. 	<url>http://people.apache.org/repo/m2-snapshot-repository/</url>

  4. 	<!-- The releases element here is due to an issue in Maven 2.0 that will be

  5. 	fixed in future releases. This should be able to be disabled altogether. -->

  6. 	<releases>

  7. 		<updatePolicy>always</updatePolicy>

  8. 	</releases>

  9. 	<snapshots>

  10. 		<updatePolicy>always</updatePolicy>

  11. 	</snapshots>

  12. </repository>

Plugin repository Configuration – add this under the pluginRepositories tag:

  1. <pluginRepository>

  2. 	<id>snapshots</id>

  3. 	<url>http://people.apache.org/repo/m2-snapshot-repository/</url>

  4. 	<!-- The releases element here is due to an issue in Maven 2.0 that will be

  5. 	fixed in future releases. This should be able to be disabled altogether. -->

  6. 	<releases>

  7. 		<updatePolicy>always</updatePolicy>

  8. 	</releases>

  9. 	<snapshots>

  10. 		<updatePolicy>always</updatePolicy>

  11. 	</snapshots>

  12. </pluginRepository>   

See http://maven.apache.org/guides/development/guide-testing-development-plugins.html for more details on setting up snapshot repos

2. Open a command prompt and go to the root project folder of the parent project that will be used to build the archetype. Run “mvn -U archetype:create-from-project”
3. The alpha-3 version will download
4. Switch to the target/generated-sources/archetype directory
5. Run “mvn install” to put the archetype in the local repo
6. Comment out the plugin repo so that updates are not always downloaded
7. From another directory, run “mvn archetype:generate -DarchetypeCatalog=local”

Issues
I did run into several issues when creating an archetype from one of my projects. There were no major issues, but one of them does need some further research.

1. If you have ant tasks defined in your pom.xml, the archetype will create successfully, but no new projects can be created from it. The error mentions that you can’t have certain characters in the CDATA of the pom. For me, I had to completely remove the ant tasks from my project. But, I’ve been thinking of doing this anyway because I use the ant tasks to control my runtime environment settings. A better approach for this would be to use profiles, so now I kind of have to look at profiles to work around this issue.

2. I also found an issue with ### symbols in log statements and println statements. The workaround was to replace any ### chars with — and then everything worked.

3. The project that is created from the archetype has submodules named “__rootArtifactId__-web” and “__rootArtifactId__-core” instead of “MyNewApp-core” and “MyNewApp-web”. It’s only the folder name that has the wrong name. The poms all references MyNewApp-web as the module name. A folder rename solves this issue.

Posted in Maven, Uncategorized | 2 Comments »