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 228939 - Context path from glassfish-web.xml not reflected if the project is opened before the server is registered
Summary: Context path from glassfish-web.xml not reflected if the project is opened be...
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: GlassFish (show other bugs)
Version: 7.3
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: TomasKraus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-24 09:12 UTC by Petr Jiricka
Modified: 2013-07-29 13:17 UTC (History)
2 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 Petr Jiricka 2013-04-24 09:12:45 UTC
Product Version: NetBeans IDE Dev (Build 201304232301)
Java: 1.7.0_15; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_15-b03
System: Mac OS X version 10.7.5 running on x86_64; UTF-8; en_US (nb)

1. Starting with a clean userdir, using the zip build: download, unpack and open the project from http://wiki.netbeans.org/wiki/images/9/99/TyrusAuctionSample.zip
2. Register GlassFish 4 promoted build
3. Go to Project Properties -> Run

The context path is set to /TyrusAuctionSample, which is not expected, because glassfish-web.xml contains the following: 
  <context-root>/sample-auction</context-root>
So I expect that /sample-auction should be set as the context path in project properties.

This works correctly if I first register GlassFish and then open the project. The workaround is to restart the IDE.

The problem is there also for Tomcat (in an analogous scenario), so this is not a GlassFish-specific problem.
Comment 1 Petr Jiricka 2013-05-21 12:14:25 UTC
Also reproducible in the latest 7.3.1 build.
Comment 2 Martin Janicek 2013-05-21 12:19:13 UTC
Is this issue really new? I guess this might be reproducible even in 7.3.
Comment 3 Petr Jiricka 2013-05-21 13:24:51 UTC
You are right, this was also a problem in 7.3 - just reproduced. In the light of that, I think we can waive this for NB 7.3.1, if Jirka agrees. Adding 731-not-a-stopper.
Comment 4 Jiri Skrivanek 2013-05-21 13:27:10 UTC
I agree it is not a stopper for 7.3.1.
Comment 5 Martin Janicek 2013-06-05 13:43:50 UTC
This is unrelated to the Maven. Creating Ant web project, changing context path and then following steps from description results in the same problem.
Although not sure yet where exactly should it be fixed. Need to investigate further..
Comment 6 Martin Janicek 2013-06-11 12:39:55 UTC
I have improved server recognition in Maven web projects a little bit (web-main #578000e13c1e) and now it behaves identical to the Ant based projects.

The rest of the problem needs to be evaluated/fixed on Glassfish side. glassfish.eecommon.api.config.GlassfishConfiguration.getContextRoot() does not return correct value when it's called from j2ee.deployment.config.ConfigSupportImpl.getWebContextRoot() : line 266
Comment 7 TomasKraus 2013-07-09 14:30:49 UTC
Targeting to 7.4. I'm quite busy with other issues now but this should be fixed before release.
Comment 8 TomasKraus 2013-07-22 14:35:34 UTC
I can't reproduce this issue with latest Dev build. Petr, please can you try it too? Looks like ti's working fine.
I did some change into context root code last week. Maybe it resolved this issue too.
Comment 9 Martin Janicek 2013-07-22 14:45:00 UTC
1. Create Ant web app with GF4
2. Go to project properties and set context root to /this-is-reproducible
3. Shut down IDE
4. Start IDE with clean userdir
5. Open the project
6. Project is missing server, resolve the problem by registering GF4
7. Go to project properties, Run subcategory

--> Context root shows /WebApplication1 instead of /this-is-reproducible
Comment 10 TomasKraus 2013-07-23 12:22:02 UTC
org.netbeans.modules.glassfish.eecommon.api.config.GlassfishConfiguration

   protected FileObject getSunDD(File sunDDFile,
           boolean create) throws IOException {
        if (!sunDDFile.exists()) {
            if (create) {
                createDefaultSunDD(sunDDFile);
            } else {
                return null;
            }
        }
        return FileUtil.toFileObject(sunDDFile);
    }

Here seems to be source of our problems - primarySunDD points to /tmp/WebApplication1/web/WEB-INF/sun-web.xml but there is glassfish-web.xml instead.

This is being initialized in GlassfishConfiguration costructor:
            this.primarySunDD = moduleHelper.getPrimarySunDDFile(module);

Looks like J2eeModuleHelper has 2 sources of configuration:

    public static final J2eeModuleHelper getSunDDModuleHelper(
            Object type) {
        return helperMap.get(type);
    }

    public static final J2eeModuleHelper getGlassfishDDModuleHelper(
            Object type) {
        return gfhelperMap.get(type);
    }

getSunDDModuleHelper is old GF v2 config and getGlassfishDDModuleHelper is v3/v4 config with WEB-INF/glassfish-web.xml.
This is being selected in Hk2ModuleConfigFactory. But without server GF v2 version is selected.

Added code into Hk2ModuleConfigFactory.create(J2eeModule module) to check for WEB-INF/glassfish-web.xml file and if exists, select proper v3/4 config.
Also create(final @NonNull J2eeModule module,
final @NonNull String instanceUrl) was modified to rely on new Tooling Library code and compare real server version instead of internal URI which is just a key here.

Checked into web-main:
----------------------
changeset:   259121:e971252d9895
summary:     #228939 - Context path from glassfish-web.xml not reflected
             if the project is opened before the server is registered
Comment 11 Martin Janicek 2013-07-24 12:48:10 UTC
Please don't close the issue until the changeset is pushed to the repository. I tried to reproduce it with todays build, it wasn't working and then I found out that the revision is not in web-main yet. It's hard to verify the fix if the bug is closed in BZ but it's not obvious when it will be part of the build. Thanks
Comment 12 TomasKraus 2013-07-24 14:47:31 UTC
Will push in 5 minutes after all bugs are updated.
Comment 13 Quality Engineering 2013-07-26 02:50:25 UTC
Integrated into 'main-silver', will be available in build *201307252300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/e971252d9895
User: Tomas Kraus <TomasKraus@netbeans.org>
Log: #228939 - Context path from glassfish-web.xml not reflected if the project is opened before the server is registered
Comment 14 Martin Janicek 2013-07-29 13:17:37 UTC
Works fine, thanks