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 221541 - Problem with the context-root when trying to run a Maven project
Summary: Problem with the context-root when trying to run a Maven project
Status: REOPENED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.1
Hardware: PC Windows 10 x64
: P2 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-06 09:52 UTC by hildeberto
Modified: 2017-04-20 14:12 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
parent pom (1.28 KB, application/xml)
2012-11-06 09:54 UTC, hildeberto
Details
ear pom (2.98 KB, application/xml)
2012-11-06 09:54 UTC, hildeberto
Details
ejb pom (1.42 KB, application/xml)
2012-11-06 09:55 UTC, hildeberto
Details
war pom (1.83 KB, text/xml)
2012-11-06 09:55 UTC, hildeberto
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hildeberto 2012-11-06 09:52:44 UTC
We have migrated a previously Ant-based Netbeans Enterprise Project to Maven. We can open it normally in Netbeans and the build with all dependencies works fine.

The only problem we are facing is when we run the project (project-ear) expecting the original context-root /project to open in the browser and we actually get a different context-root based on the name of the web module /project-war-0.1-SNAPSHOT, causing a HTTP 404 error because the original context-root (/project) was taken into consideration by Glassfish (GlassFish Server Open Source Edition 3.1.2 (build 23)).

Glassfish got the correct context-root bacause the deployed ear package contains an application.xml file generated by maven-ear-plugin. This plugin was configured as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <version>6</version>
        <defaultJavaBundleDir>lib</defaultJavaBundleDir>
        <modules>
            <webModule>
                <groupId>GroupId</groupId>
                <artifactId>project-war</artifactId>
                <contextRoot>/project</contextRoot>
            </webModule>
        </modules>
    </configuration>
</plugin>

project-war's properties also indicates the correct context-root (/project) in the section "Run / Context Path". However, we believe that this field is not taken into consideration.

If we create a Maven Enterprise Application from scratch and define the context root as shown above, Netbeans runs the project with the correct context root. In this case, Netbeans doesn't take into consideration the name of the web module by default (new-project-war-0.1-SNAPSHOT). When we change the context-root in the plugin configuration it also works normally for the next execution

We don't understand why it works when Netbeans creates the maven project and it is not working with a manually defined maven project. For some reason, Netbeans is not considering the plugin configuration.

In order to reproduce the problem, I suggest to:

1. create a normal Ant-based Netbeans Enterprise project;
2. convert it to a Maven project manually using the plugin configuration above;
3. remove all nbproject folders and build.xml files;
4. open the project in Netbeans;
5. try to run it.
Comment 1 hildeberto 2012-11-06 09:54:36 UTC
Created attachment 127201 [details]
parent pom
Comment 2 hildeberto 2012-11-06 09:54:59 UTC
Created attachment 127202 [details]
ear pom
Comment 3 hildeberto 2012-11-06 09:55:27 UTC
Created attachment 127203 [details]
ejb pom
Comment 4 hildeberto 2012-11-06 09:55:57 UTC
Created attachment 127204 [details]
war pom
Comment 5 Martin Janicek 2012-11-06 13:34:56 UTC
Hi, thanks for the report. Would it be possible to attach the whole "converted project" instead of poms?
Comment 6 hildeberto 2012-11-06 14:20:52 UTC
I wish I could attach the entire project, but I zipped it and I got a 50Mb file. It also has a lot of dependencies from other projects and connectivity with database, webservices and queues. So, it hardly would work outside of our context. What I can do is to describe here the directory structure of the project:

Activity
  Activity-ear
    src
      main
        application
          META-INF
            (empty)
    pom.xml
  Activity-ejb
    src
      conf
        wsdl
      java
        be
          ucl
            activity
              (..)
        META-INF
          (empty)
    test
    pom.xml
  Activity-war
    src
      conf
      java
        be
          (..)
    test
    web
      (..)
    pom.xml
  pom.xml

Does it help?
Comment 7 Martin Janicek 2012-11-06 14:32:33 UTC
Actually I don't need your commercial product, would be even better if you could create new project and just setup it, so it will be possible to use it as a reproducible test case (it's easier for us to resolve and test the issue on simple example than hardly configure original use-case)
Comment 8 hildeberto 2012-11-07 10:02:43 UTC
I'm trying to reproduce the error without success :( When I performed the suggested steps to reproduce the error the browser opens the application as expected. The only difference is that the project is empty. It seems to be a very particular case in which Netbeans doesn't recognize the declared maven-ear-plugin configuration. I will keep investigating the issue.

Thanks for your attention!
Comment 9 Martin Janicek 2012-11-07 10:21:29 UTC
(In reply to comment #8)
> I'm trying to reproduce the error without success :( When I performed the
> suggested steps to reproduce the error the browser opens the application as
> expected. The only difference is that the project is empty. It seems to be a
> very particular case in which Netbeans doesn't recognize the declared
> maven-ear-plugin configuration. I will keep investigating the issue.
> 
> Thanks for your attention!

Thank you, I'll be in touch. Unfortunately I can't do much without a reproducible test case. Hopefully we find one :)
Comment 10 hildeberto 2012-11-08 08:35:40 UTC
A module containing EJBs, on which the application depends on, had a pom with the packaging configured to "jar", instead of "ejb". Right after changing this property, Netbeans started opening the correct context root: "/project". 

To be sure that it was the cause of the problem, I reverted all changes to the latest revision, run the application to see the problem, changed the packaging from "jar" to "ejb", run again and it worked.

I still think this is a bug because something there changed Netbeans normal behavior. I mean, I would expect a problem during deployment, not during the opening the application in the browser with the correct context-root.

I will try to simulate the problem from scratch.
Comment 11 Martin Janicek 2012-11-19 13:28:39 UTC
Hi hildeberto, have you found a reproducible test case? Can't move forward with this issue without some.
Comment 12 Martin Janicek 2012-11-21 12:54:20 UTC
Closing as INCOMPLETE for now --> hildeberto please reopen the issue together with reproducible project if you found one. Thanks in advance!
Comment 13 hfullgraff 2017-04-20 14:12:15 UTC
Hi.  I would like to resume this issue consdiering I'am having exactly the same problem.

I created and I've been working for a long time in my javaee application conformed by five maven projects, all created created using the Enteprise Application Maven archetype provided by File->New Project wizard in Netbeans 8.1 Build 201510222201

All operating good, until I decided to change the name of all projects that conforms the application(the maven project, the ear project, a java project, an ejb module and a web application).  After do that when I runed the application, what happened was exaclty what was reported by hilderberto@netbeans.org

In my case, the ejb module has not the situation indicated by hildeberto (packagin setted as jar rather than ejb in pom file).  In fact, I runned a folder comparison between the projects with their original name an the folders with the new names, and the only differences where in the name of the referenced projects in pom files.  Nothing else changed.

Please, tell me exactly what evidence do you need from me to help resolve this issue.