Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF 2.1.13 custom component not found: Tag Library supports namespace: <namsepace> but no tag was defined for name: <compositecomponent>

Problem

I am using JSF 2.1.13 to create a prototype to demostrate the benefits of JSF over our current webapp built with JSP and struts 1.1. I following code using works with JSF 2.2.6, but I had to down grade once I found out that Oracle Weblogic 12c doesn't support JSF 2.2 yet. When running the code with 2.1.13 I receive the following error:

/pages/sites/tab-details.xhtml @27,90 <ccc:codedType> Tag Library supports namespace: http://java.sun.com/jsf/composite/ccc, but no tag was defined for name: codedType

Googling only pointed me to a bug about nested composite components, but that isn't something I'm doing.

Code

Excerpt from pom.xml

<!-- JSF Dependencies -->
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>2.1.13</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.1.13</version>
</dependency>

Composite Compontent: webapp/WEB-INF/resources/ccc/codedType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:component xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:cc="http://java.sun.com/jsf/composite">
  <cc:interface shortDescription="Renders a CodedType">
    <cc:attribute name="value" required="true"
      shortDescription="Instance of CodedType to be properly rendered"
      type="company.prototype.uireplacement.presenter.CodedType" />
    <cc:attribute name="includeCode"
      shortDescription="Whether or not the rendeder type should include the code"
      type="boolean" default="false"/>
  </cc:interface>

  <cc:implementation>
    <span id="#{cc.attrs.id}">#{cc.attrs.value.label}<ui:fragment rendered="#{cc.attrs.includeCode}"> (#{cc.attrs.value.code})</ui:fragment></span>
  </cc:implementation>
</ui:component>

Page using composite component: webapp/pages/sites/tab-details.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:ccc="http://java.sun.com/jsf/composite/ccc">

      <ccc:codedType value="#{siteControllerBean.selectedSite.type}" includeCode="true"/>
</ui:composition>
like image 447
pgreen2 Avatar asked Jul 17 '14 22:07

pgreen2


1 Answers

After more digging I found what caused my error. Note the location of my compontent: webapp/WEB-INF/resources/ccc/codedType.xhtml. The appropriate location should be webapp/resources/ccc/codedType.xhtml (root vs WEB-INF). In JSF 2.2, they allowed the location to be configurable and I had the following in my web.xml:

<context-param>
  <param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
  <param-value>/WEB-INF/resources</param-value>
</context-param>

which is why things worked in JSF 2.2.

The fix for my situation was to remove javax.faces.WEBAPP_RESOURCES_DIRECTORY since it isn't used in JSF 2.1 and move the resources to the root.

like image 126
pgreen2 Avatar answered Nov 15 '22 00:11

pgreen2