spring

What is the proper way to use Spring beans inside objects which are not managed by Spring container?

I have a Spring bean (singleton scope if it matters), lets call it FooService. And I have an object Bar which is not managed by Spring but it want to use FooService. How to implement this cooperation in the best way? (Let's assume that I don't like the solution with applicationContext.getBean()). ...

Spring 3 - Create ExceptionHandler for NoSuchRequestHandlingMethodException

Using Spring 3, I like to create an exception handler using the ExceptionHandler annotation that will handle "no page found (404)" requests. I am using the following code to do this. But when I point to a URL that does not exist, the default exception handler defined by Spring is being invoked. It might be that I'm handling the NoSu...

Spring 3 Annotations - HibernateDaoSupport - Repository Requires Session Factory

I am getting an exception saying : java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required when trying to use the @Repository annotation on a HibernateDaoSupport class. The error message is straightforward, in order to create the Repository it needs a sessionFactory. However,I have defined a s...

How to register handler interceptors with spring mvc 3.0?

It should be easy: <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> <list> <ref bean="myInterceptor" /> </list> </property> </bean> but this way the interceptor isn't called. ...

double-initialization of spring beans in jetty 7.1.4

When I start a webapp that has a spring configuration in jetty, I see two calls to initialization (@PostConstruct methods). web.xml declares a ContextLoaderListener and provides contextConfigLocation. This seems wrong. (spring 3.0.3). Is there something I've done? EDIT My web.xml calls out both the DispatcherServlet and the org.spring...

ORM using Hibernate's annotations with Spring

Hi! I'm trying integrate spring with hibernate but catch exception on project start. Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.domain.Worker"/ My config: from spring <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="clos...

configure hibernate with spring

Hi! I'm trying integrate spring with hibernate but catch NamingException: Context is read only stacktrace WARNING: Could not bind factory to JNDI javax.naming.NamingException: Context is read only at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903) at org.apache.naming.NamingContext.createSubcontext(Naming...

Spring Transactional Unit Tests - Hibernate Queries Not Rolling Back

I am using Spring 3, and Hibernate 3.5, I am not getting my transactions to rollback in the test environment, which has me worried they would not be rolled back in production either. Test Class: @ContextConfiguration(loader = MyConfigurationLoader.class) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollb...

Tomcat unable to find jsp in war file

I recently switched one of my static html files to a Spring controller that uses a JSP to render its view. I use jetty to test locally and local testing shows the page rendering fine. Upon deploying to our test server, which uses Tomcat 6.0.26, I get the following exception: javax.servlet.ServletException: Could not get RequestDispatche...

Ibatis: Define a getter as a property on a result

Hi, Can I define a getter as a property on a result in Ibatis? like <resultMap id=.... class=...> <result property="getSomeValue" column="valueColumn"/> .... I haven't seen this in documentation so far. ...

ContextLoadListener and DispatcherServlet

Is it ok to define both the ContextLoadListener and DispatcherServlet in the web.xml or are they mutually exclusive? ...

BeanInstantiationException:Cannot convert type from java.lang.String to required type --- idref tag

Hi All, i am new to spring and trying to understand the functionality of idref tag My config file is pasted here: <bean id="AudioSystembean" class="com.springexample.AudioSystem"> <property name="price" value="200"/> </bean> <bean id="Vehicle1" class="com.SpringExample.Vehicle1"> <property name="vehicleType" value="CAR" /> <property ...

Right out of the box cache-control header filter?

Is there a right of the box cache-control response header filter that will enable me to set those cache headers on my static resources without me having to build my own Filter? It seems like such a common task. Is there a Spring filter ? I am currently using Tomcat 6.0 and using Spring's ShallowEtagHeaderFilter to set etag to my resource...

Why package name cannot be parsed in jar?

Hi all! I'm working at a spring-integrated Eclipse RCP application,but i got a error while spring framework initializing at application start. My code in Activator.java below: ... public void start(BundleContext context) throws Exception { super.start(context); initializeApplicationContext(); plugin = thi...

XT Ajax Framework Help

Hi, I have been playing with XT Ajax framework and tried to replicate this dwr dynamic text example: http://directwebremoting.org/dwr/examples/index.html (specifically the dynamic text tutorial) My question is this: How do I retrieve the value from the input text field in my Ajax Handler for further processing? Any help will be very muc...

Spring MVC equivalent for Struts 2 Preparable

Is there something similar to Struts 2 Preparable interface / prepare method in Spring 3 MVC? That is, a method executed every time the controller is requested. Thanks. EDIT: What I want to achieve, for example, is to fill a group of properties depending on the user I am, for every request in this controller, trying to avoid this: @C...

Spring: Using builder pattern to create a bean

I use ektorp to connect to CouchDB. The way to build an ektorp HttpClient instance is to use builder pattern: HttpClient httpClient = new StdHttpClient.Builder() .host("mychouchdbhost") .port(4455) .build(); I am relatively new to Spring. P...

Spring Controller init method

Hi there, as far as I understand are spring controllers stateless right? If I set a field to a value, this is revoked by the next call. Is there a possibility to add a init-method or something? A method which is called once, when my controller is triggerd? I'm using spring 3.0 and a annotation configuration atm. ...

Spring's application context prevents other applications from starting in same servlet container

I have two web applications running in same Servlet container (Tomcat), A and B. These two connect to each other using Spring Remoting. On startup, B needs to call A to open a connection automatically, it's basically a really simple authentication call. However since B is (in my case) loaded before A, B's application context blocks unti...

[Spring Security 3] I want to setting within DB-URL and Role

what's the problem???? package com.sqlmap; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.sql.DataSource; import org.springframework.beans...