Announcement Announcement Module
No announcement yet.
Faces: taglibs configure problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Faces: taglibs configure problem


    During configuring JSF on Spring DM I encountered problems with taglibs.
    It turn out that not all taglibs from existings JSF components library are registered (from RichFaces for examples).
    I started to investigate and found the reason.

    Every JSF taglibs are defined at faces-config.xml so first of all, com.sun.faces is looking for faces-config.xml files.
    Metod, which do it is com.sun.faces.config.ConfigManager.getConfigDocume nts(ServletContext sc)

    As you can see at ConfigManager class, there are several resource providers.
    The important for our problem is MetaInfResourceProvider
    This provider is looking for files faces-config.xml at META-INF directories.
    There is a method of this provider (I use

        public List<URL> getResources(ServletContext context) {
                SortedMap<String, URL> sortedJarMap = new TreeMap<String, URL>();
                //noinspection CollectionWithoutInitialCapacity
                List<URL> unsortedResourceList = new ArrayList<URL>();
                try {
                    for (Enumeration<URL> items = Util.getCurrentLoader(this)
                         items.hasMoreElements();) {
                        URL nextElement = items.nextElement();
                        String jarUrl = nextElement.toString();
                        String jarName = null;
                        int resourceIndex = jarUrl.indexOf(META_INF_RESOURCES);
                        // If this resource has a faces-config file inside of it
                        // and is within a JAR.  Classpath resources not included
                        // within a JAR will not be sorted.
                        if (resourceIndex != -1 && "jar".equals(nextElement.getProtocol())) {
                            // Search backwards for the previous occurrence of File.SEPARATOR
                            int sepIndex = resourceIndex - 2;
                            char sep = ' ';
                            while (0 < sepIndex) {
                                sep = jarUrl.charAt(sepIndex);
                                if ('/' == sep) {
                            if ('/' == sep) {
                                jarName =
                                      jarUrl.substring(sepIndex + 1, resourceIndex - 2);
                        if (null != jarName) {
                            sortedJarMap.put(jarName, nextElement);
                        } else {
                            unsortedResourceList.add(0, nextElement);
                } catch (IOException e) {
                    throw new FacesException(e);
                // Load the sorted resources first:
                List<URL> result =
                     new ArrayList<URL>(sortedJarMap.size() + unsortedResourceList.size());
                for (Map.Entry<String, URL> entry : sortedJarMap.entrySet()) {
                // Then load the unsorted resources
                return result;
    URL for bundle resources at Spring DM Server looks like this one for example:

    So, this method find such resources, extract jar name and then put found URL to the HashMap under jar name key. The problem is that name of jar of our URL for differ bundles is the same: bundlefile
    As you can guess, every resources are put into the HashMap under the same key: bundlefile. This causes that only one face-config.xml is registered even if you have many of component libraries.

    The only solution of this problem is to rewrite method getResource of class MetaInfResourceProvider. It should be done at OSGI bundle Bundles repository should offers libraries adjusted to OSGI enviroment.

  • #2
    Moved to dmServer forum.