spring

EntityManager merge/persist problem

I'm having this strange problem where my merge() or my persist() functions are not being reflected in the database. My JdbcProductDao.java: @Repository("productDao") public class JdbcProductDao implements ProductDao { @PersistenceContext private EntityManager entityManager; public JdbcProductDao(){ } public Produc...

Connection with MySql is being aborted automaticly. How to configure Connector/J properly?

I read this advice from error message: You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. I'm using Spring and JPA. W...

Multilingual web application problem

Hi all, I am working on Spring web application and my application is multilingual. I have created the ResourceBundle property files as messages.properties and messages_ar.properties. In my start page, I have set by default the locale to English. through: <fmt:setLocale value="en" scope="session"/> On the same page, I have provided u...

Not showing error messages when validated using @valid(JSR-303) in Spring MVC

I have specified <mvc:annotation-driven /> in dispatcher-servlet. I am not using @InitBinder. And I am using @valid annotation for validation in controller's method like @RequestMapping(method = RequestMethod.POST, value = "new") public String save(@Valid Article article,ModelMap model) { //code here } And validation works fine...

WARN: Could not register destruction callback

15:11:14,676 WARN FacesRequestAttributes:121 - Could not register destruction callback [org.springframework.beans.factory.support.DisposableBeanAdapter@1059fd6] for attribute 'purchaseController' because FacesRequestAttributes does not support such callbacks This warn message appears in my log a lot. For every managed bean whenever...

Dependency Injection problem with EntityManagerFactory + jpadaosupport

Right now I'm having a problem injecting a entityFactoryManager into my jpadaosupport extended class. My configuration is below: <bean id="productDao" class="springapp.repository.JdbcProductDao"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> The above configuration for this bean works fine however w...

Trying to create REST-ful URLs with mulitple dots in the "filename" part - Spring 3.0 MVC

I'm using Spring MVC (3.0) with annotation-driven controllers. I would like to create REST-ful URLs for resources and be able to not require (but still optionally allow) file extension on the end of the URL (but assume HTML content type if no extension). This works out-of-the-box with Spring MVC as long as there are no dots (period/full-...

Dynamic injection of bean properties based on a locale variant in Spring

Consider the following class DialgBean.java, which defines the properties of a dialog box on a web page. Below is the class and its bean definition public class DialogBean{ private int height; public void setHeight(int height) ... } <bean id="dialogBean" class="org.springhelp.DialogBean"> <property name="height" value="${dial...

Compiling JasperReports automatically on change

Hi, I am working on a web application. We are using jasperreports. Compiling jasperreports on every call is an overhead and takes considerable time (4-7 seconds). We thought of precompiling the jrxmls using Spring but still have the ability to re-generate if the jrxml is changed/modified. Has anybody done this before? If yes, how. Thanks...

ManyToMany assoicate delete join table entry

I use these two entities to create a new user and groups it associates: @Entity @Table(name="usertable") @SuppressWarnings("serial") @Searchable public class User implements Serializable { @GeneratedValue(generator="userIdSeq") @SequenceGenerator(name="userIdSeq", sequenceName="usertable_id_seq") @Searcha...

Delay task:scheduler first execution in Spring 3

I have a simple application that uses Spring 3 for dependency injection. I have a JFrame for the user to look at and some background tasks for synchronizing with a back-end server and local database maintenance. This is the relevant part of my application context: <task:scheduler id="scheduler" pool-size="1"/> <task:scheduled-tasks sc...

Caching a resultset

My app will retrieve a countylist from MySql using a datasource bean. Since all pages will potentially use the same recordset every time I could store the countrylist as a List in some global bean, safe in this case. I could manage to refresh the list any time I want... but when things become more complex what is the best strategy for it...

Trying to destroy beans in the correct order with Spring

Hi, I've got a web app with Spring set up to create my hibernate session factory (singleton) and session and transaction (both are request scoped), but it is destroying the session and transaction in the wrong order. How can i configure it so that the transaction is destroyed before the session? Here's my spring applicationContext.xml fi...

When does Spring create instances of objects that are injected

Spring does DI and creates objects so that your program need not worry of creating objects. But the question here is when an instance of injected object is created. Is it when the main program makes use of the instance or at the time an instance of main program is created. ...

How to get rid of LazyInitializationException with Wicket JPA/Hibernate integration (with Spring)

Hi, i'm developing an application using Wicket as the view layer and JPA(Hibernate) as ORM. building the UI has been fun (even with ajax) using Wicket. My problem comes from integrating the persistent objects on edit pages (readonly pages are no problem using a LoadadableDetachableModel). I'm using the OSIV filter from spring to provide...

Add messages with Spring

I have seen that I can add errors and render them via <form:errors /> tag and addError() method of BindingResult class, but I wonder if there is something similar to send information messages to the JSP. I mean, I want to add messages when the operation has been successful. I know I could do it by sending an error, but it would make no ...

Supply Spring managed objects to non Spring managed Objects?

I have a data structure representing a CSV file containing thousands of config settings. The structure is a Java class file with instance variables to represent the records in the file (ie: a HashMap) and the state of the file (errors, warnings, etc). These classes are not created by Spring as they have state. I would like the class t...

spring 3 AOP anotated advises

Trying to figure out how to Proxy my beans with AOP advices in annotated way. I have a simple class @Service public class RestSampleDao { @MonitorTimer public Collection<User> getUsers(){ .... return users; } } i have created custom annotation for monitoring execution time @Target({ ElementType.M...

are there any potential issues with obfuscating an application?

I am building a spring mvc web application. I plan on using hibernate. I don't have much experience with obfuscating etc. What are the potential downsides to obfuscating an application? I understand that there might be issues with debugging the app, and recovering lost source code is also an issue. Are there any known issues with the...

How to check for resource file existence at run-time [grails]?

I need to test whether a resource file (an image, for instance) exists and if not, I will display another image. My GSP view code looks like: <% if (resExists(dir: "images", file:"img.jpg")) {%> <img src="${g.resource(dir:'images',file: 'img.jpg')}"> <% else { %> <img src="${g.resource(dir:'images',file: 'noimg.jpg')}"> <%}%> How ...