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 241205 - Imported maven project from 7.4 missing webapp in projects ('Web Pages')
Summary: Imported maven project from 7.4 missing webapp in projects ('Web Pages')
Status: REOPENED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-31 04:17 UTC by kommareddi
Modified: 2016-10-04 10:55 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Comparison of 7.4 and 8.0 project views (75.74 KB, image/png)
2014-01-31 04:17 UTC, kommareddi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kommareddi 2014-01-31 04:17:56 UTC
Created attachment 144613 [details]
Comparison of 7.4 and 8.0 project views

I import a NB 7.4 project which is a Maven project with a Spring MVC/AngularJS on the UI and Spring/Jersey/JAXWS on the server to NB 8.0. When importing, it prompted me to upgrade the project and upgraded successfully.

However when I look in the projects view, I don't see my webapp (Web Pages). See attachment - nb-7.4-8.0.png.

Looking in the project properties, the Javascript files section shows an error: Invalid web/site root provided.

This pretty much prevents using NB for any JSP/JS/HTML development.

Pl let me know if you need addl information
Comment 1 kommareddi 2014-01-31 04:57:55 UTC
Not sure if this is a NB issue, but I was able to resolve it by removing references to ${basedir} in pom.xml and just use '/' to refer to the root.
Comment 2 Milos Kleint 2014-01-31 06:00:33 UTC
can you attach the relevant pom.xml snippet?
Comment 3 kommareddi 2014-01-31 17:12:58 UTC
        <plugins>
			
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                                        <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>

        </plugins>

If I remove ${basedir} in above, it works in NB 8. The above works fine in NB7.4 as is.
Comment 4 Milos Kleint 2014-01-31 19:12:11 UTC
mjanicek: please evaluate, if the war plugin accepts both variants, so should we. Maybe we don't exaluate the value properly?
Comment 5 kommareddi 2014-01-31 22:19:36 UTC
I added this plugin:

           <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <echo>BASEDIR:${basedir}</echo>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The echo is printing out the right path.
Comment 6 Martin Janicek 2014-02-03 09:33:41 UTC
Fixed by change-set: web-main #f682abfa001e

Thank you for the report!
Comment 7 Quality Engineering 2014-02-04 03:07:29 UTC
Integrated into 'main-silver', will be available in build *201402040001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f682abfa001e
User: Martin Janicek <mjanicek@netbeans.org>
Log: #241205 - Imported maven project from 7.4 missing webapp in projects (Web Pages)
Comment 8 NukemBy 2016-10-04 10:55:29 UTC
I think 'fix' is not completely correct - current implementation ...
http://hg.netbeans.org/main/file/ef35591e2d0f/maven.j2ee/src/org/netbeans/modules/maven/j2ee/web/WebProjectWebRootProvider.java#l133

        // Try to find resources root using absolute path --> See issue #241205
        return FileUtil.toFileObject(FileUtil.normalizeFile(new File(webSourceDir)));

.. says it is checking 'absolute path', but does not check if path is really absolute. In case when MAVEN project does not have "src/main/webapp" next attempt (when webSourceDir is not absolute) will be actually performed against that folder:  
   C:\<NetBeans install root>\src\main\webapp

I guess correct code will look like this

        // Try to find resources root using absolute path --> See issue #241205
        File absWebRoot = new File(webSourceDir);
        return !absWebRoot.isAbsolute() ? null : FileUtil.toFileObject(FileUtil.normalizeFile(absWebRoot));