title: JSF 2 Custom component annotation does not work
body: <p>Ok i've already browsed a lot of topics here but none of them solved my problem. My problem is simple: I have ultra simple custom component:</p>
  
  <pre><code>@FacesComponent("HelloWorldComponent")
  public class HelloWorldComponent extends UIComponentBase {
  
  public String getFamily() {
  return "my.custom.component";
  }
  
  @Override
  public void encodeBegin(FacesContext ctx) throws IOException {
  String value = (String) getAttributes().get("value");
  
  if (value != null) {
  ResponseWriter writer = ctx.getResponseWriter();
  writer.write(value.toUpperCase());
  }
  }
  }
  </code></pre>
  
  <p>but unfortunately i get error:</p>
  
  <pre><code>JSF1068: Cannot instantiate component with component-type HelloWorldComponent
  </code></pre>
  
  <p>My taglib:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0"&gt;
  
  &lt;namespace&gt;http://example.com/test&lt;/namespace&gt;
  &lt;tag&gt;
  &lt;tag-name&gt;helloWorldComponent&lt;/tag-name&gt;
  &lt;component&gt;
  &lt;component-type&gt;HelloWorldComponent&lt;/component-type&gt;
  &lt;/component&gt;
  &lt;/tag&gt;
  &lt;/facelet-taglib&gt;
  </code></pre>
  
  <p>The key thing is if i place my custom component in faces-config everything works perfect, but as a very stubborn greenhorn in JSF im convinced that there has to be way to make the annotations work without registering custom components in faces-config. Im expecting to have A LOT of custom components so i want to know how to make them work with pure annotations so as not to write milion lines of code in faces-config.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;faces-config xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"&gt;
  
  &lt;application&gt;
  &lt;el-resolver&gt;org.springframework.web.jsf.el.SpringBeanFacesELResolver&lt;/el-resolver&gt;
  &lt;/application&gt;
  
  &lt;!--    &lt;component&gt; --&gt;
  &lt;!--         &lt;component-type&gt;HelloWorldComponent&lt;/component-type&gt; --&gt;
  &lt;!--         &lt;component-class&gt;com.first.utils.view.components.HelloWorldComponent&lt;/component-class&gt; --&gt;
  &lt;!--     &lt;/component&gt; --&gt;
  
  &lt;/faces-config&gt;
  </code></pre>
  
  <p>When i uncomment the component tag, everything works. But literally dont want to do that, its not laziness its forcing computers to do what I WANT ;).</p>
  
  <p>My structure of project: (im using spring &amp; maven)</p>
  
  <pre><code>src  
  ~main  
  ~~java  
  ~~resources  
  ~~~META-INF  
  ~~~~faces-config.xml (duplicated as i read other topics)  
  ~~~~persistence.xml  
  ~~webapp  
  ~~~resources  
  ~~~~css  
  ~~~~utilComponent  
  ~~~WEB-INF  
  ~~~~templates  
  ~~~~faces-config.xml  
  ~~~~my.taglib.xml  
  ~~~~web.xml  
  ~~~*.html webpages..  
  </code></pre>
  
  <p>Topics i've already browsed:
  <a href="https://stackoverflow.com/questions/9684402/jsf-custom-component-is-not-found">JSF custom component is not found</a><br>
  <a href="https://stackoverflow.com/questions/6150926/cannot-find-annotated-custom-jsf2-component-in-jar">Cannot find annotated custom JSF2 component in jar</a><br>
  <a href="https://stackoverflow.com/questions/7598036/custom-component-using-jsf">Custom Component using JSF</a>  </p>
  
  <p>It would be ideal if i wouldnt have to define my taglib but i guess it is impossible? But first thing first i want to make annotations work... any help appreciated</p>