2 Replies Latest reply on Feb 20, 2013 6:42 AM by michele mazzei

    How can I export a .tld file from a jboss-module?

    michele mazzei Newbie

      Hi to all,

      I'm trying to port a spring-mvc based war to jboss AS7.

      I've done the following steps:

      1. I created a spring module as below:

       

      <module xmlns="urn:jboss:module:1.1" name="org.springframework">

          <resources>

      ....

             <resource-root path="spring-context-support-3.2.0.RELEASE.jar"/>

      ....

                  <resource-root path="spring-webmvc-3.2.0.RELEASE.jar"/>

      ....

          </resources>

          <dependencies>

                <module name="org.jboss.vfs" export="true"/>

                <module name="javax.servlet.api" export="true"/>

                <module name="javax.servlet.jsp.api" export="true"/>

                <module name="javax.servlet.jstl.api" export="true"/>

              <module name="javax.api" export="true"/>

              <module name="org.apache.log4j" export="true"/>

              <module name="org.antlr" export="true"/>

              <module name="org.dom4j" export="true"/>

              <module name="org.hibernate" export="true"/>

              <module name="javax.persistence.api" export="true"/>

              <module name="org.javassist" export="true"/>

              <module name="org.jboss.logging" export="true"/>

              <module name="javax.transaction.api" export="true"/>

          </dependencies>

      </module>

       

      2. I deployed my springmvc based application in a WAR using the following deployment structure:

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

                <deployment>

                          <dependencies>

                                    <module name="com.h2database.h2" />

                                    <module name="org.codehaus.jackson.jackson-core-asl" />

                                    <module name="org.codehaus.jackson.jackson-mapper-asl" />

                                    <module name="org.slf4j" />

                                    <module name="org.springframework">

                                              <imports>

                                                             <include path="META-INF**" />

                                                             <include path="org**" />

                                              </imports>

                                    </module>

                          </dependencies>

                </deployment>

      </jboss-deployment-structure>

       

       

      The problem is that it does not work because the jsp pages cannot read the tld (tag libraries) include in spring-mvc.jar and located under META-INF directory.

      I declared to include all files under META-INF directory:

        <imports>

             <include path="META-INF**" />

             <include path="org**" />

        </imports>

       

      But the error is :

       

      org.apache.jasper.JasperException: The absolute uri: http://www.springframework.org/tags/form cannot be resolved in either web.xml or the jar files deployed with this application

      org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)

      org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)

      org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)

      org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:239)

      org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:152)

      ...

      11:24:51,486 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/springmvc].[jboss-as-kitchensink]] (http--127.0.0.1-8080-2) Servlet.service() for servlet jboss-as-kitchensink threw exception: org.apache.jasper.JasperException: The absolute uri: http://www.springframework.org/tags/form cannot be resolved in either web.xml or the jar files deployed with this application

              at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51) [jbossweb-7.0.13.Final.jar:]

       

       

       

       

      Where am I wrong?

      How can I instruct Jboss-Modules to export *.tld files?

      The files missing are:

      META-INF/spring-form.tld

      META-INF/spring.tld

       

      Of course, I can bypass the problem removing spring-webmvc.jar from the module and putting it inside the war, but I would like to try to solve this problem

      making my application completed modularized.

       

      Thanks

      Michele

        • 1. Re: How can I export a .tld file from a jboss-module?
          michele mazzei Newbie

          I found a same problem in:

          https://community.jboss.org/thread/196133

           

          And answered :

           

          Right now JBoss conforms to the spec, in that taglib tlds are only automatically found in jars in the WEB-INF/lib directory.

           

          You could extract the various Spring tlds and add them to each webapp in your build process.

           

          Check the spec or a JSP book on where to put them.

           

          Thus the only working solution is to put the tag files inside the war: it works but it is not a good solution.

          • 2. Re: How can I export a .tld file from a jboss-module?
            michele mazzei Newbie

            I found a simple solution:

            try to extract all tld files and put them inside the WEB-INF directory automatically using Maven:

             

               <plugin>

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

                <artifactId>maven-dependency-plugin</artifactId>

                <executions>

                 <execution>

                  <id>extract-tld</id>

                  <phase>generate-resources</phase>

                  <goals>

                   <goal>unpack</goal>

                  </goals>

                  <configuration>

                   <artifactItems>

                    <artifactItem>

                     <groupId>org.springframework</groupId>

                     <artifactId>spring-webmvc</artifactId>

                     <version>${version.spring}</version>

                     <outputDirectory>src/main/webapp/WEB-INF</outputDirectory>

                     <includes>META-INF/*.tld</includes>

                    </artifactItem>

                   </artifactItems>

                  </configuration>

                 </execution>

                </executions>

               </plugin>

             

             

            It works perfectly!

            And the spring-webmvc.jar is loaded using the module definition.

            Bye.

            Michele