This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Baffling NPE in <c:forEach  RSS feed

 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Working fine for me. What have you placed into app scope?
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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

 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • 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: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Cyrille Le Clerc
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!