Netbeans - Stairway To Maven

"...Maven2 support in Eclipse sucks. Period." as Kristian wrote this comment to one of my posts I wondered about this strong opinion. I actually used Eclipse with Maven plugin and it worked well. With the eclipse:eclipse plugin, maven creates the whole Eclipse project for you (including all the dependencies and classpath entries) - and you can just start the development. It worked so well, that I actually used it to develop some of my leisure projects (before Netbeans 5.5) too. I begun to understand Kristians clear statement :-), as I opened accidentally some of the old eclipse projects with Netbeans 6.0. It just worked, the menu structured looked very similar, I only recognized a small m2 icon in the project explorer. I began to wonder - there was no netbeans:netbeans execution or something similar - it just worked. I looked deeper into the integration and it turned out, that Netbeans support for maven is native. Netbeans just uses Maven to build the artifact instead of the internal build system. This makes a huge difference between Netbeans and Eclipse (I believe IntelliJ as well). The Netbeans-Maven integration is DRYier (Don't Repeat Yourself - no redundancies) - you have only to maintain the Maven-dependencies and you do not have to repeat it again in the IDE. This makes the work with Maven really enjoyable.

I used Maven with Netbeans in my previous projects as well - however I thought someone generated the Netbeans project already for me. However for the Maven integration you have to extend Netbeans 6.0 with a plugin (this is no more required in recent NetBeans versions). The installation is really easy - only a plugin has to be installed (it takes few minutes). Netbeans 6.0 even provides a visualization of the maven dependencies - however this feature seems not to work with Netbeans 6.1rc1.

If you have already a maven project somewhere, just try to open it with netbeans - and drop a comment here. My opinion isn't so strong as Kristian's, however I like hat Maven's integration in Netbeans work... Whats nice as well is the maven repository explorer and dependency management. However this feature is available in eclipse too.

Comments:

This is only true if you use a Maven project as Maven project in Netbeans. We consistently have trouble to get Maven web projects created in eclipse running as web projects in Netbeans.

Because if you consider it a Maven project you cannot directly run it on a server right from netbeans. No hot code replacement, nothing. If you choose to consider the project a web project, you manually have to redeclare dependencies (at least we haven't found a way round this).

Regarding this issue, I think the native support is more a lack than a feature. You can only do either or, not both of the same time.

With the current M2Eclipse you simply activate the plugin for the project and manage your dependencies by editing the pom.xml. The rest is standard eclipse stuff (Run on Server etc.)

Just my 0.02€...

Regards, Ollie

Posted by Oliver Gierke on April 18, 2008 at 11:30 AM CEST #

Oliver, can you elaborate on the "only true if you use Maven project as Maven project in Netbeans" statement?
Maven projects with war packaging should be as capable of deployment on server (that you choose in project customizer) as are standard ant based web projects. A precondition is to have the standard j2ee support installed.

if it doesn't work for you for any reason, please consider filing a bug report. Either at http://jira.codehaus.org/browse/MEVENIDE or at netbeans.org issuezilla (component: projects, subcomponent: maven)

Regards

Milos

Posted by Milos Kleint on April 18, 2008 at 12:44 PM CEST #

Well indeed my initial post on that was a little strong I guess. :) Basically, to me the most immanent and painful thing actually is the "doubling" of the build system - it's more effort to handle, it doesn't seamlessly integrate, it's difficult to explain to new users and, asides that, it is not really needed.

@Oliver: In maven you also can do "run on server" for a maven project, given it is a .war artifact. But I agree with you in that web project thing. If you consider a project a "web project" in terms of NetBeans project management, it's not a "maven" project anymore. On the other side, making a maven project a "web project" in Eclipse actually introduces a whole bunch of Eclipse-specific configuration (like eclipse:eclipse) to your project which is next to unusable in any other environment. It's possibly a matter of use cases and requirements - in our situation, I wanted to be as independent of the IDE as somewhat possible. And, about that, relying _solely_ on maven and its plugins while not being tied too much to the IDE, NetBeans simply does better in my opinion.

Cheers,
Kristian

Posted by kawazu on April 18, 2008 at 12:46 PM CEST #

Well perhaps my initial opinion indeed was worded a little too strong. ;) Maybe my main issue in Eclipse is the existence of a "proprietary" build mechanism which, in terms of having projects portable between different IDEs, seems a major drawback (and not necessary, asides that).

@Oliver: "Run on server" also works for .war artifacts in NetBeans. ;) Asides this, making a Maven project a "Web Project" in NetBeans terminology requires some modification as a "Web Proejct" uses the standard ant build mechanism. Don't know about hot-code replacement, though. Possibly it's a matter of requirements in a given situation. :)

Posted by Kristian Rink on April 18, 2008 at 12:50 PM CEST #

Oliver,

I just try to avoid "hot replacement" and sometimes even "incremental deployments". Javac compiler tends to optimize code ...and copy so sometimes the constants from the interface to a class. I spend once a whole night to find this out. This is the reason, why I didn't used it.

Thank you for your comment!,

regards,

adam

Posted by Adam Bien on April 18, 2008 at 01:07 PM CEST #

Maven support is good in NetBeans unless you want to use Visual Web JSF (Woodstock).

It took me 2 days now to figure out some weird problems that came up with the combination NetBeans/Maven/Woodstock.

At first, do not rely on NetBeans' Maven plugin (which is 3.0.10 or something). Get the newest version from http://deadlock.netbeans.org/hudson/job/mevenide/ and install it. They have fixed some bugs in there.

Then try to create a Maven project in NetBeans with the archetype "Web project". You will see that the J2EE version is set to 1.3 (!) which is due to the created web.xml. You can't change the J2EE version, it is a readonly field. Instead, go and change your web.xml to have servlet version 2.5. Then, *restart* NetBeans! J2EE version will be set to 1.5.
Only now you can add Visual Web JSF capabilities to the project (through Properties -> Frameworks). NetBeans is then installing the Woodstock dependencies to a fake repository in the project's lib folder. Notice that these dependencies are not sufficient to make NetBeans think you have a valid project. E.g, add servlet-api as a 'provided' dependency to make compile errors (red exclamation mark) vanish.
One big problem is to get the Visual Web UI Designer working correctly. Often, it can't be visualized, telling you about errors either in JSP or in the backing bean. This is most probably due to incorrect dependencies in your pom. Be sure to *restart* NetBeans once in a while to motivate the Visual Designer :-) Also be aware to execute "Clean and Build", not only "Build".

This leads to the next problem: (Sometimes?) you can't do a Clean if your war is already deployed. Seems as if Glassfish locks some files. You have to stop Glasfish then to make your Clean succeed.

One of the most annoying things is, that the Woodstock artifacts and its dependent artifacts which are hosted in the download.java.net Maven repository are inconsistent with the libraries provided by NetBeans! Woodstock 4.1.1 which ships with NB 6.0.1 is not hosted at all, whilst Woodstock 4.2 (shipping with NB 6.1RC) is hosted, but the libraries are not identical! Really annoying.

So what you can do is just to take the artifacts from you fake repository in {project.home}/lib and install them to your company's Maven repository. Following Maven web projects then can rely on these libraries, at least if they also use NetBeans 6.1RC.

Ok, now I've paid more than just 2 cents ;-) I felt a need to blow my stack...
Let's hope for real good Maven support with NetBeans 6.1 coming soon.

Stefan

Posted by Stefan Bley on April 18, 2008 at 01:13 PM CEST #

Hi folks,

I just wanted to add my thoughts to this issue. Unfortunately, I stumbled on the 1000 char limitation ;-) So I've put my comment in this Nabble thread, which also is about NetBeans/Maven. Milos, you already know about it :-)

http://www.nabble.com/Maven-web-project-td15495303.html#a16762551

Stefan

Posted by Stefan Bley on April 18, 2008 at 01:28 PM CEST #

Integration of mySQL driven with Netbeans 6 IDE is the best recent news about easing the work with mySQL and developing its applications by using Netbeans. But remains one point. Many developers still believe that loading netbeans takes time to open on your desktop.
sharo

Posted by Sharo Samavi on April 18, 2008 at 04:10 PM CEST #

Sharo,

you read my "Need For Speed" post?: http://www.adam-bien.com/roller/abien/entry/need_for_speed_with_netbeans

Posted by Adam Bien on April 18, 2008 at 04:31 PM CEST #

Nice to meet the usual suspects here ;).

I dont really see, why Eclipse should get in the way, when working with a web project which is a maven project actually. Eclipse config files are in .settings Folder plus .classpath, .project. Thats all. The m2Eclipse plugin does nothing else than maintaining these files with pom.xml as source. So nothings intermingled here.

Of course you have to initially create the project as web project (or check it out as web project from your VCS). Afterwards, its just a metter of "Enable dependency management" to let the project be configured from pom.xml.

As we're often working on projects with a designated web layer, i hardly want to redeploy the entire application for every small change.

Perhaps I'm alittle biased, as I never really got warm with Netbeans. =)

Regards,
Ollie

Posted by Oliver Gierke on April 19, 2008 at 02:33 PM CEST #

Oliver,

thanks for your comment - I will try the newer Eclipse Maven Plugin - it sounds promising.
About beeing biazed: it is a really bad idea. I personally enjoy the switching between both IDEs. For my Java EE 5 work I prefer Netbeans, however in some projects I'm using Eclipse with Ant - and it works very good as well.
Just try Netbeans 6.1rc1/2 - its really nice,

adam

Posted by Adam Bien on April 19, 2008 at 04:07 PM CEST #

I used this technology for SEO reporting system.Simply brilliant and easy to manage

Only problem was Mavan management

Posted by Nigel on January 06, 2009 at 06:42 PM CET #

I used this technology for SEO reporting system.Simply brilliant and easy to manage

Only problem was Mavan management

Posted by SEO Reporting on January 06, 2009 at 06:43 PM CET #

I switched from eclipse to Netbeans because the new compagny I work for wants me to do so. I think Netbeans sucks big time. First of all they change the project structure and build it correctly with a build.xml. Gentleman that is finding a solution for a problem that does not exist. Second of all if you create a project in ecliplse lets say a Java project and you want to change that to a web project google and oila. NP!!!! try that with netbeans You google until retirement time. The second of all I f create a maven project in Eclipse And I want it to be a standard webproject I just switch the m2 dependency management of try that in netbeans.... I think netbeans is a real nightmare for those who like a bit of freedom to do their work.

Posted by Pieter Roskam on June 23, 2011 at 02:32 PM CEST #

@Pieter,

create a Maven project. You can change it to whatever you want. Just change the pom type.

adam

Posted by Adam Bien on June 23, 2011 at 10:32 PM CEST #

Hi there
I tried to create an "Out of the Box"
Netbeans Maven WebApplication using the built-in Maven 3.0.5.
Only to discover the project does not get generated
I wonder if Netbeans 8.0.2 has a bug
I get this error creating a new MavenWebApp:

Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.3:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.codehaus.mojo.archetypes:webapp-javaee7:1.1) -> [Help 1]

I am using Java \jdk1.7.0_67
Java SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

Pity as I like this IDE
regards
Nico

Posted by nico on June 08, 2015 at 02:33 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License