9 Replies Latest reply on Aug 21, 2012 4:26 AM by martsecurit

    Taglib in module not loaded for JBoss 7

    juanm_med

      Hi,

       

      I'm trying to use Tiles in a web application with Jboss 7.0.1. I added

      the necessary modules for Tiles to get loaded, but when I try to show

      a page, the "http://tiles.apache.org/tags-tiles" taglib is not recognized.

       

      At web.xml, I added the listener and the servlet, which work fine:

       

         <listener>

          <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>

         </listener>

         <servlet>

          <servlet-name>Tiles Dispatch Servlet</servlet-name>

          <servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>

         </servlet>

         <servlet-mapping>

          <servlet-name>Tiles Dispatch Servlet</servlet-name>

          <url-pattern>*.tiles</url-pattern>

         </servlet-mapping>

       

      In my page, I declared the taglib:

       

         <html xmlns="http://www.w3.org/1999/xhtml"

              xmlns:h="http://java.sun.com/jsf/html"

              xmlns:f="http://java.sun.com/jsf/core"

              xmlns:ui="http://java.sun.com/jsf/facelets"

              xmlns:tiles="http://tiles.apache.org/tags-tiles">

       

      Finally in one of my modules, I have tiles-jsp-2.2.2.jar with the taglib:

       

           <tlib-version>1.2</tlib-version>

           <short-name>tiles</short-name>

           <uri>http://tiles.apache.org/tags-tiles</uri>

       

      The tiles module is referenced by the application. I added the following

      configuration at the pom.xml:

       

      <plugin>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-war-plugin</artifactId>

                <version>2.1.1</version>

                <configuration>

          <archive>

            <manifestEntries>

              <Dependencies>org.apache.tiles</Dependencies>

            </manifestEntries>

          </archive>

                </configuration>

      </plugin>

       

      I know that tiles is referenced because, if I delete the configuration

      section above, the application doesn't deploy since some referenced

      libraries are not present.

       

      Shouldn't the taglib be automatically loaded as I include the

      module as a dependency?

       

      Attached to this message, you will find the modules and the test

      application. After having added the modules and deployed the

      application, you can see the result at:

       

      http://localhost:8080/webapplication

       

      The result is rather explicit:

       

      Warning: This page calls for XML namespace

      http://tiles.apache.org/tags-tiles declared with prefix tiles but no

      taglibrary exists for that namespace.

       

      Thank you for your help.

        • 1. Re: Taglib in module not loaded
          rhusar

          Juan, without looking at the issue you should download JBoss AS 7.0.2 instead of the 7.0.1 :-)

          • 2. Re: Taglib in module not loaded
            juanm_med

            Thank you Radoslav.

             

            I did switch to AS 7.0.2, but the problem continues exactly the same.

            • 3. Re: Taglib in module not loaded for JBoss 7
              juanm_med

              For those who have a similar problem, see the related issue. It's necessary to include the TLD in the webapp.

              • 4. Re: Taglib in module not loaded for JBoss 7
                eduardo.mello.cantu

                I have a similar problem, my application is not including richfaces tags witch is "modularized". I've tried to put tlds on my webapp but with no success.

                • 5. Re: Taglib in module not loaded for JBoss 7
                  sfcoy

                  It's worth noting that taglibs are only "discovered" automatically when they are contained in jars that are deployed in the WEB-INF/lib directory.

                   

                  If you deploy them anywhere else, including inside the EAR somewhere or as a JBoss module, then you must add correct tld files somewhere in the WEB-INF directory tree (excluding WEB-INF/classes and WEB-INF/lib).

                  • 6. Re: Taglib in module not loaded for JBoss 7
                    eduardo.mello.cantu

                    Okay, let me see if I understand.

                     

                    I have an application packed like this:

                     

                    app.ear

                    -META-INF

                    --jboss-deployment-structure.xml

                    -app.war

                    --web-inf

                    ---all-richfacfes.tld

                    ---lib

                    ----jsf-facelets.jar

                     

                    On jboss-deployment-structure.xml it's defined a dependency on richfaces modules that i've created, so it's expected that my application can use richfaces tags normally. Is that right?

                    • 7. Re: Taglib in module not loaded for JBoss 7
                      sfcoy

                      Sorry, I did not spot that you were using facelets. The rules for discovery of facelets taglibs are slightly different and you should probably check out §10.3.2 of the JSF 2.0 Spec.

                       

                      You're not mixing JSP taglibs and Facelets taglibs are you?

                      • 8. Re: Taglib in module not loaded for JBoss 7
                        eduardo.mello.cantu

                        Actually I am, but in different places, not on the same page.

                         

                        I've added a jar with the richfaces taglib.xml on the meta-inf dir within the web-inf/lib of my webapp, then i got this:

                         

                        /login.xhtml @31,57 template="layout/edit.xhtml" object is not an instance of declaring class

                         

                        Message was edited by: Eduardo Mello Cantú

                        • 9. Re: Taglib in module not loaded for JBoss 7
                          martsecurit

                          Hello.

                           

                          I find this a little confusing:

                           

                           

                          Stephen Coy wrote:

                           

                          It's worth noting that taglibs are only "discovered" automatically when they are contained in jars that are deployed in the WEB-INF/lib directory.

                           

                          If you deploy them anywhere else, including inside the EAR somewhere or as a JBoss module, then you must add correct tld files somewhere in the WEB-INF directory tree (excluding WEB-INF/classes and WEB-INF/lib).

                          So if they are not going to be deployed in a jar in the WEB-INF/lib directory then I must include a .tld file in the root of WEB-INF directory but not in WEB-INF/classes.  The only thing I have working 50% so far is having the .tld file in the WEB-INF/classes directory, as it is not found in the WEB-INF directory and I have this .tld referenced within my web.xml file. This is ok as it then finds and parses the tld file but then when the tag is called I receive a cannot find URI for the tag lib!

                           

                          This is all frustrating as works fine in WebSphere.

                          Can you clarify what I should deploy where?

                           

                          thanks for reading.

                           

                          Edit

                          I got this working by storing the .tld file in the WEB-INF root and referencing it in the web.xml file thus:

                          <jsp-config>

                            <taglib>

                                   <taglib-uri>http://myURI/jstl/mytag</taglib-uri>

                                   <taglib-location>/WEB-INF/mytag.tld</taglib-location>    

                          </taglib>

                          </jsp-config>