spring

Spring Web Service Unit Tests: java.lang.IllegalStateExcepton: Failed to load Application Context

I am getting the error "java.lang.IllegalStateExcepton: Failed to load Application Context" when I am trying to run my unit test from within Eclipse. The Unit Test itself seems very simple: package com.mycompany.interactive.cs.isales.ispr.ws.productupgrade; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWit...

HandlerExceptionResolver for annotated controller.

I have annotated controller which contains several methinds mapped on urls. Like this: @Controller public class CategoryController { @RequestMapping(value = "/addCategories") public void addCategories(@RequestParam(value = "data") String jsonData) throws ParseException @RequestMapping(value = "/getNext") public void getNext(@RequestPa...

Lingering Hibernate sessions without transaction in JBoss

I have encountered a Hibernate issue I just can't find my way around. We're running Hibernate 3.2.6 on JBoss 4.2.0, in a Spring 2.5.4 application behind JBossWS 2.0.1 (just to get all the version on the table). Normally this works just fine, but sometime the system spontaneously (i.e. for some reason currently not know to us) enters a s...

Checking if specific user has a role

Hi, is there some pretty way to check if some specific user (not the one that is logged in) has some specific role? Here is grails example (generally the same for plain Java but syntax): def user = User.get(1) //Get user with id 1 if (ifAnyGranted(user,"ROLE_ADMIN")) { //This is the line I need to implement somehow ... } Thanks in a...

Generating simple crud applications in Spring based off existing database or hibernate configurations?

I'm attempting to learn Spring MVC but have been spoiled by Grails. While I am able to get a basic web application working I was wondering if there were any tools that could do some of the work to create a crud application given a database or hibernate data model? The only one I've found so far is http://www.skywayperspectives.org/portal...

OSGi - How mature is this technology?

I have a requirement where I need to share some web resources (jsp, html, js, images, css etc.) across different Spring based Struts 2 applications. And seems like OSGi can be used to achieve this? Can some one give some pointers on how to achieve this with OSGi? And secondly I want to know is OSGi mature enough to be used in producti...

Spring JDBC RowMapper with Class Hiearchies

I wanted to know what the community considers the "best practices" in respect to mapping class hierarchies with Spring JDBC. We do not have the ability to use a full fledged ORM tool, however we are using the Spring JDBC to alleviate some of the tedious nature of JDBC. One class which we leverage very regularly are the BeanPropertyRo...

autocommit and @Transactional and Cascading with spring, jpa and hibernate

Hi, what I would like to accomplish is the following: have autocommit enabled so per default all queries get commited if there is a @Transactional on a method, it overrides the autocommit and encloses all queries into a single transaction, thus overriding the autocommit if there is a @Transactional method that calls other @Transaction...

loading .properties in spring-context.xml and persistence.xml

Hi, is there a way to reference a .properties file in a spring-context.xml and a JPA persistence.xml? I think I've seen somewhere an example of this in spring context files, though I can't remember where that was. Maybe someone knows this? About the persistence.xml I am actually unsure if this works at all. My aim is to change some pr...

cannot do 2nd level cache

in my applicationcontext.xml <bean id="annotatedsessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="packagesToScan" value="testonly.package.model" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect...

Spring Webflow Best Practice

Hi. I have a java web application which uses spring webflow as framework. I have a problem with processing data on a plain flow xml. When the processing gets more complicated I find it hard to implement using the flow xml of the web flow. I was considering of using controllers to perform these operations. How do I do this. Have no Idea ...

JPA @VERSION how to use it?

@Entity public class Person { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private int salary; @Version private long version; // ...getters and setters } may i know is there required to create set/get for "version" ? in my code ,when persist (saveorupdate) this entity with hiber...

Spring - handle multiple forms submit with one controller

Is it possible to have one controller to handle multiple forms in spring? For example, i have 3 steps registration that map with "/register" url. Is it possible to have only one RegisterController that can handle all registration's steps form submit? ...

Can I use an Environment variable based location for Spring FileSystemResource?

I have a requirement to have all our properties files be stored in a directory. The location of this directory should be stored in a system environment variable. In my application context I will need to access this environment variable to create the FileSystemResource bean. Here is an example of what I would normally have: <bean id="pr...

Execute a task after the modelAndView is returned

In Spring, is there a way to execute a task after returning a view or I need to create a ThreadPool and do it ? Ex: public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { Map<Object, Object> data = new HashMap<Object, Object>(); //do some stuff exe...

Spring Web Flow

Hi. How do I get or pass in the flow xml the value from a selectoneMenu field in an XHTML page. ...

Customizing Spring concurrent-session-control configuration

How do I detect and inform the user that they already have an active session and provide them an option to create a new session or close the current active one? Please advise. Thanks much. ...

hibernate don't read from ehcache.xml OR not timeout?

This is how my entity look like @Entity @Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Table(name = "TestPojoOnly") @NamedQueries({@NamedQuery(name = "TestPojoOnly.findAll", query = "SELECT h FROM TestPojoOnly h"), @NamedQuery(name = "TestPojoOnly.findById", query = "SELECT h FROM TestPojoOnly h WHERE h.id = :id"), @Na...

jpa @version optimistic locking

I loaded same entity record on 2 separate browser window then press submit (hibernate template.merge), version number incremented for both browser window, but never caught any problem with optimistic lock.. so how to test this? my save() look like this hibernatetemplate().merge(..); setJPAObject(null); //reset after save ...

Java compile warnings with spring "Validator" classes

New to spring, we have a whole pile of validators that generate java warnings, I was able to hide them using the "@SuppressWarnings" annotation, however what is the proper way to sort this out? public class SignInValidator implements org.springframework.validation.Validator { @SuppressWarnings("unchecked") public boolea...