spring

Calling A Method After all SpringBeans and ApplicationContext have been initialized

Hi, I have a method in a complex java program that needs to be called immediately after the web ApplicationContext and SpringBeans have been initialized. I've tried toying around with <bean id="..." class="..." init-method="initialize"> but this method will call a applicationContext.get().getBean(beanId); method. I was wondering if ...

Should I close connection when using SessionFactoryUtils

If I want to use SessionFactoryUtils to get Connection directly to execute some SQL statement, and join the same transaction. Like this: SessionFactoryUtils.getDataSource(getSessionFactory()).getConnection(); //some logic after Connection retrieved Do I have to close Connection by myself? or just let it be and Hibernate Session will h...

How to get Spring to autowire integration test class using multiple contexts?

One of my integration tests uses multiple Spring context files. It seems that Spring only autowires in beans from the first context and not the second. Does anyone know what I am doing wrong or how to work around the problem? @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:/META-INF/spring...

[Spring-Flex][ACEGI] Error or no security...

Hi all , As I say in the title of my question, I don't succeed in configuring Spring Security... I've followed two articles written by James Ward or Jettro Coenradie but I still don't have it ! First I tried to make all this working in a fake project, and it worked well, thant I tried in the "real" project. The configuration files are ...

Petclinic spring-mvc example not building

I just co https://src.springframework.org/svn/spring-samples/ and tried to build petclinic. I did: mvn clean install mvn eclipse:eclipse I imported to eclipse but: The import org.aspectj cannot be resolved What are the odds that the pom.xml is wrong and I have to add the dependency myself? ...

Spring, JndiTemplate externalizing provider URL

Hi, My project requires the Initial Context Factory and the provider URL to be loaded from a properties file. Here is my Spring configuration <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate" lazy-init="true"> <property name="environment"> <props> <prop key="java.naming.factory.initial">${ini...

Stop URITemplate expansion when using Spring RESTTemplate

I am using the Spring RestTemplate to make calls to a Apache Solr index. I form a request string manually and don't supply any intentional {variable_name} template expansion variables. Part of the query is the term {!lucene q.op=OR}. Unfortunately this gets processed by the URITemplate engine as part of a restTemplate.getForObject call. ...

Why is an object found by id in JPA, but not through a JPQL query?

I have a JUnit 4 test case with the Spring @Transactional annotation that saves an object, and then attempts to find it. The test case passes when I use this implementation: @Override public EventSummary findEventSummaryById(Integer id) { return em.find(EventSummary.class, id); } It fails when I use this implementation (and then c...

Per-user TimeZones in a webapp using Spring

Hello, I have a web application which has different users logging in to view transactions. I want to be able to let the users set their own time zone and then have dates on forms be bound using the user's timezone so that they can search transactions in a database and have the results adjusted depending on what time zone the user is in...

Several operation on DAO execution

I try to execute several queries in one DAO-method. Test is FAILED (the data are not updated). Logs without exceptions. public List<Domain> getNewDomains(final int maxAllowedItems, final Date timestamp) { return getJpaTemplate().execute(new JpaCallback<List<Domain>>() { @SuppressWarnings("unchecked") public List<Do...

Possibility to use <c:import> with spring views

I was wondering if there is a possibility that I could use the JSTL function to import spring Views. so something likes this: <div id="contentHolder"> <c:import url="/foo.do?bar" /> </div> In the XML stands: <!-- Viewresolver --> <b:bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver...

Spring @Transaction method call by the method within the same class, does not work?

I am new to Spring Transaction. Some thing that I found really odd, probably I did understand this properly. I wanted to have a transactional around method level and I have a caller method within the same class and it seems like it does not like that, it has to be called from the separate class. I don't understand how is that possible. I...

Autowiring Validation without Naming Controllers After Models in Spring

Very new to spring and working my way through validation. I have examples working where I actually implement the spring Validator class, but am working on getting examples working without implementing the Validator class and instead using annotations directly on model class attributes such as @NotBlank and @Email. My question is this. ...

MySQL view to CSV file using Java, Spring, and Hibernate

I've been asked to output a CSV file from a view in MySQL. The app I currently am writing uses Spring and Hibernate to create the database, but the view is just handed to me. Hibernate doesn't know anything about this view, but I'd want to do something like this: public List<Object> getCsvView() { return (List<Object>) getHibernate...

Sending msgs in my crud spring-mvc

I am learning spring-mvc and I am doing a simple crud. I have a list of items with a big add button on top of it. When the user clicks add it will redirect to /item/add where the view is a form. Now, when the user loads a new item I want to show a msg in the list saying something like: "Item added successfully" I noticed that I c...

Java Singleton Design Pattern : Interview Question

Hi, I had an interview recently and he asked me about Singleton Design Patterns about how are they implemented and I told him that using static variables and static methods we can implement Singleton Design Patterns. He seems to be half satisfied with the answer but I want to know How many different ways we can implement Singleton...

Unable to locate Spring NamespaceHandler for XML schema namespace [http://jboss.org/xml/ns/javax/validation/configuration]

I am using spring 3, hibernate validator 4. My unit test is running fine. But i am getting this(see below) for my functional test, have i miss out some dependencies? Dependencies i had added for hibernate validator: validation-api-1.0.0.GA.jar hibernate-validator-4.0.2.GA.jar Here's my the content of validation.xml: <?xml version="...

ROO IDT Push In results in a "Requested Resource not found"

I have a scaffolded controller with a populate method. I wanted to customize this method so I did an IDT 'push in' and re implemented it. Everything compiled and roo updated the aspect, but when accessing the controller with the browser I get a "Requested resource not found". I'm using SpringSource tc Server Developer Edition v2.0. No e...

Hibernate using Query via Spring injection

Hello all, Beginner here to hibernate, spring. Followed tutorial here to setup hibernae + spring + struts2 project: http://splinter.com.au/blog/?p=224 I wanted to prepare queries. So I tried following: Services.java public class Services { protected SessionFactory sessionFactory; public void setSessionFactory(SessionFactory value) ...

Grails dependency injection no longer working after upgrade to Grails 1.3.3

Hi All, Project setup is Flex 3-BlazeDS-Spring Flex Integration-Grails Dependency injection in my Service classes was working just fine with Grails 1.2.1, when service methods were called from my flex client. When I upgraded my project to 1.3.3 yesterday using the regular 'grails upgrade' command, everything went well but once I start...