Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 179923 - Web Beans error annotation for non CDI enabled modules
Web Beans error annotation for non CDI enabled modules
Status: RESOLVED FIXED
Product: javaee
Classification: Unclassified
Component: JSF Editor
6.x
PC Linux
: P3 (vote)
: 7.0
Assigned To: Denis Anisimov
issues@javaee
http://relation.to/Bloggers/WhyIsBean...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-01-27 08:42 UTC by Jindrich Sedek
Modified: 2011-01-14 06:07 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jindrich Sedek 2010-01-27 08:42:44 UTC
Create new Java Library and add weld-osgi-bundle.jar or some other weld jar containing javax.inject package.

Create new java class:
----------------------
package dd;
import javax.inject.Named;
@Named
public class NewClass {
    private String str = "test";
    public String getStr() {
        return str;
    }
    public void setStr(String str) {
        this.str = str;
    }
}
---------------------

Create new Web Application with javaEE 6 with CDI and JSF enabled 
add previous java library as a dependency to the Web Application
in index.xhtml type:
-------------------------
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
      <h:form id="UserEntryForm">
        <h:inputText value="#{|newClass.str}" />
        <h:commandButton action="welcome" value="OK" />
       </h:form>
    </h:body>
</html>
-----------------------
note that cc offers "newClass" at position of "|"

run project -> text field is empty, type something in, press ok -> an error appears: >>Target Unreachable, identifier 'newClass' resolved to null<<

The problem is that the java library doesn't declare being CDI enabled - having beans.xml. (create beans.xml in META-INF directory of java library and it starts working). 

The bug is that we offer this class in cc, because it's usage is not valid in this case. Not offering the class name in cc would be very non-transparent for users. It would be better to propose the name in cc, but add a warning (and possibly also a autogeneration hint) to create beans.xml file in META-INF directory of the library.

See the URL of this bug with the description how beans.xml file should work.
Comment 1 Marek Fukala 2010-01-27 08:59:01 UTC
I recon that this is a problem of the web.beans module which mark classes as web beans when it sees a class with the @Named annotation on the project's classpath. It does so regardless if modules from the classpath has the CDI enabled or not.

I'm not sure if Denis works for us or not anymore, but if he cannot fix the issue I may give it a try by some sort of classpath filtering.
Comment 2 David Konecny 2010-01-27 17:54:12 UTC
Feel free to pass webbeans(CDI) problems to me - Denis is not working on it anymore.

I agree with Jindra that code completion should list beans even from modules which are not CDI enabled. Could we mark them differently in code completion (grey?) to indicate the difference? Also using such a bean should add editor hint saying "<bean-name> will not be available in runtime because CDI is disabled for <something.jar>" and there should be autofix option "Enable CDI for <something.jar>" which would just create beans.xml.

Do you agree Marek? Should I do it or would you prefer do it all or some parts yourself? I'm not very familiar with JSF editor implementation/code completion but I can give it a try.
Comment 3 Marek Fukala 2010-01-28 02:49:01 UTC
Feel free to do it Davide. I can help you with the editor part if you want.  

If you extend the web beans API or create some reasonable utility method which can be used for mapping the web beans classes to the source jars I can do the editor part quickly. I can do it all if you are busy anyway but the truth is that I'm currently fiddling with the css/html refactoring so I would do it later.
Comment 4 Denis Anisimov 2011-01-13 12:56:53 UTC
changeset:   186107:2d3ea0c3acaf
Comment 5 Quality Engineering 2011-01-14 06:07:08 UTC
Integrated into 'main-golden', will be available in build *201101140000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/2d3ea0c3acaf
User: Denis Anisimov <ads@netbeans.org>
Log: Fixes for BZ#179923 -  Web Beans error annotation for non CDI enabled modules  and BZ#194119 -  java.util.ConcurrentModificationException at java.util.LinkedList$ListItr.checkForComodification


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo