spring

Spring MVC Date and CustomDateEditor problem on simple text Field.

Hello I have a problem with Spring MVC 3.0 + CustomDateEditor and one field of type java.util.Date In my controller I have : protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { DateFormat df = new SimpleDateFormat("hh:mm MM/dd/yyyy"); df.setLenient(false); CustomDat...

Invalidating JPA EntityManager session

A project I am working on uses Spring 2.5 & JPA with Hibernate as a provider. My DAO classes extend JpaDaoSupport, so I get my JpaTemplate using the getJpaTemplate() method. The back-end database can get changed either by my application, or a third-party application. When a third-party application changes the database (mostly config...

Hibernate/Spring: Persisting collections

Hi guys, I've got two objects: User and Permission, where User has a Collection. In my "create" service, I read a bunch of Permissions, put them in a HashSet, add them to the user, and create the user using my DAO that says ((SessionFactory) sessionFactory).getCurrentSession().save(user); When I look in my object, all looks fine, bu...

Best way to force Spring shutdown from a bean?

My application uses a Spring DefaultMessageListenerContainer to process incoming messages. The main method of the app already registers a shutdown hook. Question is this: what is the best way to force the application context to shut down? If I throw a RuntimeException in the message listener, it is handled by the container, and not pas...

Execute method on startup in spring

Hello, Is there any Spring 3 feature to execute some methods when the application starts for the first time? I know that I can do the trick of setting a method with @Scheduled annotation and it executes just after the startup, but then it will execute periodically. Thanks. ...

What does <tx:annotation-driven/> in Spring really do in the code level ?

Does it set a flag in a bean ? Does it load "special" bean which then looks for @Transactional ? ...

Spring WS & Validator interceptor

I have a endpoint mapping a webservice which is used to insert in the dabatabase some keywords: @Transactional(readOnly = false,isolation= Isolation.SERIALIZABLE) public Source saveKW(...). The input is a request. I would like to add an interceptor on the method in order to validate the parameters. this one will read some values fro...

Is there an equivalent to Spring:bind for binding forms and data on the front end?

I asked this question a few weeks ago and didn't get the answer I was looking for, so figured I'd ask again a little differently. I need to construct a form in my UI which will allow users to view and edit complex, nested objects. If I were doing this the JSP way, I would use Spring's bind functionality to associate form fields with bac...

post xml to Spring REST server returns Unsupported Media Type

I'm trying to create a simple spring based webservice that supports a "post" with xml content. In spring, I define an AnnotationMethodHandler: <bean id="inboundMessageAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <util:list> ...

GWT Acegi alternative

I'm starting new project. The client interface is based on GWT (and GXT) I have no say it's predetermined. However I can pick and choose as far as server side so I can have some fun and hopefully learn something new in the process. Some requirements are : Exchange with server will be through use of JSON, most if not all of UI will be g...

hibernate query cache specify cache duration

below is how i do query cache getHibernateTemplate().setCacheQueries(true); List<IssSection> result = (List<IssSection>) getHibernateTemplate().findByCriteria(crit); getHibernateTemplate().setCacheQueries(false); may i know how to specify duration of maximum time to cache this method? let say i want to clear cache after 5 min...

Is solr a web application that can run on the same instance as a spring app on tomcat?

Is solr a web application that can run on the same instance as a spring app on tomcat? I've always run solr on its own server (jetty), along with a asp.net app so a bit confused if you need solr to run on its own server. Or can you run both a spring web app and solr on the same instance as tomcat, both running on port 80? ...

MySql timeouts - Should I set autoReconnect=true in Spring application?

After periods of inactivity on my website (Using Spring 2.5 and MySql), I get the following error: org.springframework.dao.RecoverableDataAccessException: The last packet sent successfully to the server was 52,847,830 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/...

SimpleJdbcCall ignoring JdbcTemplate fetch size

We are calling the pl/sql stored procedure through Spring SimpleJdbcCall, the fetchsize set on the JdbcTemplate is being ignored by SimpleJdbcCall. The rowmapper resultset fetch size is set to 10 even though we have set the jdbctemplate fetchsize to 200. Any idea why this happens and how to fix it? Have printed the fetchsize of resultse...

[Java] How should I unit test Spring, Hibernate and Struts using junit

What is the best practice? How should I implement it so that the database isn't polluted? ...

Using Hibernate Validator with JPA and Spring

I'm using Hibernate Validator 4.0.2, Spring 3.0 and Hibernate 3.3.2 (which, as I understand it, is pre-JPA2) as a JPA 1 provider. I've found it easy to integrate the Validator into the MVC layer (it just works) but can't see how to integrate the validator automatically into the JPA entityManager (JPA 1). Basically, I have some entities...

Oracle Blobs - store size or calculate?

I am writing a generic Http resource hosting service and am storing larger objects as BLOBs in an Oracle database. I want to be able to set the 'Content-Length' header when returning a stored object, which means I need to know the size of the BLOB before I start writing it to the client (I know I could use chunked-encoding, and am in so...

request scoped beans in spring testing

I would like to make use of request scoped beans in my app. I use JUnit4 for testing. If I try to create one in a test like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:spring/TestScopedBeans-context.xml" }) public class TestScopedBeans { protected final static Logger logger = Logger...

Log4J config for Spring JTA transactions

We use this Log4J config to display JTA info: <category name="org.springframework.transaction"> <priority value="DEBUG"/> </category> The resulting log entries are of the type: 15:36:08,048 DEBUG [JtaTransactionManager] [ ] Creating new transaction with name [class]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 15:36:09,564 DEBUG [Jta...

A Maven2 mojo that uses Hibernate: how to control logging?

I have a maven2 plugin that calls hibernate as configured in a Spring context. Hibernate, of course, logs. I'm trying to control the logging. 0 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.2.6 So, I explicitly put slf4j into the plugin's dependencies, along with the log4j package. And I configure Spring to use log4j, ...