This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 208607 - Unable to set jee version for application
Summary: Unable to set jee version for application
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.1.1
Hardware: PC Mac OS X
: P3 normal with 2 votes (vote)
Assignee: Martin Janicek
URL:
Keywords:
: 184616 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-19 06:52 UTC by medeag
Modified: 2013-01-28 15:00 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description medeag 2012-02-19 06:52:12 UTC
Product Version: NetBeans IDE 7.1 (Build 201112071828)
Java: 1.6.0_29; Java HotSpot(TM) 64-Bit Server VM 20.4-b02-402
System: Mac OS X version 10.6.8 running on x86_64; MacRoman; ka_GE (nb)

I'm trying to port eclipse based maven web application to netbeans, i checked  out the sources from repository using netbeans, netbeans recognized it as the maven based web app, but when i tried to run it, netbeans only showed me glassfish 3+ server, when i checked run configuration and J2EE version is JEE6, which should not be for my app, since it should run on tomcat 6 so it should be JEE5.
Netbeans should give users the opportunity to select JEE version.
Comment 1 Martin Janicek 2012-02-20 10:04:33 UTC
This was already discussed as a part issue 184616 (please take a look for some background). We are not sure if it's a good idea to let the user decide which Java EE version should be used. Current solution works fine in a typical cases but it seems that sometimes our recognition mechanism fails, so maybe we should reconsidered and provide some 'backup' mechanism to able to change it manually (not by default - only if necessary).

David could you please comment on this one?
I more or less agree with medeag that we should give the user some opportunity to select JEE version. Project Properties/Run panel could be easily used for that (actually Java EE version is already there - only thing that needs to be done is to enable to change it and change the server selection at the same time). But I don't feel as a person authorized to decide if it's generally good idea or not :]
Comment 2 Petr Jiricka 2012-02-20 12:47:18 UTC
A related question is, when Java EE 7 comes along, how will we recognize Java EE 6 from Java EE 7 in cases when web.xml is missing? In both EE 6 and EE 7 web.xml is optional.
Comment 3 David Konecny 2012-02-23 00:36:32 UTC
> [...] when i checked run configuration and J2EE version is JEE6,
> which should not be for my app, since it should run on tomcat 6 so it should be
> JEE5.

Tomcat was always problematic fit into NetBeans EE projects design because it is not EE compliant server. How does this work in Ant based Web project Martin? If I'm creating new Web Project for Tomcat 6 can I select EE 6? If not I would think that Maven should behave similarly. And vice versa.

If user want to develop EE 5 application which is deployable to Tomcat 6 then they can create web.xml and set version there, no?

I'm not against allowing to set EE level but I would like to do it only when it is necessary, for example as Petr say to distinguish EE 6 from 7 or cases like that. In this case I do not think there is strong argument to allow that. If something I would rather fix Tomcat 6 to "pretend" to be EE 6 compliant server even if it is not.
Comment 4 medeag 2012-02-23 04:11:33 UTC
Just for information:

Project i'm working on has web.xml with appropriate header 

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> 

but still netbeans fails it to recognize as jee5 project, unfortunately i can't share project since it is not open source.
Comment 5 David Konecny 2012-02-23 06:29:31 UTC
That sounds like a bug which needs to be fixed.
Comment 6 medeag 2012-02-23 17:32:11 UTC
I think in my case the problem is lies in project structure: 
 
Project Name:
   -- WEB-INF
             --src
             --web.xml
   -- pom.xml

So netbeans sees pom.xml but doesn't see web.xml. just the guess...
Comment 7 Martin Janicek 2012-06-13 13:47:41 UTC
*** Bug 184616 has been marked as a duplicate of this bug. ***
Comment 8 predatorvi 2012-10-30 17:01:02 UTC
Coming late to the party, I started using the Enunciate utility that does some magic at build time to allow all sorts of coolness in my web services.

The final web.xml is generated at build time using Enunciate which it puts into the final target folder and WAR file.

This is causing issues in NetBeans because it is a JavaEE 5 service, but due to the lack of a web.xml, NB assumes JavaEE 6 and won't let me deploy to my Tomcat6 servers.
Comment 9 David Konecny 2012-10-30 21:26:04 UTC
Re. Enunciate - I would think you should be able to define in your sources (empty) web.xml and during the build Enunciate adds additional stuff to it.
Comment 10 predatorvi 2012-10-30 22:18:39 UTC
Re: Enunciate -- By default, if there exists a src/main/webapp/WEB-INF/web.xml, this file is the one that "wins" during packaging of the war file.  Thus, any "generated" content got lost to this version of the file.

I even tried adding variations of 'packagingExcludes' option in the maven-war-plugin to exclude web.xml but without success.

I was instructed by the maintainer of Enunciate to remove the default web.xml to allow the enunciate version to be used.  This solved the initial problem, but caused NetBeans to default to JavaEE 6 for my project.

I re-added the default web.xml to make NB happy and found that by using the 'webXml' option in the maven-war-plugin I could force it to use the Enunciate-generated file such as:

<webXml>${project.build.directory}/enunciate/generate/basic-app/merged-web.xml</webXml>

So there is a workaround, but if I could tell NB that my project is JavaEE 5 or if NB would also check the final version of web.xml in the WAR, then it would save some headache but that last option is probably a bit late in the process.

Maybe NB could determine the JavaEE version based on the servlet-api artifact version included in the POM?

Regardless---thanks to anyone reading who works with NetBeans and Maven.  We have devs using Eclipse with m2e and I frequently want to kill myself rather than support that environment.
Comment 11 David Konecny 2012-10-30 22:39:25 UTC
(In reply to comment #10)
> Re: Enunciate -- By default, if there exists a src/main/webapp/WEB-INF/web.xml,
> this file is the one that "wins" during packaging of the war file.  Thus, any
> "generated" content got lost to this version of the file.

My previous comment was based purely on assumption that if there is a tool which can collect some information from my sources and add that information to web.xml automatically that's great but what if I want to add to web.xml something what this tool does not understand? I would expect such tool to allow me to write my own base web.xml and simply enhance that file with additional information which the tool collected. And actually looking at Enunciate documentation (http://enunciate.codehaus.org/user_guide.html) there is "mergeWebXML" config parameter which should allow just that, no?
Comment 12 David Konecny 2012-11-01 02:59:43 UTC
In offline conversation with predatorvi it was confirmed that Enunciate does have a merging mechanism in place and that enables to keep web.xml in the sources. The key to make that work successfully was to configure maven-war-plugin to exclude copying of original web.xml into build output using <warSourceExcludes> exclude option.
Comment 13 Martin Janicek 2012-11-06 08:54:42 UTC
I'm not sure what is the impact of the last 4-5 comments about Enunciate:) As I understand from comment 12, there is a way how to workarround the problem, right? On the other hand it's just another case where our recognition system doesn't "work" correctly and would be good to give the user some opportunity to change the Java EE version.
I would like to make some progress here (the issue is here for a quite long time), but I'm still not convinced what is the correct behavior. As Petr mentioned, maybe the decision will be easier after Java EE 7 integration. From what I have understand there is no way to differs between EE6 and EE7, am I right?
Comment 14 David Konecny 2012-11-06 21:28:42 UTC
(In reply to comment #13)
> I'm not sure what is the impact of the last 4-5 comments about Enunciate:)

None. It was an issue in the Enunciate documentation not explaining how to setup Maven project properly.

> I would like to make some progress here

Do anything you think is right and you are willing to support. I was vocal against storing EE level in project but if it makes life of users easier then perhaps it is worth it.
Comment 15 Martin Janicek 2013-01-22 13:00:41 UTC
With upcoming Java EE 7 support, this has to be done. As much as I know there is no way to recognize between Java EE 6 and Java EE 7 in certain situations. And since the user still can create new project without selected server, we have to allow possibility of choosing different version in already created project.

I'm going to do this within the javaee7 branch..
Comment 16 Petr Jiricka 2013-01-22 13:19:51 UTC
Sounds good - though what will you do in case the deployment descriptor exists? Will it still be allowed to change an app with EE 6 version of web.xml to EE 7. And vice versa?
Comment 17 Martin Janicek 2013-01-22 13:33:54 UTC
(In reply to comment #16)
> Sounds good - though what will you do in case the deployment descriptor exists?
> Will it still be allowed to change an app with EE 6 version of web.xml to EE 7.
> And vice versa?

It should be possible I guess (probably showing user some kind of warning dialog about possible consequences). I don't see another option to be honest. We obviously need to enable changing server in already created project and only other option is to make this changing behavior enabled/disabled based on the presence of the web.xml ..which might sounds good, but it's terrible from the user point of view. No-one would ever know why it is possible to change the server only in some certain mysterious situations.
Comment 18 Martin Janicek 2013-01-28 15:00:12 UTC
Fixed together with Maven Java EE 7 implementation in: web-main #89d0da06af1b

The fix is currently only in javaee7 branch, not in trunk, so it will be part of the 7.3.1 release, but it's not possible to test it in the current daily builds.