This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes bean:message throwing NPE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:message throwing NPE" Watch "bean:message throwing NPE" New topic

bean:message throwing NPE

Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Aloha ranchers,

I've been getting my feet wet with struts the past few weeks and have run into a problem. I have a few bean:message tags in my index.jsp of the webapp I'm learning with, which were working until I started getting into validation. I started getting the following:

I have the message resources defined in both web.xml and struts-config.xml (after the <action-mappings> section). The tld's are in the WEB-INF directory and I have set <taglib> in web.xml too. Strange that fmt:message *DOES* work.

I'm back at square one and not sure where else to look. I'm more curious to know why bean:message is failing in case I encounter it again rather than using fmt:message as a work around.

A lot of googling pointed at struts config problems and missing/incorrect jars. Because fmt:message is working and I'm not getting Class exceptions could it be something else?

Anyone have any ideas?


-- Nothing is impossible if I'mPossible
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
What version of Struts are you using? If it's 1.3 or above, I expect the problem is that your taglib TLDS are the wrong ones for version 1.3. In version 1.3, the TLDS are all located inside the struts-taglib-1.3.x.jar file. Your JSPs should then reference the TLDS by their namespace, rather than their physical location. Example:

As long as the struts-taglib-1.3.x.jar file is in your classpath, the above reference should work. You don't need any TLDs in WEB-INF.

Consultant, Sima Solutions
Doug Slattery
Ranch Hand

Joined: Sep 15, 2007
Posts: 294
Thanks for the reply Merrill,

I downloaded 2.0.11, which didn't come with a struts-taglib-*.jar. I did a little more looking after your reply and found from an example that it uses:

I think the error I was getting was from commingling different versions of jar files in the WEB-INF/lib directory. I've cleaned the directory and copied the distribution jars back in. I changed the bean:message tag to s:message and now I'm getting:
org.apache.jasper.JasperException: /index.jsp(20,3) No tag "message" defined in tag library imported with prefix "s"

which makes sense. Maybe I've been going too fast and didn't notice much documentation on the apache site and the distro didn't come with docs. Is there an easy way to look at the jar files to find what the uri should be and what prefixes/tags are available?


-- Nothing is impossible if I'mPossible
I agree. Here's the link:
subject: bean:message throwing NPE
Similar Threads
not able to run html:text tag of struts tld
problem with the name attribute of form tag
TagUtils. computeURLWithCharEncoding
Getting error message when calling the JSP, please help
Help Please