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 257684 - JSF 2 composite components in JAR are not recognized
Summary: JSF 2 composite components in JAR are not recognized
Status: NEW
Alias: None
Product: javaee
Classification: Unclassified
Component: JSF Editor (show other bugs)
Version: 8.1
Hardware: PC Windows 7 x64
: P3 normal with 3 votes (vote)
Assignee: Martin Fousek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-23 03:29 UTC by ban.nobuhiro
Modified: 2017-07-25 22:53 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 ban.nobuhiro 2016-01-23 03:29:59 UTC
Overview:

NetBeans 8.1 does not recognize JSF composite components in JAR files.
Component files are stored in JAR as /META-INF/resources/**/*.xhtml.


Description:

In org.netbeans.modules.web.jsf.editor.index.CompositeComponentModel
( http://hg.netbeans.org/main-golden/raw-file/d5b9312f4383/web.jsf.editor/src/org/netbeans/modules/web/jsf/editor/index/CompositeComponentModel.java ),
getResourcesDirectory(FileObject) checks path:
>  if (folder.getName().equalsIgnoreCase("resources")) { //NOI18N
>      //check if its parent is META-INF
>      FileObject parent = folder.getParent();
>      if (parent != null && parent.getNameExt().startsWith("META-INF")) { //NOI18N
>          //the folder seems to be the right resources folder
>          return folder;
>      }
>  }

but this is buggy, so
  * /META-INF/resources/ : not match
  * /foo.META-INF/resources/ : match
  * /foo.META-INFbar/resources/ : match


Suggested fix:

Replace
  parent.getNameExt().startsWith("META-INF")
with
  parent.getName().equalsIgnoreCase("META-INF") .
Comment 1 ban.nobuhiro 2016-03-20 07:22:56 UTC
>Suggested fix:
>
>Replace
>  parent.getNameExt().startsWith("META-INF")
>with
>  parent.getName().equalsIgnoreCase("META-INF") .

This fix was not enough...

org.netbeans.modules.web.jsf.editor.index.JsfBinaryIndexer does not
search *.xhtml files:
>@ConstrainedBinaryIndexer.Registration(
>namePattern = ".*\\.tld|.*\\.taglib\\.xml",
>indexVersion = JsfBinaryIndexer.INDEXER_VERSION,
>indexerName = JsfBinaryIndexer.INDEXER_NAME)

So you need to add "*.xhtml" to namePattern in Registration.
(And need to increment indexVersion ?)
Comment 2 greensoft 2016-11-21 11:38:32 UTC
Despite the low number of votes so far, this (hopefully easily fixed) issue is very important for the continued popularity of NetBeans for JSF work. 

Combined with the lack of a dedicated NetBeans Web Fragment Project that one can easily reference as a Project dependency (the workaround for which is to use a Web Application project and use a custom Ant task to build a JAR with appropriate structure, which then can't be "seen" because of this issue here, this issue renders NetBeans barely usable for modular JSF work.

I have spent the last few days reading nearly everything possible about strategies for modularising Java EE projects. Again and again in forum postings I've encountered people who are (or were) using NetBeans with Ant but have been forced to move eventually to Eclipse (+ Maven) because of these two related issues:

1. Lack of a dedicated Web Fragment Project that builds a JAR (see workaround here http://stackoverflow.com/questions/18746367/how-to-create-and-maintain-jsf-composite-component-jar-with-netbeans-and-ant)

2. Even if you build a composite component library JAR with the correct structure, the NetBeans JSF/XHTML editor can't "see" the composite components.

I have used both Eclipse and NetBeans for many years professionally. For standalone JSF Web Application development I prefer NetBeans; for highly modularised JSF development (with intermediate JSF "library" layer separated from EJB and EIS/database layers and client web app) it is currently almost unusable.

A quick tour of Stackoverflow reveals that you are losing otherwise avid NetBeans fans to Eclipse because of these related issues.
Comment 3 greensoft 2016-12-01 07:37:25 UTC
Have also tried using NetBeans Maven projects and the same problem exists. Please see description of Maven setup here: http://stackoverflow.com/questions/40886972/netbeans-maven-web-apps-two-how-create-jar-from-upstream-web-app-as-dependenc
Comment 4 appercel 2016-12-01 10:05:23 UTC
I have to agree that I also have to workaround this limitation when using NetBeans, and I'm then forced to design, implement, or declare my JSF components in a way that I would not otherwise do if this limitation did not exist.

I've tried other IDE's because of that, namely IntelliJ and Eclipse, but still I prefer NetBeans though.