• Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts Configuration problem

 
Joe Williams
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!