How to Solve Error Message XML Parsing Error: prefix not bound to a namespace when running Java Web Application using Primefaces Framework

Posted on

Introduction

This is another article which is showing about how to solve a specific error message. Actually, this is an error appear in an attempt to use AdminFaces in the Java web application. Before going on further, there are several articles which is important before getting on to use AdminFaces in the Java web application. First of all, the article with the title of ‘How to Create maven-based Web Application in NetBeans IDE’ in this link. The second one, it is an article in this link with the title of ‘How to Add JSF Library to a maven-based Web Application in NetBeans IDE’. That article is giving an information about how to create a maven-based Java web application. By reading that article, it will give an information about how to add a JSF library to the Java web application. The last one, it is article in this link with the title of ‘How to Add Primefaces Library to a maven-based Java Web Application in NetBeans IDE’. In that last article, there is a reference for adding Primefaces framework to the Java web application.

  1. First of all, Create a new file with the name of ‘index.html’. By normal, the following is the original content after creating the file :

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
    Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/XHtml.xhtml to edit this template
    -->
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head> 
           <title>TODO supply a title</title>
           <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        </head>
        <body>
           <div>TODO write content</div>
        </body>
    </html>
    
  2. Next after, just remove all the content of the file except for the first top line as follows :
    <?xml version="1.0" encoding="UTF-8"?>
  3. Before getting on to use the AdminFaces, just add the additional tag of ‘ui:composition’. Since using the AdminFaces is possible by utilizing the template mechanism, ‘ui:composition’ tag allow to use a template from AdminFaces. The following is the declaration of the template using ‘ui-composition’ tag :
    <?xml version="1.0" encoding="UTF-8"?>
    <ui:composition>
    </ui:composition>
    

    Actually, the above line will trigger an error message as it appear in the following page :

    "<yoastmark

Solve Error Message XML Parsing Error: prefix not bound to a namespace

So, the error message above appear in the middle of the process to use AdminFaces in the Java web application. It is the first attempt to do it. In this context, all of the process exist above in the previous part including the step for creating a new XHTML file is using a NetBeans IDE. However, in this part, the focus is just to solve the error message appear as exist in the previous part. Actually, the error message is referring to the declaration of the ui:composition tag. The triggering error message as in the output above informing the unknown prefix of ‘ui’ which does not have any namespace bound to it. So, the solution is to define the namespace for the prefix. Revise the ‘index.xhtml’ file as follows :

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets">
</ui:composition>

The following is the working one as follow in the image :

How to Solve Error Message XML Parsing Error: prefix not bound to a namespace when running Java Web Application using Primefaces Framework
How to Solve Error Message XML Parsing Error: prefix not bound to a namespace when running Java Web Application using Primefaces Framework

One thought on “How to Solve Error Message XML Parsing Error: prefix not bound to a namespace when running Java Web Application using Primefaces Framework

Leave a Reply