spring

Spring Transaction - automatic rollback of previous db updates when one db update failes

I am writing a simple application (Spring + Hibernate + PostgreSql db). I am just trying to construct a sample object and persist in db. I run a simple java class main method where i have loaded the applicationContext and have got reference to the service class as below TestService srv = (TestService)factory.getBean("testService"); ...

JPA and DAO - what's the standard approach?

I'm developing my first app with JPA/Hibernate and Spring. My first attempt at a DAO class looks like this: @Repository(value = "userDao") public class UserDaoJpa implements UserDao { @PersistenceContext private EntityManager em; public User getUser(Long id) { return em.find(User.class, id); } public List g...

example of spring declarative roolback-for?

want declarative transactional management example in spring aop........ Actually Here <aop:config> <aop:advisor advice-ref="addAdvice" pointcut="execution(* com.DAO.*.*(..))"/> </aop:config> <tx:advice id="addAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propag...

Spring: Accessing the correct WebApplicationContext with multiple dispatchers decalred

I have two Spring contexts declared in my application - one for Spring-MVC requests, and another for Flex/BlazeDS messagebroker requests, mapped to different url-patterns: <servlet-mapping> <servlet-name>spring-mvc</servlet-name> <url-pattern>/app/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>flex</servl...

DAO and Service layers (JPA/Hibernate + Spring)

I'm designing a new app based on JPA/Hibernate, Spring and Wicket. The distinction between the DAO and Service layers isn't that clear to me though. According to Wikipedia, DAO is an object that provides an abstract interface to some type of database or persistence mechanism, providing some specific operations without exposing...

How to set-up transactions for both web application and batch jobs using Spring and Hibernate

I have an application which uses Spring 2.5 and Hibernate 3. There's a web application with a presentation layer, a servive layer and a DAO layer, as well as some Quartz jobs sharing the same service and DAO layers. Transactions are initialized in different layers with @Transactional annotations, like this: It led me to a problem ...

How to ensure the same account is not used to log in two different people at the same time in Spring Security?

I have a Spring MVC app that does not protect updates of user data with transactions. It assumes that only a single user is accessing the account data for that account at any one time. However, if two users were to log in using the same authentication credentials, it is theoretically possible, although unlikely, for two database upda...

Spring Session User Info retrieval in Dao layer

I have a web-application in java, spring framework, hibernate on tomcat, that has basically almost no security except the login and logout functionality (no spring security) I can access the user information in a controller by: // where request is HttpServletRequest HttpSession session = request.getSession(true); SystemUser user =...

Make a C# call from XML or just set path as application path in XML

Hey I'm connecting to a .sdf database file and i need it to be generic project wide, no matter what computer the project is on. Currently I cana cheive this in C#/ASP.NET witht he following code: "Data Source=" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "/dbmon.sdf;Passwor...

Why am I not getting Spring Security Login Error Messages?

Using Spring Security 3 along with Struts 2 and Tiles 2, I have a login page that appears when it is supposed to and performs the login as expected -- however when I enter bad user credentials I am returned to the login page with no information about what went wrong. I've checked all my configuration parameters and I can't see where the ...

Service layer and controller: who takes care of what?

In class we're now learning how to build up a Spring application, even though spring isn't directly involved, we learned how to make the interfaces for DAO and service layer objects. Please correct me if I'm wrong: DAO layer is pretty abstract: it just contains the CRUD operations and is further used to read data.(ie: get all objects, ...

Access maven project version in Spring config files

I would like to display the currently running version of my web application in the page. The project is based on Maven, Spring, and Wicket. I'd like to somehow get the value of maven's ${project.version} and use it in my spring XML files, similarly to the way I use the Spring PropertyPlaceholderConfigurer to read a property file for set...

Where should "@Transactional" be place Service Layer or DAO

Firstly it is possible that I am asking something that has been asked and answered before but I could not get a search result back . Okay generally (or always so far:) ) We define transactional annotations on service layer typical spring hibernate crud is usually Controller->Manager->Dao->Orm . I now have a situation where I need to ch...

visual vm analyze memory leak

in my visual vm, i click on sample->memory, and i keep see "windowprincipal" class, instances stay at 25. even that right now nobody using the application. is this sign of memory leak? http://www.freeimagehosting.net/image.php?c069df48c2.gif ...

Does Spring MessageSource Support Multiple Class Path?

I am designing a plugin system for our web based application using Spring framework. Plugins are jars on classpath. So I am able to get sources such as jsp, see below ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource[] pages = resolver.getResources("classpath*:jsp/*jsp"); So far so good. But I have...

SpringPython error following the book: AttributeError: 'module' object has no attribute 'ObjBase'

Hello from Spain. Well, I bought the book Spring Python 1.1 and I have been facing some problems that I cannot solve. I am going to write the code of each file in order to make sure everything is clear. If some of you know what is the problem, please let me know because I am desperate. simple_service.py class Service(object): def happ...

Using Spring in Java swing app

We are seeing Spring in school right now but we don't have the time to wait till the end of the semester to start developing an application. We continue using an app we made last year, and are writing the service layer right now. The problem is our "client" wants to have a desktop client and a webpart, which used the same dtatabase. Thi...

Migrating JUnit JPA tests from Spring 2.5.5 to Spring 3.0.4

Our project has just decided to migrate from Spring 2.5.5 to Spring 3.0.4. In my original code, I had unit tests that looked like the following: public class RequisitionDaoTest extends AbstractJpaTests { public static String FAIL_MSG_UNEXPECTED_ERROR = "FAIL: Unexpected Error"; @PersistenceContext private EntityMa...

How to do Spring Lookup Method Injection with Annotations?

Is there any way to use Lookup Method Injection using annotations? Given the following class: @Service public abstract class A { protected abstract createB(); } In order to get it to work I have to declare in spring applicationContext.xml the following: <bean id="b" class="com.xyz.B"> </bean> <bean id="a" class="com.xyz.A"> ...

How do I log response in Spring RestTemplate?

I am using RestTemplate to make calls to a web service. String userId = restTemplate.getForObject(createUserUrl, String.class); If this fails to return a user ID I just get returned null but I don't know why. How do I output the actual XML response to a log? ...