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 129103 - maven + visual web interoperability issues.
Summary: maven + visual web interoperability issues.
Status: RESOLVED WONTFIX
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 3 votes (vote)
Assignee: _ potingwu
URL: http://www.codehaus.org/~mkleint/samp...
Keywords:
: 105218 113284 (view as bug list)
Depends on:
Blocks: 89008
  Show dependency tree
 
Reported: 2008-03-04 10:40 UTC by Milos Kleint
Modified: 2008-11-20 23:33 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Exception when opening the designer (after the jsfloader is fixed) (3.02 KB, text/plain)
2008-03-08 00:07 UTC, _ potingwu
Details
.java file errors (18.78 KB, image/gif)
2008-03-12 19:06 UTC, _ sandipchitale
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Milos Kleint 2008-03-04 10:40:17 UTC
I've tried to work on the maven + web frameworks story (http://www.netbeans.org/issues/show_bug.cgi?id=106955). I've
managed to create a Frameworks panel in the maven project properties dialog that allows to add frameworks to maven
projects. It seems to work now fine, all frameworks can be added to project. However when adding visual web  framework
to the project I keep getting errors.

It's been discussed as part of http://www.netbeans.org/issues/show_bug.cgi?id=113284.
Today I tried again. And got a different set of exceptions. I can't figure if these are caused by my integration with
maven, or are general and I just had bad luck.

I created the project, added webframework. While the project compiles, I got exceptions on opening or creating any
visual jsf page. I've tried to restart the IDE and reopen the file, got the same exception.
http://statistics.netbeans.org/analytics/detail.do?id=30496
When I switch to the java tab, I get this one (again consistently)
http://statistics.netbeans.org/analytics/detail.do?id=30500

I succeeded in creating a JSF fragment. However when I try adding a text field in it, it says there's an error (see
below for stacktrace)
The default theme jar is on the classpath.

I would be grateful for any advice on how to resolve these issues.

At this location (http://www.codehaus.org/~mkleint/sampleproject.zip) is a sample maven project I was experimenting
with. It's a 1.4 j2ee webapplication, into which I've added visuaweb through the frameworks panel.
My environment was: daily build of netbeans 6.1 (as of March 4, 2008) the latest build of mevenide
(http://deadlock.netbeans.org/hudson/job/mevenide/) instructions how to install included on that page.
Unzip the project, open it's folder in the IDE, it should open as a maven project. do a build of the project, to get
classpath right and the local maven repository populated. You will need access to the internet at this step.

Then opening visual jsf pages shows errors as described above..

Milos Kleint

com.sun.rave.web.ui.theme.ThemeConfigurationException: No Themes in the classpath!
   at com.sun.rave.web.ui.theme.ThemeFactory.getThemeAttributes(ThemeFactory.java:370)
   at com.sun.rave.web.ui.theme.ThemeFactory.createThemeManager(ThemeFactory.java:304)
   at com.sun.rave.web.ui.theme.ThemeFactory.createThemeManager(ThemeFactory.java:268)
   at com.sun.rave.web.ui.theme.ThemeFactory.initializeThemeManager(ThemeFactory.java:231)
   at com.sun.rave.web.ui.util.ThemeUtilities.getTheme(ThemeUtilities.java:91)
   at com.sun.rave.web.ui.renderer.LabelRenderer.encodeEnd(LabelRenderer.java:144)
   at
org.netbeans.modules.visualweb.web.ui.dt.renderer.AbstractDesignTimeRenderer.encodeEnd(AbstractDesignTimeRenderer.java:74)
   at
org.netbeans.modules.visualweb.web.ui.dt.renderer.ValueHolderDesignTimeRenderer.encodeEnd(ValueHolderDesignTimeRenderer.java:108)
   at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
   at org.netbeans.modules.visualweb.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1350)
   at org.netbeans.modules.visualweb.insync.faces.FacesPageUnit.getFacesRenderTree(FacesPageUnit.java:1107)
   at org.netbeans.modules.visualweb.insync.faces.FacesPageUnit.renderHtml(FacesPageUnit.java:1675)
   at org.netbeans.modules.visualweb.designer.jsf.JsfForm.renderMarkupDesignBean(JsfForm.java:2906)
   at org.netbeans.modules.visualweb.designer.jsf.JsfForm.renderMarkupDesignBean(JsfForm.java:2902)
   at org.netbeans.modules.visualweb.designer.jsf.DomSynchronizer.processInsert(DomSynchronizer.java:1287)
   at org.netbeans.modules.visualweb.designer.jsf.DomSynchronizer.processUpdates(DomSynchronizer.java:798)
   at org.netbeans.modules.visualweb.designer.jsf.DomSynchronizer.run(DomSynchronizer.java:696)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
   at org.netbeans.core.TimeableEventQueue.dispatchEvent(TimeableEventQueue.java:104)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Comment 1 _ sandipchitale 2008-03-05 17:15:22 UTC
First question is is this supposed to work. In other words is the VW framework capable of handling NetBeans non-Web
projects? Po-ting can answer that question. Assigning this to Po-ting.

Secondly is this a defect or a feature?

Quy can you look at the respective exception in:

org.netbeans.modules.visualweb.project.jsf.api.JsfDataObjectException: Can't find corresponding java folder for

Winston, we fixed the Theme exceptions correct?
Comment 2 Quy Nguyen 2008-03-05 17:49:09 UTC
The jsfloaders directly use the JSF project apis to determine the relative locations of jsp/java files.  This is a
hardcoded location, I believe, so the loaders expect the files to conform to the following directory structure:

$somepath/web/.../*.jsp
$somepath/src/java/.../*.java

That said, it looks like the jsfloaders were able to work correctly in this case, since the DataObject was instantiated
correctly and the designer opened.
Comment 3 _ potingwu 2008-03-05 17:58:23 UTC
> org.netbeans.modules.visualweb.project.jsf.api.JsfDataObjectException: Can't find corresponding java folder for

I think there is no issue for finding the corresponding java folder. We have already resolved that long before.

Sandip, this bug is created especially for insync and/or Theme.

Maven/VisualWeb projects already have bugs filed for this maven+visualweb support. Yes, we need to support this feature
for getting more developers from non-NetBeans environment and Milos has already reached the final stage. Please see
issue#106955 and issue#113284. He just needs some minor support from us here to resolve classloader issue that may be
coming from insync.
Comment 4 _ potingwu 2008-03-07 23:01:08 UTC
I rechecked the project and found that we have some kind of regression in jsfloader, the page is not recognized.
Comment 5 _ potingwu 2008-03-07 23:29:16 UTC
The jsfloader calls JsfProjectUtils.isJsfProjectFile(JSP FILE) to see whether it's a Visual Web project or not and the
result is NO! The problem is, isJsfProjectFile is searching "nbproject/project.xml" to find
"http://www.sun.com/creator/ns" and failed.

I need to extend the API to also search "$root/nb-configuration.xml".

My question is, how do I locate the file "nb-configuration.xml"? Is it always on the project root directory?
Comment 6 _ potingwu 2008-03-08 00:05:49 UTC
I have fixed the jsfloader issue. Now this Maven Visual Web JSF page is recognized.
    changeset 7988fe879235 in main
    details: http://hg.netbeans.org/main?cmd=changeset;node=7988fe879235

Now opening the sampleproject looks much better; you will see the multi-tab editor. No any error inside the Java editor.
But switch to the designer, you will get error from insync:
    Caused: java.lang.IllegalStateException: FacesModel was not loaded for DataObject,
dataObject=org.netbeans.modules.visualweb.project.jsfloader.JsfJspDataObject@1f97f92[D:\Projects\mavenproject64\src\main\webapp\Page1.jsp]

Passing to insync for further fix.
Comment 7 _ potingwu 2008-03-08 00:07:15 UTC
Created attachment 58008 [details]
Exception when opening the designer (after the jsfloader is fixed)
Comment 8 Milos Kleint 2008-03-10 08:33:21 UTC
how do you access the http://www.sun.com/creator/ns you are looking for in nbproject/project.xml file? 
The fact if it's in the nbproject/project/xml file should not matter. The correct way of accessing your configuration is
through the AuxiliaryConfiguration class. That one should correctly delegate to nbproject/project.xml for ant projects
and to nb-configuration.xml file for maven projects..
Comment 9 _ potingwu 2008-03-10 16:59:09 UTC
Yes, it's a known limitation due to performance improvement! Originally in NB 5.5.*, Visual Web jsfloader did use
AuxiliaryConfiguration API to check whether the JSP object is under Visual Web or not. But since every check by using
this AuxiliaryConfiguration API will involve parsing an XML file which is pretty expensive. The jsfloader then
introduced a serious P1 performance issue when integrating into NB 6 (actually already in 5.5.*). We decided just simply
opening the XML file and scanning the keywork "http://www.sun.com/creator/ns".
Comment 10 _ sandipchitale 2008-03-12 19:06:16 UTC
Created attachment 58263 [details]
.java file errors
Comment 11 _ sandipchitale 2008-03-12 19:06:38 UTC
When I open Page1 I see errors in .java file. See the attached screenshot.
Comment 12 _ potingwu 2008-03-12 19:13:53 UTC
Did you also install the Visual Web Backward Compatible Kit as well? It's a JSF 1.1 project. Actually I got the warning
if I didn't.
Comment 13 _ sandipchitale 2008-03-13 02:16:45 UTC
JsfProjectUtils.hasLibraryReference(project, library, ClassPath.COMPILE) is failing for every library when the ModelSet
is using it in the getProjectClassLoader() method.

It seems to be because the maven projects classpath contains all .jar files from some 

user.home/.m2 folder

but the jars in the libraries refer to some path im modules/ext.
Comment 14 _ potingwu 2008-03-13 03:40:02 UTC
Milos, looks like the problem is caused by Maven project does not have matched pathname between the Library URL and the
ClassPath FileObject. Please see the following code that is not working for the Maven project:

    public static boolean hasLibraryReference(Project project, Library library, String type) {
        List lst = library.getContent("classpath");
        if (lst.isEmpty()) {
            return false;
        }

        URL url = (URL) lst.get(0);
        FileObject obj = URLMapper.findFileObject(url);
        if (obj == null) {
            return false;
        }

        // XXX NetBeans API not finished yet
        type = ClassPath.COMPILE;
        ClassPath cp = ClassPath.getClassPath(getSourceRoot(project), type);
        if (cp == null) {
            return false;
        }

        return cp.contains(obj);
    }
Comment 15 Milos Kleint 2008-03-13 07:02:16 UTC
yes, it never actually will. the .m2/repository path jars are the ones from local repository. That's the only path the
maven project get. ever. that's how maven works. I can't possibly reference the jars from the IDE (BTW I assume the
library you pass in is coming from shared location in case of shared ant projects.. otherwise it can break as well).


The way similar check is done in spring integration for example is to check for a particular class from the library on
the classpath and not for the specific jar url itself. That might work for you as well, but I don't know the context of
your hasLibraryReference method so it's hard to judge.
Comment 16 _ sandipchitale 2008-03-13 18:02:12 UTC
FYI: Another thing Insync relies upon is the content of volumes ("classpath" and "designtim" volume etc) inside
libraries used by the project to determine which jars should be added to the designtime Classloader.
Comment 17 _ potingwu 2008-03-13 18:21:37 UTC
*** Issue 113284 has been marked as a duplicate of this issue. ***
Comment 18 _ potingwu 2008-03-13 18:24:52 UTC
*** Issue 105218 has been marked as a duplicate of this issue. ***
Comment 19 _ potingwu 2008-03-13 21:32:24 UTC
> The way similar check is done in spring integration for example is to check for a particular class from the library on
the classpath and not for the specific jar url itself.

Please provide more details, where the Spring's codes are, for me to look into. Thanks!
Comment 20 _ potingwu 2008-03-14 19:24:10 UTC
> The way similar check is done in spring integration for example is to check for a particular class from the library on
the classpath and not for the specific jar url itself.

Do you mean Spring uses ClassPath.findResource to check the existence of a particular class? If so, then this scheme may
not work for visualweb insync!

Insync grabs all IDE libraries and tests each to see whether the individual library is used in the project, then put it
under its own classloader for the design-time visual editor.

BTW, checking the resource name is not robust because the libraries got may have wrong version. E.g., class name for JSF
1.1 has the same resource name in JSF 1.2, and then grab a wrong library! (JSF 1.1 & 1.2 libraries can be coexisted in
the IDE) I was thinking of comparing the base jar name which is not robust either, but has similar issue as comparing
resource name.
Comment 21 Milos Kleint 2008-03-17 08:50:09 UTC
org.netbeans.modules.spring.api.SpringUtilities

A rather quick check (maybe wrong) of jsf-api.jar for 1.1 and 1.2 reveals that both versions have
javax.faces.FacesException.class  but only the 1.2 version has javax.faces.TypedCollections.class. That way you can
distinguish if you dealing with jsf 1.1 or 1.2..

> Insync grabs all IDE libraries and tests each to see whether the individual library is used in the project, then put it
> under its own classloader for the design-time visual editor.

Please check your code, this might not work in 6.1 anymore with shared libraries implemented.

BTW: Why check libraries at all, why not put the complete runtime/compilation classpath of the project under the design
time classloader?

Comment 22 _ potingwu 2008-11-20 23:33:57 UTC
.