PDA

View Full Version : Values are not inserted in the database


christopher1234
Jan 7th, 2008, 01:52 PM
I have everything running after hours and days of debugging. I think some people have this problem when they started learning springframework and i am one of those.

I am doing a simple insert command to mysql database. I have created a form where the user is suppose to enter item, quantity and id. date and timestamp values are automatically inserted using current timestamp and current date.

My problem now is that why my values are not displaying on my page + its not even updating the database. I checked the log file it loads all the library + my jdbc driver also. but its not executing my insert sql command.

here is my insertQuantityOnHandForm.jsp

<%@ include file="/WEB-INF/jsp/include.jsp" %>
<html>
<head>
<title>Insert Quantity On Hand</title>
</head>
<body>
<P>
<FORM name = "insertQuantityOnHandForm" method="POST" action = "insertQuantityOnHandForm.htm">
<spring:nestedPath path="insertQuantityOnHand">
<B>Item Number:</B>
<spring:bind path="itemNumber">
<BR><INPUT type="text" maxlength="30" size="30" name="itemNumber" value="<c:out value="${status.value}"/>" >
</spring:bind>
<P>
<B>Vendor Id:</B>
<spring:bind path="vendorId">
<BR><INPUT type="text" maxlength="5" size="30" name="vendorId" value="<c:out value="${status.value}"/>" >
</spring:bind>
<P>
<B>Quantity:</B>
<spring:bind path="quantity">
<BR><INPUT type="text" maxlength="30" size="30" name="quantity" value="<c:out value="${status.value}"/>" >
</spring:bind>
<P>
</spring:nestedPath>
<INPUT type = "submit" value="Insert QOH" />
</FORM>
<P>
<BR>
</P>

<P>
<H2>Entry:</H2>
<TABLE border="1">
<TH>Item Number</TH><TH>Vendor Id</TH><TH>Inventory Date</TH><TH>Inventory Update Datetime</TH><TH>Quantity</TH>
<c:forEach var="insertQuantityOnHand" items="${selections}">
<TR>
<TD><c:out value="${insertQuantityOnHand.itemNumber}"/></TD>
<TD><c:out value="${insertQuantityOnHand.vendorId}"/></TD>
<TD><c:out value="${insertQuantityOnHand.inventoryDate}"/></TD>
<TD><c:out value="${insertQuantityOnHand.inventoryupdateDateTime}"/></TD>
<TD><c:out value="${insertQuantityOnHand.quantity}"/></TD>
</TR>
</c:forEach>
</TABLE>
<P>
<BR>
</body>
</html>


I wanted tp show the values on the same page but everytime i do that i get a BindException error so i redirected my ModelandView to my result page. Anyways here is my addInsertQuantityOnHand.jsp


<%@ include file="/WEB-INF/jsp/include.jsp" %>
<html>
<head>
<title>Results for Insert Quantity On Hand</title>
</head>
<body>
<P>
<H2>Entry:</H2>
<TABLE border="1">
<TH>Item Number</TH><TH>Vendor Id</TH><TH>Inventory Date</TH><TH>Inventory Update Datetime</TH><TH>Quantity</TH>
<c:forEach var="insertQuantityOnHand" items="${selections}">
<TR>
<TD><c:out value="${insertQuantityOnHand.itemNumber}"/></TD>
<TD><c:out value="${insertQuantityOnHand.vendorId}"/></TD>
<TD><c:out value="${insertQuantityOnHand.inventoryDate}"/></TD>
<TD><c:out value="${insertQuantityOnHand.inventoryupdateDateTime}"/></TD>
<TD><c:out value="${insertQuantityOnHand.quantity}"/></TD>
</TR>
</c:forEach>
</TABLE>
<P>
<BR>
</body>
</html>


And here is my controller

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataIntegrityViolationExce ption;
import org.springframework.validation.BindException;
import org.springframework.web.bind.RequestUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormCont roller;

import com.abc.dao.InsertQuantityOnHandDao;
import com.abc.model.InsertQuantityOnHand;

public class InsertQuantityOnHandController extends SimpleFormController{

private Log Logger = LogFactory.getLog(InsertQuantityOnHandController.c lass);

private static final String ITEM_NUMBER = "itemNumber";

private static final String VENDOR_ID = "vendorId";

private static final String QUANTITY = "quantity";

public InsertQuantityOnHandDao insertQuantityOnHandDao;

public InsertQuantityOnHandController() {

setCommandClass(InsertQuantityOnHand.class);

}

@SuppressWarnings("deprecation")
public Object formBackingObject(final HttpServletRequest request)
throws Exception {

if (Logger.isInfoEnabled()) {
Logger.info("Handling formBackingObject of UpdateCarrierHolidaysController");
}
//final HttpSession session = request.getSession();
// session.setAttribute(, true);
final InsertQuantityOnHand insertQuantityOnHand = new InsertQuantityOnHand();
final String itemNumber = ServletRequestUtils.getStringParameter(request, ITEM_NUMBER);
final String vendorId = ServletRequestUtils.getStringParameter(request, VENDOR_ID);
final String quantity = ServletRequestUtils.getStringParameter(request, QUANTITY);
insertQuantityOnHand.setItemNumber(ITEM_NUMBER);
insertQuantityOnHand.setVendorId(VENDOR_ID);
insertQuantityOnHand.setQuantity(QUANTITY);
// session.setAttribute(ITEM_NUMBER, insertQuantityOnHand);
// session.setAttribute(VENDOR_ID, insertQuantityOnHand);
// session.setAttribute(QUANTITY, insertQuantityOnHand);
return insertQuantityOnHand;
}

public ModelAndView onSubmit(
HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception {

if (Logger.isInfoEnabled()) {

Logger.info("Handling onSubmit of InsertQuantityOnHandController.java");
}
String now = (new Date()).toString();
logger.info("Returning hello view" + now);
Map myModel = new HashMap();
List list = new ArrayList();
try {
// String userId = request.getSession(false).getAttribute("user").toString().trim();
InsertQuantityOnHand insertQuantityOnHand = (InsertQuantityOnHand)command;
//insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand, userId);
insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand);
System.out.println("Inside modelview method and database updated");
// myModel.put("statusResult", "Success");
myModel.put("insertQuantityOnHand", insertQuantityOnHand);
myModel.put("insertQuantityOnHandDao", insertQuantityOnHandDao);

}
catch (DataIntegrityViolationException e) {
myModel.put("statusResult", "IntegrityViolation");
} catch (Exception e) {
myModel.put("statusResult", "Failure");
}

//return showForm(request, response, errors, myModel);
return new ModelAndView("addInsertQuantityOnHand", myModel);
}

public InsertQuantityOnHandDao getInsertQuantityOnHandDao() {
return insertQuantityOnHandDao;
}

public void setInsertQuantityOnHandDao(InsertQuantityOnHandDao insertQuantityOnHandDao) {
this.insertQuantityOnHandDao = insertQuantityOnHandDao;
}
}


Any help will be really appreciated. thank you

christopher1234
Jan 7th, 2008, 06:01 PM
Anyone care to reply?

ozosmail
Jan 7th, 2008, 06:33 PM
Hi, I would advice you to use the spring tags for your form elements. To be more specific your insertQuantityOnHandForm.jsp can be modified to something like:

<form:form action="" commandName="insertQuantityOnHand" method="post">
Item Number: <form:input path="itemNumber" size="30"/> <form:errors path="itemNumber"/>
<p>
Vendor Id: <form:input path="vendorId" size="30"/> <form:errors path="vendorId"/>
<p>
Quanityt: <form:input path="quantity" size="30"/> <form:errors path="quantity"/>
<input type="submit" value="Insert QOH" />
</form>


You will equally have to define your formView, successView, CommandClass, etc in your webapplication context.

As for your addInsertQuantityOnHand.jsp page, this page looks perfectly okay to be able to display your desired results, as long as your view resolver is configured well. You didn't display your view resolver code.

Now importantly, to your Controller code
There are so many things happening here :

try {
// String userId = request.getSession(false).getAttribute("user").toString().trim();
InsertQuantityOnHand insertQuantityOnHand = (InsertQuantityOnHand)command;
//insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand, userId);
insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand);
System.out.println("Inside modelview method and database updated");
// myModel.put("statusResult", "Success");
myModel.put("insertQuantityOnHand", insertQuantityOnHand);
myModel.put("insertQuantityOnHandDao", insertQuantityOnHandDao);

}
catch (DataIntegrityViolationException e) {
myModel.put("statusResult", "IntegrityViolation");
} catch (Exception e) {
myModel.put("statusResult", "Failure");
}

return new ModelAndView("addInsertQuantityOnHand", myModel);


And you didn't display the details of what's happening. Your data access code isn't here so how can we know if you have DAOs right in the first place? Check your DAOs! And get your configurations right. Don't rush into it, refer to the Spring reference.

christopher1234
Jan 8th, 2008, 12:07 AM
First of all thanks alot for looking into my code ozosmail. This is my first time working with spring. I have already read 2 books. Too bad all of those books use a big huge application and then the author dont even know what they are talking about. I mean they could have created simple web applications rather than creating one big application which is divided into 8 to 10 chapters.

Anyways back to the topic. What i am trying to do over here is i have three text fields. Once the user clicks on submit button I need to show those values in a tabular format on the same page(WHich i am unsuccessful).

Secondly there are 2 other fields also date and timestamp. Which would be automatically inserted( I am able to do that easily since i am good in core java). Just a simple form i am creating right now.

I have defined all my commandClass, formView, successView, etc.. I will post my code. I really appreciate if someone can clarify me. I am sure once this application is created by myself then i am good to go into more depth in spring framework with the help of you guys.

InsertQuantityOnHand.java

package com.abc.model;

import java.util.Date;

public class InsertQuantityOnHand {


private String itemNumber;
private String vendorId;
private String inventoryDate;
private Date updateDateTime;
private String quantity;

public InsertQuantityOnHand() {}

public InsertQuantityOnHand(String itemNumber, String vendorId,
String inventoryDate, Date updateDateTime,
String quantity) {

setItemNumber(itemNumber);
setVendorId(vendorId);
setInventoryDate(inventoryDate);
setUpdateDateTime(updateDateTime);
setQuantity(quantity);

}



public void setItemNumber(String itemNumber) {

this.itemNumber = itemNumber;

}


public String getItemNumber() {

return itemNumber;

}



public void setVendorId(String vendorId) {

this.vendorId = vendorId;

}


public String getVendorId() {

return vendorId;

}



public void setInventoryDate(String inventoryDate) {

this.inventoryDate = inventoryDate;

}



public String getInventoryDate() {

return inventoryDate;

}



public void setUpdateDateTime(Date updateDateTime) {

this.updateDateTime = updateDateTime;

}



public Date getUpdateDateTime() {

return updateDateTime;

}



public void setQuantity(String quantity) {

this.quantity = quantity;

}


public String getQuantity() {

return quantity;

}
}


InsertQuantityOnHandDao.java

package com.abc.dao;


import org.springframework.dao.DataAccessException;
import com.abc.model.InsertQuantityOnHand;

public interface InsertQuantityOnHandDao {

public void addInsertQuantityOnHand(
final InsertQuantityOnHand
insertQuantityOnHandModel)
throws DataAccessException;




}


InsertQuantityOnHandDaoImpl.java

package com.abc.daoimpl;


import java.sql.Timestamp;
import java.sql.Types;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.SqlUpdate;

import com.abc.dao.InsertQuantityOnHandDao;
import com.abc.model.InsertQuantityOnHand;

public class InsertQuantityOnHandDaoImpl implements InsertQuantityOnHandDao{

private Log Logger = LogFactory.getLog(InsertQuantityOnHandDaoImpl.clas s);

private DataSource dataSource;

private InsertQuantityOnHandInformation insertQuantityOnHandInformation;

public InsertQuantityOnHandDao insertQuantityOnHandDao;

private static final class InsertQuantityOnHandInformation extends
SqlUpdate{



private static final String INSERT_SQL = "insert into qoh(qh_item_no, qh_vendor_id," +
"qh_inv_date, qh_quantity, qh_upd_datetime" +
"values('?','?','?','?','?')";

public InsertQuantityOnHandInformation(final DataSource ds, final String sql) {

super(ds, (sql == null) ? INSERT_SQL : sql);
declareParameter(new SqlParameter(Types.INTEGER));
declareParameter(new SqlParameter(Types.VARCHAR));
declareParameter(new SqlParameter(Types.DATE));
declareParameter(new SqlParameter(Types.INTEGER));
declareParameter(new SqlParameter(Types.TIMESTAMP));
compile();
}

}

public InsertQuantityOnHandInformation getInsertQuantityOnHandInformation() {

if(this.insertQuantityOnHandInformation == null ) {
this.insertQuantityOnHandInformation = new InsertQuantityOnHandInformation(dataSource, null);
}

return this.insertQuantityOnHandInformation;
}


public void addInsertQuantityOnHand(InsertQuantityOnHand insertQuantityOnHandModel
) throws DataAccessException{
// TODO Auto-generated method stub
if(Logger.isInfoEnabled()) {
Logger.info("Handling insertQuantityOnHand in InsertQuantityOnHandDaoImpl ");
}

try {
// checkVendorItemNumber();
System.out.println("Inside addinsertquantityonhand");
SimpleDateFormat ts = new SimpleDateFormat("MM/DD/YYYY");
Date invDate =
new java.sql.Date(
ts.parse(insertQuantityOnHandModel.getInventoryDat e()).getTime());
final Object[] objs = new Object[] {
insertQuantityOnHandModel.getItemNumber(),
insertQuantityOnHandModel.getVendorId(),
invDate,
insertQuantityOnHandModel.getQuantity(),
new Timestamp(System.currentTimeMillis())
};

getInsertQuantityOnHandInformation().update(objs);
System.out.println("updated");

} catch(DataAccessException ex) {

System.out.println(ex.getMessage());
Logger.info("Data Access Exception occured " + ex.getMessage());

} catch ( ParseException e) {
if (Logger.isErrorEnabled()) {
Logger.error("ParseException occurred in insertCarrierHolidays()");
Logger.error(e.getMessage());
}
}
}

public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}

public DataSource getDataSource() {
return dataSource;
}

public void insertQuantityOnHandDao(InsertQuantityOnHandDao insertQuantityOnHandDao) {
this.insertQuantityOnHandDao = insertQuantityOnHandDao;
}

public InsertQuantityOnHandDao getInsertQuantityOnHandDao() {
return insertQuantityOnHandDao;
}

}

christopher1234
Jan 8th, 2008, 12:09 AM
InsertQuantityOnHandController.java

package com.abc.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataIntegrityViolationExce ption;
import org.springframework.validation.BindException;
import org.springframework.web.bind.RequestUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormCont roller;

import com.abc.dao.InsertQuantityOnHandDao;
import com.abc.model.InsertQuantityOnHand;

public class InsertQuantityOnHandController extends SimpleFormController{

private Log Logger = LogFactory.getLog(InsertQuantityOnHandController.c lass);

private static final String ITEM_NUMBER = "itemNumber";

private static final String VENDOR_ID = "vendorId";

private static final String QUANTITY = "quantity";

public InsertQuantityOnHandDao insertQuantityOnHandDao;

public InsertQuantityOnHandController() {

setCommandClass(InsertQuantityOnHand.class);

}

@SuppressWarnings("deprecation")
public Object formBackingObject(final HttpServletRequest request)
throws Exception {

if (Logger.isInfoEnabled()) {
Logger.info("Handling formBackingObject of UpdateCarrierHolidaysController");
}
//final HttpSession session = request.getSession();
// session.setAttribute(, true);
final InsertQuantityOnHand insertQuantityOnHand = new InsertQuantityOnHand();
final String itemNumber = ServletRequestUtils.getStringParameter(request, ITEM_NUMBER);
final String vendorId = ServletRequestUtils.getStringParameter(request, VENDOR_ID);
final String quantity = ServletRequestUtils.getStringParameter(request, QUANTITY);
insertQuantityOnHand.setItemNumber(ITEM_NUMBER);
insertQuantityOnHand.setVendorId(VENDOR_ID);
insertQuantityOnHand.setQuantity(QUANTITY);
// session.setAttribute(ITEM_NUMBER, insertQuantityOnHand);
// session.setAttribute(VENDOR_ID, insertQuantityOnHand);
// session.setAttribute(QUANTITY, insertQuantityOnHand);
return insertQuantityOnHand;
}

public ModelAndView onSubmit(
HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception {

if (Logger.isInfoEnabled()) {

Logger.info("Handling onSubmit of InsertQuantityOnHandController.java");
}
String now = (new Date()).toString();
logger.info("Returning hello view" + now);
Map myModel = new HashMap();
List list = new ArrayList();
try {
// String userId = request.getSession(false).getAttribute("user").toString().trim();
InsertQuantityOnHand insertQuantityOnHand = (InsertQuantityOnHand)command;
//insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand, userId);
insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand);
System.out.println("Inside modelview method and database updated");
// myModel.put("statusResult", "Success");
myModel.put("insertQuantityOnHand", insertQuantityOnHand);
myModel.put("insertQuantityOnHandDao", insertQuantityOnHandDao);

}
catch (DataIntegrityViolationException e) {
myModel.put("statusResult", "IntegrityViolation");
} catch (Exception e) {
myModel.put("statusResult", "Failure");
}

//return showForm(request, response, errors, myModel);
return new ModelAndView("addInsertQuantityOnHand", myModel);
}

public InsertQuantityOnHandDao getInsertQuantityOnHandDao() {
return insertQuantityOnHandDao;
}

public void setInsertQuantityOnHandDao(InsertQuantityOnHandDao insertQuantityOnHandDao) {
this.insertQuantityOnHandDao = insertQuantityOnHandDao;
}
}

here is my abc-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource" >
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>

<property name="url">
<value>jdbc:mysql://localhost/audit</value>
</property>

<property name="username">
<value>jhtp6</value>
</property>

<property name="password">
<value>jhtp6</value>
</property>

</bean>

<bean name="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="/insertQuantityOnHandForm.htm">insertQuantityOnHandController</prop>
</props>
</property>
</bean>

<bean id="insertQuantityOnHandController" class="com.abc.controller.InsertQuantityOnHandController" >
<property name="sessionForm"><value>true</value></property>
<property name="insertQuantityOnHandDao"><ref bean ="insertQuantityOnHandDao"/></property>
<property name="commandName"><value>insertQuantityOnHand</value></property>
<property name="commandClass"><value>com.vendornet.model.InsertQuantityOnHand</value></property>
<property name="formView"><value>insertQuantityOnHandForm</value></property>
<property name="successView"><value>addInsertQuantityOnHand</value></property>
</bean>


<bean id="insertQuantityOnHandDao" class="com.abc.daoimpl.InsertQuantityOnHandDaoImpl" >
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>



<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>



</beans>


Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">



<display-name>abc</display-name>



<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>


<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>


<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<jsp-config>
<taglib>
<taglib-uri>/spring</taglib-uri>
<taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
</taglib>
</jsp-config>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

</web-app>

Marten Deinum
Jan 8th, 2008, 03:46 AM
Well start with defining transactions (http://static.springframework.org/spring/docs/2.5.x/reference/transaction.html), without those insert/delete/update statements aren't going to do anything.

pmularien
Jan 8th, 2008, 07:27 AM
I would strongly suggest reading through the Spring MVC Step by Step (http://www.springframework.org/docs/Spring-MVC-step-by-step/index.html) tutorial, updated for Spring 2.5. It covers the basic structure of a JDBC-driven Spring MVC application very well (and you can't beat the price!).

christopher1234
Jan 8th, 2008, 09:13 AM
mdeinum thanks for the url. I have read the spring reference manual and couple of my spring books also. They are doing the same thing also what i am doing. Create a model, then a dao interface, then the daoimpl(Where you will have all your insert and update statements) and then the controller. After that create -servlet.xml where you will define all your jdbc connections and injecting bean dependency.

Is it necessary to use transactions? I am sure we can presist the data without using the transactions? please clarify me if i am wrong.

I have read the spring MVC 3 times now and i am following the same standard :--).

pmularien
Jan 8th, 2008, 09:23 AM
Is it necessary to use transactions? I am sure we can presist the data without using the transactions? please clarify me if i am wrong.
Yes, it is.

christopher1234
Jan 8th, 2008, 10:11 AM
Code from beginning Spring framework 2. Testing database application.

springdao-test.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


<!--Album DAO Mapping -->
<bean id="albumDAO" class="com.wrox.beginspring.pix.dao.examples.AlbumSpringD ao">

<property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>

<!-- Wire in the HSQL DataFieldMaxValueIncrementer -->
<property name="albumIdIncrementor"
ref="albumIdinc"/>

<!-- Wire in the HSQL DataFieldMaxValueIncrementer -->
<property name="pictureIdIncrementor"
ref="pcitureIdinc"/>

</bean>


<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
</bean>
<bean id="albumIdinc" class="org.springframework.jdbc.support.incrementer.HsqlM axValueIncrementer">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
<constructor-arg><value>ALBUM_SEQUENCE</value> </constructor-arg>
<constructor-arg><value>SEQ_ID</value> </constructor-arg>
</bean>

<bean id="pcitureIdinc" class="org.springframework.jdbc.support.incrementer.HsqlM axValueIncrementer">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
<constructor-arg><value>PICTURE_SEQUENCE</value> </constructor-arg>
<constructor-arg><value>SEQ_ID</value> </constructor-arg>
</bean>

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerD ataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:hsql://localhost/pix" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>

</beans>


Now can you tell me where did he used transactions over here? i was able to run this example application presisting the data in the database. No transactions used so whats wrong with my application?

nyte3k
Jan 8th, 2008, 02:06 PM
ok... i'm too lazy to read everything posting above...but this is how I have mine done... i'm using Spring, spring MVC and hibernate and it's using transactions.

A Service Class i created to handle some business logic and hit the database.
This is a method I have in there.


public void updateUserAccount(final UsersAccounts userAccount){
logger.debug("[START] - updateUserAccount()");
this.transactionTemplate.execute(new TransactionCallbackWithoutResult(){
public void doInTransactionWithoutResult(TransactionStatus status){
daoAccessor.userAccountDao.updateUserAccount(userA ccount);
}
});
logger.debug("[END] - updateUserAccount()");
}


Basically UsersAccounts is a bean that my Form Controller populated and passed to this method. (This Service is injected into the controller)
daoAccessor is an object that I created that accesses other objects that perform the hibernate database functions(save, update, delete etc) As you can see daoAccessor.userAccountDao.updateUserAccount(userA ccount) is called within doInTransactionWithoutResult.... basically it's done within a transaction.



This is the injected TransactionManager in the same file that the above method uses:


public void setTransactionManager(PlatformTransactionManager transactionManager){
this.transactionTemplate = new TransactionTemplate(transactionManager);
}



This is the transactionManager that is injected into the Service.



<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransa ctionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>



session factory that is injected into the element above. And of course the "dataSource" property is the connection info to the database.

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.Anno tationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>

<property name="annotatedClasses">
<list>
<value>com.....model.UsersAccounts</value>
</list>
</property>



Hope, this helps a little.

Marten Deinum
Jan 8th, 2008, 02:16 PM
Why so complicated? Now your service layer is directly tied to spring and you need to programmatically manage your transactions.

Adding a few more lines to your configuration, saves you a lot of code and gain the same results...

nyte3k
Jan 8th, 2008, 02:27 PM
ya thats true, i could have just injected the transaction manager to the controller. When i learned i did it that way, and have done a lot since then with this project, so i just left it how it was.

Marten Deinum
Jan 8th, 2008, 02:30 PM
Inject it into the controller?! You don't have to inject the transaction manager when using declarative transaction management, just a few lines of xml...

nyte3k
Jan 8th, 2008, 03:21 PM
that may have been a section i skipped. :)

ozosmail
Jan 8th, 2008, 05:29 PM
Just to clarify what the last poster said about inserting data into a database, from all I have gathered, and from past experiences, you don't need to use transactions to make database inserts, updates, etc. You don't.

But without transactions you are likely to have database inconsistencies when errors occur.

christopher1234
Jan 9th, 2008, 12:21 AM
Man is there a way to use transaction management without using hibernate? I am just using simple dataSource. I have been banging my head now for 3 days :--( stuck on just one simple problem( NOt updating the database).

I have searched everything on google. Nothing is working for me. To write the code was a piece of cake with all the dao, daoimpl, service. The only problem where i am new is the bean configuration and modelandview controller.

Anyone care to look at my code and help me out just one time. If i get this thing working my first own written web page using springframework i will be very happy. As you can see i did'nt had no problem in writing the java code since i am very good in core java but this configuration is killing me. please help :--(


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>


<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource" >
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>

<property name="url">
<value>jdbc:mysql://localhost/audit</value>
</property>

<property name="username">
<value>jhtp6</value>
</property>

<property name="password">
<value>jhtp6</value>
</property>



</bean>

<bean id="insertQuantityOnHandValidator" class="com.abc.validator.InsertQuantityOnHandValidator">
<property name="insertQuantityOnHandService"><ref bean="insertQuantityOnHandService"/></property>
</bean>

<bean name="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="/insertQuantityOnHandForm.htm">insertQuantityOnHandController</prop>
</props>
</property>
</bean>

<bean id="insertQuantityOnHandController" class="com.abc.controller.InsertQuantityOnHandController" >
<property name="insertQuantityOnHandService"><ref bean="insertQuantityOnHandService"/></property>
<property name="validator"><ref bean="insertQuantityOnHandValidator"/></property>
<property name="commandName"><value>insertQuantityOnHand</value></property>
<property name="commandClass"><value>com.abc.model.InsertQuantityOnHand</value></property>
<property name="formView"><value>insertQuantityOnHandForm</value></property>
<property name="successView"><value>/addInsertQuantityOnHand.htm</value></property>
</bean>

<bean id="messageSource"
class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename" value="messages"></property>
</bean>

<bean id="contentMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.Pa rameterMethodNameResolver"/>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>



<bean id="insertQuantityOnHandService" class="com.abc.service.impl.InsertQuantityOnHandServiceIm pl">
<property name="insertQuantityOnHandDao"><ref bean="insertQuantityOnHandDao"/></property>
</bean>


<bean id="insertQuantityOnHandDao" class="com.abc.dao.impl.InsertQuantityOnHandDaoImpl" init-method="initialize" >
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>

<!--
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/abcMassUpdate"></property>
</bean>

<bean id="insertQuantityOnHandTarget" class="com.abc.service.impl.InsertQuantityOnHandServiceIm pl">
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>

-->

<!-- this is where things get messed up. If i remove this then no error but then database does not update -->

<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransaction Manager"/>

<bean id="insertQuantityOnHand"
class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref bean="insertQuantityOnHandTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="add*">
PROPAGATION_REQUIRES_NEW, ISOLATION_SERIALIZABLE,-ContentServiceException
</prop>
</props>
</property>
</bean>

</beans>


and here is my controller. Like i mentioned before that all i am doing is checking to see if that item exist in a table(USing a select query). If it exist then go ahead execute my (Insert query) if not error msg is displayed.

christopher1234
Jan 9th, 2008, 12:22 AM
package com.abc.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;

import org.apache.commons.logging.Log;

import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataIntegrityViolationExce ption;
import org.springframework.validation.BindException;
import org.springframework.web.bind.RequestUtils;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormCont roller;

import com.abc.dao.InsertQuantityOnHandDao;
import com.abc.model.InsertQuantityOnHand;
import com.abc.service.InsertQuantityOnHandService;
import com.abc.validator.InsertQuantityOnHandValidator;

public class InsertQuantityOnHandController extends SimpleFormController{

private Log Logger = LogFactory.getLog(InsertQuantityOnHandController.c lass);

private static final String ITEM_NUMBER = "itemNumber";

private static final String VENDOR_ID = "vendorId";

private static final String QUANTITY = "quantity";

private InsertQuantityOnHandService insertQuantityOnHandService;

private InsertQuantityOnHandValidator insertQuantityOnHandValidator;

public InsertQuantityOnHandController() {

setCommandClass(InsertQuantityOnHand.class);

}

@SuppressWarnings("deprecation")
public Object formBackingObject(final HttpServletRequest request)
throws Exception {

if (Logger.isInfoEnabled()) {
Logger.info("Handling formBackingObject of InsertQuantityOnHandController");
}
final InsertQuantityOnHand insertQuantityOnHand = new InsertQuantityOnHand();
final String itemNumber = ServletRequestUtils.getStringParameter(request, ITEM_NUMBER);
final String vendorId = ServletRequestUtils.getStringParameter(request, VENDOR_ID);
final String quantity = ServletRequestUtils.getStringParameter(request, QUANTITY);
insertQuantityOnHand.getItemNumber();
insertQuantityOnHand.getVendorId();
insertQuantityOnHand.getQuantity();
return insertQuantityOnHand;
}

public ModelAndView onSubmit(
HttpServletRequest request,
HttpServletResponse response,
Object command,
BindException errors)
throws Exception {

if (Logger.isInfoEnabled()) {

Logger.info("Handling onSubmit of InsertQuantityOnHandController.java");
}
ModelAndView mav = null;
System.out.println("INside mav");
String now = (new Date()).toString();
logger.info("Returning hello view" + now);
Map myModel = new HashMap();
List list = new ArrayList();
try {
System.out.println("Inside try and catch block");
// String userId = request.getSession(false).getAttribute("user").toString().trim();
InsertQuantityOnHand insertQuantityOnHand = (InsertQuantityOnHand)command;
boolean valid = getInsertQuantityOnHandService().validateItemNumbe rQuery(insertQuantityOnHand.getItemNumber());
if(!valid) {
errors.reject("item number is invalid");
mav = showForm(request, response, errors);
}
else {
insertQuantityOnHandService.addQuantityOnHand(inse rtQuantityOnHand);
System.out.println("Inside modelview method and database updated");
myModel.put("insertQuantityOnHand", insertQuantityOnHand);
myModel.put("insertQuantityOnHandService", insertQuantityOnHandService);
mav = new ModelAndView(getSuccessView(), myModel);
}
}

//insertQuantityOnHandDao.addInsertQuantityOnHand(in sertQuantityOnHand, userId);
catch (DataIntegrityViolationException e) {
myModel.put("statusResult", "IntegrityViolation");
} catch (Exception e) {
myModel.put("statusResult", "Failure");
}

//return showForm(request, response, errors, myModel);
return mav;
//return new ModelAndView("addInsertQuantityOnHand", myModel);
}

public void setInsertQuantityOnHandService(InsertQuantityOnHan dService insertQuantityOnHandService) {
this.insertQuantityOnHandService = insertQuantityOnHandService;
}

public InsertQuantityOnHandService getInsertQuantityOnHandService() {
return insertQuantityOnHandService;
}

public void setInsertQuantityOnHandValidator(InsertQuantityOnH andValidator insertQuantityOnHandValidator) {
this.insertQuantityOnHandValidator = insertQuantityOnHandValidator;
}

public InsertQuantityOnHandValidator getInsertQuantityOnHandValidator() {
return insertQuantityOnHandValidator;
}
}



Now this is the error i am getting

ERROR DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'insertQuantityOnHandValidator' defined in ServletContext resource [/WEB-INF/abcMassUpdate-servlet.xml]: Cannot resolve reference to bean 'insertQuantityOnHandService' while setting bean property 'insertQuantityOnHandService'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'insertQuantityOnHandService' defined in ServletContext resource [/WEB-INF/abcMassUpdate-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
Caused by:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'insertQuantityOnHandService' defined in ServletContext resource [/WEB-INF/abcMassUpdate-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
Caused by:
java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.ja va:2395)
at java.lang.Class.getDeclaredMethods(Class.java:1763 )
at java.beans.Introspector$1.run(Introspector.java:12 65)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(I ntrospector.java:1263)
at java.beans.Introspector.getTargetMethodInfo(Intros pector.java:1129)
at java.beans.Introspector.getBeanInfo(Introspector.j ava:387)
at java.beans.Introspector.getBeanInfo(Introspector.j ava:159)
at org.springframework.beans.CachedIntrospectionResul ts.<init>(CachedIntrospectionResults.java:244)
at org.springframework.beans.CachedIntrospectionResul ts.forClass(CachedIntrospectionResults.java:143)
at org.springframework.beans.BeanWrapperImpl.setIntro spectionClass(BeanWrapperImpl.java:236)
at org.springframework.beans.BeanWrapperImpl.setWrapp edInstance(BeanWrapperImpl.java:194)
at org.springframework.beans.BeanWrapperImpl.setWrapp edInstance(BeanWrapperImpl.java:177)
at org.springframework.beans.BeanWrapperImpl.<init>(BeanWrapperImpl.java:130)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:753)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:717)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:386)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 49)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:155)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:267)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:110)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 49)
at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:155)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
.......

I have read on google about this error and someone said to put the jta.jar under classpath which i did but still i cannopt run my application

christopher1234
Jan 9th, 2008, 12:24 AM
can someone show me a simple example from one of their work with the bean configuration ? so i can get a good idea

christopher1234
Jan 9th, 2008, 01:29 AM
Ok. I got my xml file working now with no errors. Now still the same thing happening not updating the database. May be it has to do something with my controller code the one i posted like 3 min ago?

xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>


<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerD ataSource" >
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>

<property name="url">
<value>jdbc:mysql://localhost:3306/audit</value>
</property>

<property name="username">
<value>jhtp6</value>
</property>

<property name="password">
<value>jhtp6</value>
</property>



</bean>

<bean id="insertQuantityOnHandValidator" class="com.abc.validator.InsertQuantityOnHandValidator">
<property name="insertQuantityOnHandService"><ref bean="insertQuantityOnHandService"/></property>
</bean>

<bean name="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop key="/insertQuantityOnHandForm.htm">insertQuantityOnHandController</prop>
</props>
</property>
</bean>

<bean id="insertQuantityOnHandController" class="com.abc.controller.InsertQuantityOnHandController" >
<property name="insertQuantityOnHandService"><ref bean="insertQuantityOnHandService"/></property>
<property name="validator"><ref bean="insertQuantityOnHandValidator"/></property>
<property name="commandName"><value>insertQuantityOnHand</value></property>
<property name="commandClass"><value>com.abc.model.InsertQuantityOnHand</value></property>
<property name="formView"><value>insertQuantityOnHandForm</value></property>
<property name="successView"><value>/addInsertQuantityOnHand.htm</value></property>
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTran sactionManager">
<property name="dataSource"><ref local="dataSource"/></property>
</bean>


<!--
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename" value="messages"></property>
</bean>
-->

<!--
<bean id="contentMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.Pa rameterMethodNameResolver"/>
-->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>



<bean id="insertQuantityOnHandService" class="com.abc.service.impl.InsertQuantityOnHandServiceIm pl">
<property name="insertQuantityOnHandDao"><ref bean="insertQuantityOnHandDao"/></property>
</bean>


<bean id="insertQuantityOnHandDao" class="com.abc.dao.impl.InsertQuantityOnHandDaoImpl" init-method="initialize" >
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>

<!--
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/abcMassUpdate"></property>
</bean>
-->

<bean id="insertQuantityOnHandTarget" class="com.abc.service.impl.InsertQuantityOnHandServiceIm pl">
<property name="insertQuantityOnHandDao"><ref bean="insertQuantityOnHandDao"/></property>
</bean>



<bean id="insertQuantityOnHand"
class="org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref bean="insertQuantityOnHandTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="add*">
PROPAGATION_REQUIRES_NEW, ISOLATION_SERIALIZABLE,-ContentServiceException
</prop>
</props>
</property>
</bean>

</beans>


This is what i get when i restart my tomcat looks like it cannot resolve the view.


EBUG DispatcherServlet - No HandlerAdapters found in servlet 'abcMassUpdate': using default
DEBUG CollectionFactory - Creating [java.util.LinkedHashMap]
DEBUG DispatcherServlet - No HandlerExceptionResolvers found in servlet 'abcMassUpdate': using default
DEBUG DefaultListableBeanFactory - No bean named 'viewNameTranslator' found in org.springframework.beans.factory.support.DefaultL istableBeanFactory@5dcec6: defining beans [dataSource,insertQuantityOnHandValidator,simpleUrl Mapping,insertQuantityOnHandController,transaction Manager,messageSource,contentMethodNameResolver,vi ewResolver,insertQuantityOnHandService,insertQuant ityOnHandDao,insertQuantityOnHandTarget,insertQuan tityOnHand]; root of factory hierarchy
DEBUG DefaultListableBeanFactory - Creating instance of bean 'org.springframework.web.servlet.view.DefaultReque stToViewNameTranslator' with merged definition [Root bean: class [org.springframework.web.servlet.view.DefaultReques tToViewNameTranslator]; scope=prototype; abstract=false; lazyInit=false; autowireCandidate=true; autowireMode=0; dependencyCheck=0; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
DEBUG CachedIntrospectionResults - Getting BeanInfo for class [org.springframework.web.servlet.view.DefaultReques tToViewNameTranslator]
DEBUG CachedIntrospectionResults - Caching PropertyDescriptors for class [org.springframework.web.servlet.view.DefaultReques tToViewNameTranslator]
DEBUG CachedIntrospectionResults - Found bean property 'alwaysUseFullPath' of type [boolean]
DEBUG CachedIntrospectionResults - Found bean property 'class' of type [java.lang.Class]
DEBUG CachedIntrospectionResults - Found bean property 'prefix' of type [java.lang.String]
DEBUG CachedIntrospectionResults - Found bean property 'separator' of type [java.lang.String]
DEBUG CachedIntrospectionResults - Found bean property 'stripExtension' of type [boolean]
DEBUG CachedIntrospectionResults - Found bean property 'stripLeadingSlash' of type [boolean]
DEBUG CachedIntrospectionResults - Found bean property 'suffix' of type [java.lang.String]
DEBUG CachedIntrospectionResults - Found bean property 'urlDecode' of type [boolean]
DEBUG CachedIntrospectionResults - Found bean property 'urlPathHelper' of type [org.springframework.web.util.UrlPathHelper]
DEBUG CollectionFactory - Creating [java.util.LinkedHashMap]
DEBUG DispatcherServlet - Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultReques tToViewNameTranslator@e49dcd]
DEBUG CollectionFactory - Creating [java.util.LinkedHashMap]
DEBUG DefaultListableBeanFactory - Returning cached instance of singleton bean 'viewResolver'
DEBUG DispatcherServlet - Published WebApplicationContext of servlet 'abcMassUpdate' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.C ONTEXT.abcMassUpdate]
INFO DispatcherServlet - FrameworkServlet 'abcMassUpdate': initialization completed in 811 ms
DEBUG DispatcherServlet - Servlet 'abcMassUpdate' configured successfully
Jan 9, 2008 12:30:15 AM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 9, 2008 12:30:15 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 9, 2008 12:30:15 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/100 config=null
Jan 9, 2008 12:30:15 AM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Jan 9, 2008 12:30:15 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2674 ms


Can i start a new thread?

nyte3k
Jan 9th, 2008, 03:25 PM
Inject it into the controller?! You don't have to inject the transaction manager when using declarative transaction management, just a few lines of xml...

I looked into that, and discovered using the annotated way is a lot cleaner than what I had.


@Transactional within my daoImpls

Thanks.