Problem running PetClinic in JRun4
hi all,
i'm a newbie to Spring. I downloaded Spring 1.1.1. I'm currently trying to install the PetClinic demo but i'm getting a pageContext error. I'm not sure how to fix this, please help! Thank you.
Internal error
** Root cause is: Compiler errors: Found 1 semantic error compiling "C:/JRun4/servers/SpringSamples/default-ear/petclinic-war/WEB-INF/jsp/jrun__WEB2dINF__jsp__findOwners2ejsp1b.java": 61. status = (org.springframework.web.servlet.support.BindStatu s) pageContext.findAttribute("status"); <----> *** Error: No entity named "status" was found in this environment. jrunx.compiler.DefaultCFE: Compiler errors: Found 1 semantic error compiling "C:/JRun4/servers/SpringSamples/default-ear/petclinic-war/WEB-INF/jsp/jrun__WEB2dINF__jsp__findOwners2ejsp1b.java": 61. status = (org.springframework.web.servlet.support.BindStatu s) pageContext.findAttribute("status"); <----> *** Error: No entity named "status" was found in this environment. at jrunx.compiler.JavaCompiler.compile(JavaCompiler.j ava:135) at jrunx.compiler.JavaCompiler.compile(JavaCompiler.j ava:94) at jrun.jsp.Translator.compilePage(Translator.java:17 6) at jrun.jsp.Translator.translate(Translator.java:254) at jrun.jsp.Translator.translate(Translator.java:101) at jrun.jsp.JSPEngine.translateJSP(JSPEngine.java:693 ) at jrun.jsp.JSPServlet.translate(JSPServlet.java:125) at jrun.jsp.JSPServlet.service(JSPServlet.java:113) at jrun.servlet.ServletInvoker.invoke(ServletInvoker. java:91) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvok erChain.java:42) at jrun.servlet.JRunRequestDispatcher.invokeNext(JRun RequestDispatcher.java:449) at jrun.servlet.JRunRequestDispatcher.forwardInvoke(J RunRequestDispatcher.java:418) at jrun.servlet.JRunRequestDispatcher.forward(JRunReq uestDispatcher.java:175) at org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:91) at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:241) at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:678) at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:562) at org.springframework.web.servlet.FrameworkServlet.s ervice(FrameworkServlet.java:321) at javax.servlet.http.HttpServlet.service(HttpServlet .java:853) at jrun.servlet.ServletInvoker.invoke(ServletInvoker. java:91) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvok erChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequ estDispatcher.java:249) at jrun.servlet.ServletEngineService.dispatch(Servlet EngineService.java:527) at jrun.servlet.http.WebService.invokeRunnable(WebSer vice.java:168) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRu nnable(ThreadPool.java:457) at jrunx.scheduler.WorkerThread.run(WorkerThread.java :66) Cookies:
me too! (I hate these types of posts)
I really hate seeing 'me, too!' posts, when they don't add any new information to the problem discussion...
HOWEVER, I do feel that I need to register my vote for a resolution of this issue, since it's holding up a very aggressive deadline I have at work. I haven't dug into the taglib sources yet to take a stab at fixing it - that's my next move, but I will contribute this information for starters:
I'm having this problem (the 'status' pagecontext attribute not being bound) from within MY OWN webapp, wherein I'm using the spring:bind tag. So, it's not specific to the jPetclinic. Also, I'm using spring-1.0.2 rather than spring-1.1.x so it's pervasive throughout the versions apparently.
Anyway, there's my 2-cents, and now I'm off to dig into the sources.
Thanks for any help you can offer.
-john
Eureka! Found the problem, and I have a workaround.
The problem is that JRun 4 mishandles the <variable> element in the spring TLD.
Here is the relevant bug information on the Macromedia site:
http://tinyurl.com/6axfb
As you can see, this thread took place in 2001...apparently either the bug didn't actually get filed, or it hasn't been resolved. I have confirmed that this bug still exists in JRun 4 Update 4, and that the workaround given in the support thread works.
Here is the workaround:
Modify the spring.tld file (embedded in the spring.jar archive) to have a <declare>true</declare> sub-element within each <variable/> element...it will look similar to this:
Code:
<tag>
<name>hasBindErrors</name>
<tag-class>org.springframework.web.servlet.tags.BindErrorsTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides Errors instance in case of bind errors.
</description>
<!-- Note: Was "Integer count" in earlier version -->
<variable>
<name-given>errors</name-given>
<variable-class>org.springframework.validation.Errors</variable-class>
<declare>true</declare>
</variable>
<!-- Note: Now one Errors instance per bind object -> name of object needed -->
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>bind</name>
<tag-class>org.springframework.web.servlet.tags.BindTag</tag-class>
<body-content>JSP</body-content>
<description>
Provides BindStatus object for the given bind path.
</description>
<!-- Note: Was "bind" in earlier version -->
<variable>
<name-given>status</name-given>
<variable-class>org.springframework.web.servlet.support.BindStatus</variable-class>
<declare>true</declare>
</variable>
<!-- Note: Was "value" in earlier version -->
<attribute>
<name>path</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>htmlEscape</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
Note the <variable> elements in this snippet. Once I modified the TLD to include <declare>true</declare>, everything magically worked.
I'll be filing a support request in Spring to add this element, since it will make the library more compatible without compromising correctness.
Enjoy!
-john[/url]