Maven, the better quickstart

I read a lot of Maven documentation and at the end the most interesting question “How do I run an application with its dependencies?” wasn’t answered. Instead I was flooded with many xml configuration sections without showing a simple and complete configuration file. That’s why I wrote this howto but first a little story.

I came across Ivy and Maven a couple of days ago, both of which make it very easy to add a list of libraries to your Java project and add them to the classpath.

Basically both look for a project configuration file including your dependency list and they download the libraries from the internet and install them in the local repository ~/.ivy2 for Ivy and ~/.m2/repository for Maven which are then shared with your Ivy/Maven projects.

While Ivy is only a dependency manager which is integrated with the most popular build management system for Java projects (Ant), Maven is more than just such a manager. With Maven you have a build system and a dependency manager in one tool.

I focused on Maven and it took me a while to find out that a feature I was looking for wasn’t there natively. I assumed it would have a similar behaviour than Ivy but it hasn’t and works completely different.

I was missing a clear Maven howto which shows in 5 minutes how your project is created, compiled, packaged and especially how your standard java application is run afterwards.

I assume that Maven is already installed and that you are familiar with using a shell as I won’t use m2eclipse, the Maven integration for Eclipse. Maybe I’ll update this post later and give you a little introduction but for now let’s concentrate on using it in a shell.

I don’t guarantee that everything is 100% correct because I don’t use Maven that long. Post a comment if something is wrong.

Continue reading »

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Eclipse, Axis2 and Tomcat

If you are looking for a howto for that toolchain you’re wrong here. If you are here because you’ve got the same/similar problem than me, go on.

While I was following step 6 in this tutorial I got the following error.

Result: Failed while installing Axis2 Web Services Core 1.1

This forum wasn’t useful for me so I updated my Axis2 to the latest release 1.5.3 and checked the axis2 and tomcat preferences. The web service runtime was unfortunately set to Apache Axis so I changed it to Apache Axis2.

I did step 6 of the tutorial again while I deselected Javascript in the Project Facets dialog this time and it happily worked. Then I created another project with Javascript selected but I got the same error from above again. From that point on the error alway appeared regardless the Javascript selection. No chance to get rid of that error message.

Does somebody experience the same? Any workaround?

Update 1:

I downgraded to Eclipse Java EE IDE for Web Developers (Build id: 20100218-1602, Galileo) but this time eclipse hanged up while I was creating the Dynamic Web Project. The process “waiting user operation” stuck. I updated the packages (Help > Check for Updates) and only an xml problem appeared which seems to not be a big problem as I was now able to create a project without any error messages.

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

There is no handler to execute for command

If you follow the Vogella tutorials, especially those about menu contribution, the error message There is no handler to execute for command might appear. They don’t mention that you have to take care about the return value of isHandled().

While I was experiencing the error message after the first time I hit the menu yesterday, I’m absolutely not able today to get the command run once. In fact the behaviour shouldn’t change over night but anyway keep an eye on isHandled.

My plugin output this today1:

11:21:23 zprototype.AbstractApplication::start   Starting the plugin
11:42:47 zprototype.command.LoadModel::addHandlerListener
11:42:47 zprototype.command.LoadModel::isEnabled
11:42:48 zprototype.command.LoadModel::isHandled
11:42:48 zprototype.command.LoadModel::isEnabled
11:42:48 zprototype.command.LoadModel::isEnabled
11:42:48 zprototype.command.LoadModel::execute
11:42:49 zprototype.command.LoadModel::isEnabled

AbstractApplication is actually the entry point of the plugin and LoadModel is the menu handler.

As you can see isHandled is executed before execute so if it returns false a NotHandledException will be thrown.

  1. I’m not sure if this output is alway the same as other developer did run the command once too before the message appeared.
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

org.eclipse.emf.ecore.xmi.IllegalValueException

I hate exceptions. Yes, I really hate exceptions.

I’ve defined a EDataType EPoint that uses the java class org.eclipse.draw2d.geometry.Point.

Ecore model

In the code I set the start and end point of the ElementView by the corresponding setter that I pass instances of the class Point ( and not EPoint! ).

ElementView view = factory.createElementView();
view.setStartPoint(new Point(20, 20));
view.setEndPoint(new Point(100, 100));

Saving the model produces the following file content:


...
<diagrams name="NewDiagram">
    <diagramView diagram="//@diagrams.0">
      <elementViews startPoint="Point(20, 20)" endPoint="Point(100, 100)"/>
    </diagramView>
  </diagrams>
...

The instances are serialized by the method toString() of the class Point which outputs Point(xx, yy) but these values lead the loading process fail while this message appears:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'Point(20, 20)' is not legal. (file:/.../test1/model.pe, 7, 76)
18:28:12 zprototype.model.impl.ModelManagerImpl::load   Model could not be loaded (org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'Point(20, 20)' is not legal. (file:/.../test1/model.pe, 7, 76))
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
	at zprototype.model.impl.ModelManagerImpl.load(ModelManagerImpl.java:63)

I tried to replace the Point class by another one but it’s the same problem with that. Now my question is why the value is not legal? Does the deserializer not know how to create the objects from the string?

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare