aspose file tools*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:message throwing NPE" Watch "bean:message throwing NPE" New topic
Author

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?

Aloha,
Doug

-- 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.


Merrill
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?

Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
 
subject: bean:message throwing NPE