• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Baffling NPE in <c:forEach

 
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting a NPE exception, only for the ${applicationScope} loop.
The rest work fine.




It seems to be the ${entry.value} is blowing up. Changing it to
${entry} still causes the NPE.

I dont' see how ${entry} can be null in the forEach iteration.
What am I doing wrong?
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Working fine for me. What have you placed into app scope?
 
Pat Farrell
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Working fine for me. What have you placed into app scope?



If I knew, I could fix it, right?

Here is what I get from EL on that part.


Application Scope: com.sun.appserv.tld.map
com.sun.jsp.tldUriToLocationMap
com.sun.jsp.tagFileJarUrlsCache
jspx.1st.request
repdrawingbase
javax.servlet.context.tempdir
com.sun.appserv.jsp.resource.injector
com.sun.jsp.taglibraryCache
org.apache.catalina.resources
org.glassfish.jsp.isStandaloneWebapp
ptoquery
org.apache.catalina.jsp_classpath
McpParameters
org.glassfish.servlet.habitat
org.glassfish.jsp.monitor.probeEmitter
javax.servlet.context.orderedLibs
timezonelist
com.sun.appserv.tldlistener.map
staticurl
com.sun.faces.useMyFaces

 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does it give you a stack trace for the null pointer exception pointing out the rogue class?

My bet would be on one of the custom application attributes you have put into scope (ie those without a package/qualified namespace)
- repdrawingbase
- ptoquery
- McpParameters
- timezonelist
- staticurl

Could the toString() method of any of these objects produce a null pointer exception?

 
Pat Farrell
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's my guess as well. The stackdump is not useful. And Netbeans doesn't want to set breakpoints in the generated java code for the JSP.

I don't understand how the ${entry} can be null and the problem, when it lists out the ${entry.key}

I'll look at the toString() and if that fails, start removing items from the context
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
entry is not likely null at any time. But the default action is to emit the string equivalents of the key and value. So as Stephan pointed out, the toString()'s of any of the entry keys or values can cause this issue if they NPPE.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I faced the same NPE with Jetty 7.6, it is caused by calling toString() on servletContext.getAttribute("com.sun.jsp.taglibraryCache") which returns a java.util.concurrent.ConcurrentHashMap.

The stack trace is :


Hope this helps,

Cyrille
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic