Posts Tagged ‘eclipse’

Why Eclipse WTP doesn’t publish libraries when using m2e

April 29th, 2012 No comments

Lately, I noticed my libraries weren’t published to Tomcat when I used a Maven project in Eclipse, even though it was standard war packaging. Since I mostly use Vaadin, I didn’t care much, I published the single vaadin-x.y.z.jar to the deployed WEB-INF/lib manually and I was done with it.

Then, I realized it happened on two different instances of Eclipse and for the writing of Develop Vaadin apps with Scala, I used 3 different libraries, so I wanted to correct the problem. At first, I blamed it on the JRebel plugin I recently installed, then I began investigating the case further and I found out that I needed a special Maven connector that was present in neither of my Eclipse instances: the WTP connector. I had installed this kind of connector back when Maven Integration was done by m2eclipse by Sonatype, but had forgotten that a while ago. Now the integration is called m2e, but I have to do the whole nine yards again…

The diagnostics that can be hard but the solution is very simple.

Go to the Windows -> Preferences menu and from this point on go to Maven -> Discovery.

Click on Open Catalog.

Search for “wtp”, select Maven Integration for WTP and click on Finish. Restart and be pleased. Notice that most Maven plugins integration in Eclipse can be resolved the same way.

For a sum up on my thoughts about the current state of m2e, please see here.

Send to Kindle
Categories: JavaEE Tags: , ,

Migrating from m2eclipse to m2e

September 25th, 2011 5 comments

Since Indigo, the Maven Ecliple plugin formerly known as m2eclipse became part of Eclipse release (at least in the pure Java release). The name of the plugin also changed from m2eclipse to m2e. This was not the sole change, however:

  • The number of tabs on the POM has shrinked drastically, and the features as well. This will probably be the subject of a later post since I feel quite cheated by the upgrade.
  • The POM configuration has been more integrated with Eclipse build (which can cause unwanted side-effects as I described in my last article).

More importantly, projects that began with m2eclipse can be built in Indigo but no contextual Maven menu is accessible on the project itself (though a contextual menu is available on the POM).

In order to migrate flawlessly and have our contextual menu back, some actions are necessary. They are gruesome because it involves updating by hand Eclipse configuration file.

Warning: at this point, you have the choice to stop reading. If you decide to continue and use the process described below, it’s at your own risk!

The Maven plugin recognizes a project as a Maven one based the .project Eclipse proprietary configuration file. To display it, go to the Project Explorer view, click on the scrolling menu at the top right and choose Customize View. You have to uncheck *.resources: along the .project file , you should see a .classpath file as well as a .settings folder.

  1. In the .project:
    • Replace org.maven.ide.eclipse.maven2Builder by org.eclipse.m2e.core.maven2Builder in the buildSpec section
    • Replace org.maven.ide.eclipse.maven2Nature by org.eclipse.m2e.core.maven2Nature in the natures section
  2. In the .classpath, replace org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER by org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER
  3. Finally, in the .settings folder, rename the org.maven.ide.eclipse.prefs file to org.eclipse.m2e.core.prefs. Contents should be left unchanged.

Now, the contextual menu should appear and work accordingly.

Remember, this is a big hack you should only use with the right parachute (at least a source control management system) since it will hurt you plenty if it fails. For me, it has always worked… yet.

Send to Kindle
Categories: Java Tags: , ,

My first Scala servlet (with Eclipse)

October 10th, 2010 2 comments

In this article, I will show you how to tweak Eclipse so that you will be able to code “classical” webapps in Scala.

Note: I know about Lift, I just want to see how Scala can integrate in my existing infrastructure step-by-step.

Setting up your Eclipse project

Eclipse has a plugin(found at the Scala IDE site) that let you help develop with Scala. The plugin is by no mean perfect (autocompletion does not works in Ganymede), but it gets the job done, letting you create Scala projects that automatically compile Scala code with scalac.

The Web Tools Platform, another Eclipse plugin, let you create web application projects that can be deployed to application servers.

Most projects created with one or another Eclipse plugin are compatible with one another. For example, you can create a new Dynamic Web Project, then add a JPA extension and presto, you can now use the Java Persistence API in you project. Likewise, you can add a Vaadin extension to your Web Project and you can use Vaadin in it. These extensions are called “Facets” in Eclipse. Each project can have many facets: Java, JPA, Vaadin, etc. depending on the plugins you installed.

Unfortunately, the Scala plugin does not use the Facet mechanism. Thus, Dynamic Web Projects cannot be enhanced with the Scala facet. Creating a web project that compiles your Scala code requires a little tweaking. First, you should create a simple Dynamic Web Project. Then, open the .project file. If you do not see the file, go to Customize View in the view and uncheck .*resources in the Filter tab (the first one). It should look something like this:


Replace the org.eclipse.jdt.core.javabuilder with org.scala-ide.sdt.core.scalabuilder. Note: you can remove the Java builder with the IDE but you cannot add another one so hacking the configuration file is a necessary evil. Now add the Scala nature to your project: org.scala-ide.sdt.core.scalanature.

The .project file should now look like this:


If you made the right change, you should see a S instead of a J on your project’s icon (and it should keep the globe!).

The last thing to do should be to add the Scala library to your path. Depending on your application server configuration, either add the Scala library to your build path (Build Path -> Configure Build Path -> Add Library -> Scala Library) or manually add the needed library to your WEB-INF/lib folder. You’re all set to create your first Scala servlet!

Creating your servlet

In order to create your servlet “the easy way”, just do New -> Other -> Scala Class. Choose a package (it is a good practice to respect the Java guidelines regarding the class location according to its package name). Choose the HttpServlet as the superclass. Name it however you please and click OK.

It seems to compile but you and I know there will be some problem later since you don’t override the servlet’s doGet() method. Do it:

override def doGet(request:HttpServletRequest, response:HttpServletResponse) {


Don’t forget the imports. Let’s use the Scala way:

import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}

Last but not least, let’s code some things for your servlet to do. Since I’m feeling very innovative, I will print the good old “Hello world!”:

override def doGet(request: HttpServletRequest, response: HttpServletResponse) {

  response setContentType ("text/html")

  val out = response getWriter

  out println """
      Scala Servlet
      <p>Hello world!"""
<p>Don’t forget to add the servlet to your web.xml and presto, you should see some familiar example, in a familiar IDE, but with some unorthodox language.</p>
<p>Once Eclipse correctly set up, it’s pretty straightforward to develop your webapp in Scala. I do hope the next version of the Scala IDE plugin will definitely improve Scala’s integration into Eclipse and WTP further.</p>
<p>Here are the <a href="/wp-content/resources/my-first-scala-servlet/" target="_self">sources</a> of the example, in Eclipse format.</p>
<p>To go further:</p>
<li>The <a href="" onclick="_gaq.push(['_trackEvent', 'outbound-article', '', 'Scala Programming Language']);" target="_blank">Scala Programming Language</a></li>
<li>The <a href="" onclick="_gaq.push(['_trackEvent', 'outbound-article', '', 'Scala IDE']);" target="_blank">Scala IDE</a> site</li>
<li><a href="" onclick="_gaq.push(['_trackEvent', 'outbound-article', '', 'Scala for Java refugees']);" target="_blank">Scala for Java refugees</a></li>
<div class='kindleWidget kindleLight' style='font-family: arial;'><img src="//"/><span>Send to Kindle</span></div> <div class="fixed"></div>
<div class="under">
<span class="categories">Categories: </span><span><a href="" rel="category tag">JavaEE</a></span> <span class="tags">Tags: </span><span><a href="" rel="tag">eclipse</a>, <a href="" rel="tag">scala</a></span> </div>
<div class="post" id="post-213">
<h2><a class="title" href="" rel="bookmark">Top Eclipse plugins I wouldn’t go without</a></h2>
<div class="info">
<span class="date">August 8th, 2009</span>
<span class="author"><a href="" title="Posts by Nicolas Frankel" rel="author">Nicolas Frankel</a></span> <span class="comments"><a href="">5 comments</a></span>
<div class="fixed"></div>
<div class="content">
<p>Using an <acronym title="Integrated Development Environment">IDE</acronym> to develop today is necessary but any IDE worth his salt can be enhanced with additional features. NetBeans, IntelliJ IDEA and Eclipse have this kind of mechanism. In this article, I will mention the plugins I couldn’t develop without in Eclipse and for each one advocate for it.</p>
<p>Maven is my build tool of choice since about 2 years. It adds some very nice features comparing to Ant, mainly the dependencies management, inheritance and variable filtering. Configuring the <acronym title="Project Object Model">POM</acronym> is kind of hard once you’ve reached a fairly high number of lines. The Sonatype <a href="" onclick="_gaq.push(['_trackEvent', 'outbound-article', '', 'm2eclipse plugin']);" target="_blank">m2eclipse plugin</a> (formerly hosted by Codehaus) gives you a tabs-oriented view of every aspect of the POM:</p>
<li>An Overview tab neatly grouped into : Artifact, Parent, Properties, Modules, Project, Organization, SCM, Issue Management and Continuous Integration,</li>
<p><img class="aligncenter" title="m2eclipse Overview tab" src="//" alt="m2eclipse Overview tab"/> <a href="" class="more-link">Read more…</a></ul>
<div class='kindleWidget kindleLight' style='font-family: arial;'><img src="//"/><span>Send to Kindle</span></div> <div class="fixed"></div>
<div class="under">
<span class="categories">Categories: </span><span><a href="" rel="category tag">Java</a></span> <span class="tags">Tags: </span><span><a href="" rel="tag">eclemma</a>, <a href="" rel="tag">eclipse</a>, <a href="" rel="tag">emma</a>, <a href="" rel="tag">IDE</a>, <a href="" rel="tag">important</a>, <a href="" rel="tag">m2eclipse</a>, <a href="" rel="tag">maven</a>, <a href="" rel="tag">necessary</a>, <a href="" rel="tag">plugins</a>, <a href="" rel="tag">spring</a>, <a href="" rel="tag">testng</a>, <a href="" rel="tag">top</a></span> </div>
<div id="pagenavi">
<span class="newer"></span>
<span class="older"></span>
<div class="fixed"></div>
<div id="sidebar">
<div id="northsidebar" class="sidebar">
<div class="widget widget_feeds">
<div class="content">
<div id="subscribe">
<a rel="external nofollow" id="feedrss" title="Subscribe to this blog..." href=""><abbr title="Really Simple Syndication">RSS</abbr></a>
<div class="fixed"></div>
<div id="advman-3" class="widget Advman_Widget"><h3></h3><script type="text/javascript"><!--
google_ad_client = "pub-1912713618652264";
/* 160x600, date de création 13/09/10 */
google_ad_slot = "1401534104";
google_ad_width = 160;
google_ad_height = 600;
<script type="text/javascript" src="//">
</script></div> <div id="recent-posts-2" class="widget widget_recent_entries"> <h3>Recent Posts</h3> <ul>
<a href="">Designing your own Spring Boot starter – part 1</a>
<a href="">Why you shouldn’t trust the HTML password input</a>
<a href="">The Java Security Manager: why and how?</a>
<a href="">Playing with Spring Boot, Vaadin and Kotlin</a>
<a href="">8 years of blogging in retrospect</a>
</div> <div id="wp-cumulus" class="widget wp_cumulus_widget">  <script type="text/javascript" src="//"></script><div id="wpcumuluswidgetcontent8850245"><p><a href='' class='tag-link-376' title='4 topics' style='font-size: 9.3207547169811pt;'>android</a>
<a href='' class='tag-link-129' title='5 topics' style='font-size: 10.377358490566pt;'>Architecture</a>
<a href='' class='tag-link-155' title='4 topics' style='font-size: 9.3207547169811pt;'>book</a>
<a href='' class='tag-link-263' title='9 topics' style='font-size: 13.283018867925pt;'>CDI</a>
<a href='' class='tag-link-119' title='4 topics' style='font-size: 9.3207547169811pt;'>configuration</a>
<a href='' class='tag-link-142' title='3 topics' style='font-size: 8pt;'>custom</a>
<a href='' class='tag-link-182' title='4 topics' style='font-size: 9.3207547169811pt;'>dependency injection</a>
<a href='' class='tag-link-133' title='3 topics' style='font-size: 8pt;'>design</a>
<a href='' class='tag-link-152' title='3 topics' style='font-size: 8pt;'>design pattern</a>
<a href='' class='tag-link-307' title='4 topics' style='font-size: 9.3207547169811pt;'>devops</a>
<a href='' class='tag-link-304' title='10 topics' style='font-size: 13.811320754717pt;'>devoxx</a>
<a href='' class='tag-link-151' title='4 topics' style='font-size: 9.3207547169811pt;'>eclipse</a>
<a href='' class='tag-link-62' title='14 topics' style='font-size: 15.660377358491pt;'>hibernate</a>
<a href='' class='tag-link-311' title='6 topics' style='font-size: 11.301886792453pt;'>integration testing</a>
<a href='' class='tag-link-420' title='5 topics' style='font-size: 10.377358490566pt;'>Java</a>
<a href='' class='tag-link-333' title='4 topics' style='font-size: 9.3207547169811pt;'>javaconfig</a>
<a href='' class='tag-link-172' title='4 topics' style='font-size: 9.3207547169811pt;'>jboss</a>
<a href='' class='tag-link-60' title='3 topics' style='font-size: 8pt;'>jpa</a>
<a href='' class='tag-link-122' title='3 topics' style='font-size: 8pt;'>logging</a>
<a href='' class='tag-link-166' title='3 topics' style='font-size: 8pt;'>m2eclipse</a>
<a href='' class='tag-link-167' title='23 topics' style='font-size: 18.301886792453pt;'>maven</a>
<a href='' class='tag-link-386' title='4 topics' style='font-size: 9.3207547169811pt;'>microservices</a>
<a href='' class='tag-link-88' title='4 topics' style='font-size: 9.3207547169811pt;'>mockito</a>
<a href='' class='tag-link-46' title='3 topics' style='font-size: 8pt;'>opensource</a>
<a href='' class='tag-link-47' title='4 topics' style='font-size: 9.3207547169811pt;'>open source</a>
<a href='' class='tag-link-61' title='6 topics' style='font-size: 11.301886792453pt;'>persistence</a>
<a href='' class='tag-link-93' title='3 topics' style='font-size: 8pt;'>proxy</a>
<a href='' class='tag-link-48' title='6 topics' style='font-size: 11.301886792453pt;'>quality</a>
<a href='' class='tag-link-273' title='13 topics' style='font-size: 15.264150943396pt;'>scala</a>
<a href='' class='tag-link-83' title='10 topics' style='font-size: 13.811320754717pt;'>security</a>
<a href='' class='tag-link-45' title='3 topics' style='font-size: 8pt;'>sonar</a>
<a href='' class='tag-link-49' title='45 topics' style='font-size: 22pt;'>spring</a>
<a href='' class='tag-link-383' title='8 topics' style='font-size: 12.622641509434pt;'>spring boot</a>
<a href='' class='tag-link-347' title='4 topics' style='font-size: 9.3207547169811pt;'>Spring MVC</a>
<a href='' class='tag-link-12' title='3 topics' style='font-size: 8pt;'>taglib</a>
<a href='' class='tag-link-90' title='12 topics' style='font-size: 14.735849056604pt;'>test</a>
<a href='' class='tag-link-30' title='6 topics' style='font-size: 11.301886792453pt;'>testng</a>
<a href='' class='tag-link-79' title='5 topics' style='font-size: 10.377358490566pt;'>tomcat</a>
<a href='' class='tag-link-28' title='3 topics' style='font-size: 8pt;'>unit test</a>
<a href='' class='tag-link-96' title='7 topics' style='font-size: 11.962264150943pt;'>unit testing</a>
<a href='' class='tag-link-257' title='19 topics' style='font-size: 17.245283018868pt;'>vaadin</a>
<a href='' class='tag-link-25' title='5 topics' style='font-size: 10.377358490566pt;'>web</a>
<a href='' class='tag-link-240' title='4 topics' style='font-size: 9.3207547169811pt;'>webapp</a>
<a href='' class='tag-link-58' title='4 topics' style='font-size: 9.3207547169811pt;'>wordpress</a>
<a href='' class='tag-link-137' title='4 topics' style='font-size: 9.3207547169811pt;'>xml</a></p><p>WP Cumulus Flash tag cloud by <a href="">Roy Tanck</a> and <a href="">Luke Morton</a> requires <a href="">Flash Player</a> 9 or better.</p></div><script type="text/javascript">var widget_so8928918 = new SWFObject("", "tagcloudflash", "260", "260", "9", "#ffffff");widget_so8928918.addParam("wmode", "transparent");widget_so8928918.addParam("allowScriptAccess", "always");widget_so8928918.addVariable("tcolor", "0x2970a6");widget_so8928918.addVariable("tcolor2", "0x2970a6");widget_so8928918.addVariable("hicolor", "0xFF0000");widget_so8928918.addVariable("tspeed", "100");widget_so8928918.addVariable("distr", "true");widget_so8928918.addVariable("mode", "tags");widget_so8928918.addVariable("tagcloud", "");widget_so8928918.write("wpcumuluswidgetcontent8850245");</script> </div> <div id="recent-comments-2" class="widget widget_recent_comments"><h3>Recent Comments</h3><ul id="recentcomments"><li class="recentcomments"><span class="comment-author-link">clay press</span> on <a href="">Designing your own Spring Boot starter – part 1</a></li><li class="recentcomments"><span class="comment-author-link"><a href='' rel='external nofollow' class='url'>Cristian</a></span> on <a href="">Playing with Spring Boot, Vaadin and Kotlin</a></li><li class="recentcomments"><span class="comment-author-link"><a href='' rel='external nofollow' class='url'>Nicolas Frankel</a></span> on <a href="">Designing your own Spring Boot starter – part 1</a></li><li class="recentcomments"><span class="comment-author-link">Abhijit Sarkar</span> on <a href="">Designing your own Spring Boot starter – part 1</a></li><li class="recentcomments"><span class="comment-author-link"><a href='' rel='external nofollow' class='url'>Nicolas Frankel</a></span> on <a href="">Vaadin Spring integration</a></li></ul></div></div>
<div id="centersidebar">
<div id="eastsidebar" class="sidebar">
<div id="westsidebar" class="sidebar">
<div class="fixed"></div>
<div id="southsidebar" class="sidebar">
<div class="fixed"></div>
<div id="footer">
<a id="gotop" href="#" onclick="MGJS.goTop();return false;">Top</a>
<a id="powered" href="">WordPress</a>
<div id="copyright">
Copyright © 2008-2016 A Java geek </div>
<div id="themeinfo">
Theme by <a href="">NeoEase</a>. Valid <a href="">XHTML 1.1</a> and <a href="">CSS 3</a>. </div>
 <script type='text/javascript' src='//'></script>
<script type='text/javascript' src='//'></script>
<script type='text/javascript' src='//'></script>
<script type='text/javascript'>
		var corecss = document.createElement('link');
		var themecss = document.createElement('link');
		var corecssurl = "";
		if ( corecss.setAttribute ) {
				corecss.setAttribute( "rel", "stylesheet" );
				corecss.setAttribute( "type", "text/css" );
				corecss.setAttribute( "href", corecssurl );
		} else {
				corecss.rel = "stylesheet";
				corecss.href = corecssurl;
		document.getElementsByTagName("head")[0].insertBefore( corecss, document.getElementById("syntaxhighlighteranchor") );
		var themecssurl = "";
		if ( themecss.setAttribute ) {
				themecss.setAttribute( "rel", "stylesheet" );
				themecss.setAttribute( "type", "text/css" );
				themecss.setAttribute( "href", themecssurl );
		} else {
				themecss.rel = "stylesheet";
				themecss.href = themecssurl;
		document.getElementsByTagName("head")[0].insertBefore( themecss, document.getElementById("syntaxhighlighteranchor") );
	SyntaxHighlighter.config.strings.expandSource = '+ expand source'; = '?';
	SyntaxHighlighter.config.strings.alert = 'SyntaxHighlighter\n\n';
	SyntaxHighlighter.config.strings.noBrush = 'Can\'t find brush for: ';
	SyntaxHighlighter.config.strings.brushNotHtmlScript = 'Brush wasn\'t configured for html-script option: ';
	SyntaxHighlighter.defaults['pad-line-numbers'] = true;
	SyntaxHighlighter.defaults['tab-size'] = 2;
<script type='text/javascript' src='//'></script>
<script type='text/javascript'>
/* <![CDATA[ */
(function k(){window.$SendToKindle&&window.$SendToKindle.Widget?$SendToKindle.Widget.init({"title":".entry-title","published":".entry-date","content":".post","exclude":".sharedaddy"}):setTimeout(k,500);})();
/* ]]> */
<script type='text/javascript' src='//'></script>
<script type='text/javascript' src='//'></script>
<script src="/cookiechoices.js"></script>
  document.addEventListener('DOMContentLoaded', function(event) {
    cookieChoices.showCookieConsentBar('By continuing browsing this site, you explicitly accept cookies.',
      'OK', 'Learn more', '');