0

I am working on velocity templates to fix some issue. Am new to this technology and am having hard time fixing this issue, please help me to fix this issue.

I need to call a java class from form velocity template(.vt) file, am doing the following

Am trying to get one of our application's url by calling the java class SCProperties

<#set ($partMatchURL = $txt.display($sCProperties.getProperty("partmatch.url")))>

SCProperties class is part of com.nfsmith.util package.

Then on clicking the Partmatch(below hyperlink) it should open a window with partmatch(one of our internal application) URL.

Following is the html code for the hyperlink

<div id="sub2tab10" class="subtab" style="left: 910" 
     onClick = "javascript:window.open('$partMatchURL');" 
     onMouseOver="hoversub(this);" 
     onMouseOut="setStateSub(2,10)">
  Part Match
</div>

But a herem gettinghttp://foo.bar.com/SalesChain3/Controller/`) url and below error

Am getting 500 error after clicking on the Partmatch hyperlink

HTTP Status 500 - 
type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Unable to find resource ')'
    com.nfsmith.servlet.Controller.error(Controller.java:683)
    org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:361)
    org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:292)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


root cause 

org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource ')'
    org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceManager.java:438)
    org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:736)
    org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:718)
    org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.java:337)
    org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.java:499)
    com.nfsmith.servlet.Controller.handleRequest(Controller.java:626)
    org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:331)
    org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:292)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
5
  • You neglect to say what's actually wrong. Is $sCProperties an instance of the class you're talking about? Jun 24, 2013 at 18:48
  • $sCProperties.getProperty("partmatch.url")) is not fetching the required url.
    – OTUser
    Jun 24, 2013 at 18:58
  • Please take note of how I edited your question (again) to display properly. It's important that (a) you know how to use the SO editor if you're going to ask questions, and (b) you don't un -do other people's edits that make your post legible. Jun 24, 2013 at 19:04
  • Thanks Dave, for editing my post. I never used SO much, so i was unable to make a good question using the SO editor.
    – OTUser
    Jun 24, 2013 at 19:10
  • Can you clarify if the error occurs when you are generating the page that will contain the hyperlink, or after clicking the hyperlink? I'd experiment with printing out the various parts of the link to see where the problem is, e.g. just print $sCProperties.getProperty("partmatch.url") without wrapping it in $txt.display or setting it into another variable.
    – jfrank
    Jun 24, 2013 at 19:28

1 Answer 1

1

Your question is very hard to follow. If I'm right then the following is true:

$txt.display($sCProperties.getProperty("partmatch.url")) results in http://foo.bar.com/SalesChain3/Controller/) (including the closing bracket)

I don't know what $txt.display() is supposed to do as you haven't explained it so I'll ignore it

If $sCProperties.getProperty("partmatch.url") is responding with http://foo.bar.com/SalesChain3/Controller/) then is sounds like you are successfully calling the method you want to and that the issue is in the method itself giving the wrong result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.