Saturday, 16 June 2012

Grails exception when rendering a view: java.util.EmptyStackException

So I was getting this exception after a change in my view page:

 Stacktrace follows: 

 java.lang.RuntimeException: Error initializing GroovyPageView 

      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 

      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 

      at java.lang.Thread.run(Thread.java:662) 

 Caused by: java.util.EmptyStackException 

      at java.util.Stack.peek(Stack.java:85) 

      ... 3 more  

This is what I added:

                               <div id="positive-review"> 

                                    <img 

                                         src="${resource(dir: 'images', file: 'Thumbs_up_icon_sm.jpg')}" 

                                         width="38px" height="38px"></img> <span>${reviewCountsMap['1']}</span> 

                               </div> 

                               <div id="neutral-review"> 

                                    <img src="${resource(dir: 'images', file: 'Icon_neutral.png')}" 

                                         width="38px" height="38px"></img> <span>${reviewCountsMap['0']]}</span> 

                               </div> 

                               <div id="negative-review"> 

                                    <img 

                                         src="${resource(dir: 'images', file: 'thumbs-down-icon.jpg')}" 

                                         width="38px" height="38px"></img> <span>${reviewCountsMap['-1']}</span> 

                               </div>  

Notice the error? It's an extra square bracket after reviewCountsMap['0]! Remove it and you'll be fine.

No comments:

Post a Comment