This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts Configuration problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Configuration problem" Watch "Struts Configuration problem" New topic
Author

Struts Configuration problem

Joe Williams
Greenhorn

Joined: Oct 18, 2005
Posts: 6
Hi,

My application runs fine if i'm not configured the database stuf in the struts-config.xml. I'm using postgresql as db.

This is the my struts-config file

<?xml version="1.0"?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>

<data-sources>

<data-sources>
<!-- configuration for commons BasicDataSource -->
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="org.postgresql.Driver" />
<set-property property="url" value="jdbc ostgresql://localhost/TestDB" />
<set-property property="username" value="postgres" />
<set-property property="password" value="arun" />
<set-property property="maxActive" value="10" />
<set-property property="maxWait" value="5000" />
<set-property property="defaultAutoCommit" value="false" />
<set-property property="defaultReadOnly" value="false" />
<set-property property="validationQuery"
value="SELECT COUNT(*) FROM demotable" />
</data-source>
</data-sources>

</data-sources>



<form-beans>

<form-bean
name="UserFormBean"
type="coreservlets.UserRegistrationForm">
</form-bean>

</form-beans>


<!-- Global Forwards Configuration -->
<global-forwards>
<forward name="register1" path="/index.jsp"/>
</global-forwards>


<action-mappings>

<action path="/register1"
type="coreservlets.UserRegistrationAction"
name="UserFormBean"
scope="session">

<forward name="welcome" path="/WEB-INF/pages/password.jsp"/>
<forward name="success" path="/WEB-INF/pages/success.jsp"/>
<forward name="failure" path="/WEB-INF/pages/failure.jsp"/>

</action>

</action-mappings>

<!-- Message Resources Configuration -->
<message-resources
parameter="coreservlets.ApplicationResources"/>


</struts-config>

exception

javax.servlet.ServletException
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NullPointerException
coreservlets.UserRegistrationAction.execute(UserRegistrationAction.java:44)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

sgp sundar
Greenhorn

Joined: Oct 08, 2005
Posts: 3
hi,

remove one <datasources> tag

and specify the Key attribute in the datasource tag
[ October 22, 2005: Message edited by: sgp sundar ]
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
after fixing your datasource definition...like really pay attention to tag syntax, go to line 44 of your UserRegistrationAction.java and see what it's doing.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Configuration problem
 
Similar Threads
Struts Request Processor gives me Null Pointer exception
Path for Tile Does Not Start With a "/" Character
Validation error
Struts
Struts REquest Processor throws Null Pointer exception