aspose file tools*
The moose likes Struts and the fly likes struts error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts error" Watch "struts error" New topic
Author

struts error

krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
what caused this error,I have rewrote my struts-config.xml.

org.apache.jasper.JasperException: java.lang.NullPointerException: Module 'null' not found.

My struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>

<struts-config>

<form-beans>
<form-bean name="messageFormBean"
type="test.MessageFormBean"/>
</form-bean>

<action
path="/messageLogin"
type="test.MessageActionClass"
name="messageFormBean"
scope="request"
<forward name="path"
path="/WEB-INF/view/messageSuccess.jsp"/>
</action>

<message-resources parameter="MessageResources" />
<message-resources parameter="TestMessageResources"
null="false" />

</struts-config>


My JSP

<%@ taglib uri="http://struts.apache.org/tags-bean"
prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html"
prefix="html" %>
<html>
<head>
<Title> Login </title>
</head>
<body>
<Center>
<html:form action="/messageLogin">
<bean:message key="form.firstName" /> :
<html:text property="firstName"/><br>
<bean:message key="form.lastName" /> :
<html:text property="lastName"/><br>
<bean:message key="form.emailID" /> :
<html:text property="emailID"/><br>
<html:submit>
Submit
</html:submit>
</html:form>
</center>
</body>
</html>


have a great day,
krishna prasad
krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
There is a slight change in 'My struts-config.xml'. sorry, <action-mappings> is missing in 'My struts-config.xml' in the above question. But <action-mappings> is present in my origianl struts-config.xml. so that may not have caused the error. so what caused the error?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I can see at least two errors: There is no closing </form-beans> tag. Also, at least one of your <message-resources> stanzas must have a key attribute. Also check out question 10 in the JavaRanch Struts FAQ.

Thanks for being up front about the fact that your post didn't accurately represent what's in your config file. However, this brings up a "pet peeve" of mine, so forgive while I unload a little.

For a person trying to be helpful, having spent some time searching through a post for some minute detail that might be the cause of someone's problem, then finally finding something and pointing it out, there's nothing more irritating than being told "Oh, yeah, I just copied it wrong into my post. That's not the problem. Can you help me find the real problem?"

If you're going to ask other developers to spend their time looking for problems in your code, don't you think you at least owe them the courtesy of taking the time to make sure the code you put in your post accurately represents the code that's causing you the problem?
[ March 11, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
jay roy
Ranch Hand

Joined: Nov 16, 2006
Posts: 145
>>><html:form action="/messageLogin">

also in above tag, you might want to include what method you want to call in the servlet :get or post.

if its get
<html:form action="/messageLogin" method="get">

if its post
<html:form action="/messageLogin" method="post">

post is most commonly used.
krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
sorry Merrill, I would take utmost care, not to repeat that mistake again. By the way, what did you mean by this:

'Also, at least one of your <message-resources> stanzas must have a key attribute.'

and what does DTD stands for?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You cannot have two <message-resources> tags in the same struts-config file unless one of them is defined by a key attribute. Example:

In the above example, "MessageResources" is the default message resource, and the "TestMessageResources" is a secondary resource. In order to reference a secondary resource, you must specify a bundle attribute. So, for example, if I want to reference a message in the "TestMessageResources", I would specify the following:

For more detailed information on this, see this link.
what does DTD stand for?

A DTD (Data Type Definition) is the governing document for an XML file. It declares the rules for what elements can be in the XML file, their frequency, and the order in which they appear. If your Struts-config.xml file does not conform to the rules in the DTD file declared at the top of the document, Struts will throw an exception stating that it cannot parse the XML file.
krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
could you please tell me where the DTD file and all the declarations are.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
At the beginning of your struts-config.xml file, you should have a declaration that looks like this:

The last line of this declaration is a real URI that points to the location of the DTD. You can use your browser to download it. The DTD declared is dependent on the version of Struts you're using. If you're using version 1.2.x, then the DTD will be different. Since I'm using 1.3.8, the DTD is declared as version 1.3.

Here's a tip: I almost never create a struts-config.xml file from scratch. I'd recommend that you unzip the struts-blank.war file that came with the download and copy the struts-config.xml file found in that application into your application and use it as a template for your config file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts error