metamug / mason

REST APIs with JSP tags, SQL and much more.
https://metamug.github.io/mason
Other
26 stars 10 forks source link

Unable to find taglib [m] for URI: [mtg-mason.tld] #122

Closed d3ep4k closed 4 years ago

d3ep4k commented 4 years ago

With 3.4 we get this error Unable to find taglib [m] for URI: [mtg-mason.tld]

<dependency>
  <groupId>com.metamug</groupId>
  <artifactId>mason</artifactId>
  <version>3.4</version>
</dependency>

mason init used is

<jsp:directive.page pageEncoding="UTF-8" trimDirectiveWhitespaces="true"
    errorPage="/WEB-INF/resources/error/errorpage.jsp"/>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@taglib uri="http://xml.metamug.net/jsp/jstl/mason" prefix="m" %>

<m:resource>

    <m:request method="GET" item="true">
       <sql:query var="result" dataSource="${datasource}">
          SELECT * FROM movie where id = $id
       </sql:query>
       <c:set target="${output}" property="output" value="${result}"/>
    </m:request>

</m:resource>
d3ep4k commented 4 years ago

The cause of this issue has been trying to use $ variables similar to metamug resource file which will ofcouse not work.

<jsp:directive.include file="../fragments/mason-init.jspf"/>

<m:resource>

     <m:request method="GET" item="true">
        <sql:query var="result" dataSource="${datasource}">
              SELECT * from movie where id=?
        <sql:param value="${mtgReq.id}"/>
        </sql:query>
        <c:set target="${output}" property="getReq2"  value="${result}"/>
    </m:request>

</m:resource>
d3ep4k commented 4 years ago

Got this issue when typecasting

<m:resource>
    <m:request method="GET">
        <m:execute className="com.example.RequestHandler" var="getCustomer" output="true">
            <m:arg name="id" value="618" />
        </m:execute>
    </m:request>        
</m:resource>
customer.setId((int)args.get("id"));

Fixed it by correctly converting string to integer

customer.setId(new Integer((String)args.get("id")));