spring

MethodInvokingBean question

I have a method invoking bean which calls a method to perform some sort of initialization on a targetBean and another bean who needs a twitter class albeit initialized. <bean id="twitter" class="twitter4j.Twitter"></bean> <bean id="twitterInjector" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> ...

Spring 3.0M4 and passing objects as parameters to POST

Hi guys, I'm quite sure this has to be in the docs somewhere, but I've looked for days and haven't spotted it. I'm probably staring myself blind when it's right in front of me, so sorry for asking an abvious question, but.... @RequestMapping(method = RequestMethod.POST) public ModelAndView post(@ModelAttribute("user") User user) { Mo...

JaxWsPortProxyFactoryBean query timeout

Hello I'm using a JaxWsPortProxyFactoryBean (from Spring framework) to access a web-service. I would like to change the timeout of the http queries I'm sending. Is there a way to do this? Thank you by advance for any help ...

Spring load time weaving not detecting class annotated with @configurable

I'm having trouble getting AspectJ to perform load time weaving on a class annotated with @configurable in my main project. No fields get set and none of the setters are touched. I don't think there's trouble with the configuration itself, because I've extracted the configuration and tested it on a smaller sandbox project. Just for the...

How can i get generic type from a Class object ?

Hi, Suppose the following class public class Message { // some code } And a Spring Validator implementation (no Spring knowledge required) public class MessageValidator implements Validator { public boolean supports(Class clazz) { if(clazz.isAssignableFrom(Message.class)) return true; else if(<AN...

using JDBC Connection from presentation tier in 2-tier and 3-tier applications

I am writing a module that will be used in different applications (2-tiers and 3-tiers). I'll need to connect to a DB. so, I made the module requires a java.sql.Connection object as a parameter when used with a 2-tier application. there's no problem there. the problem i'm facing is that in case of a 3-tier application, the module will b...

How to mock a static variable in java using JMock

Hello, I have a Unit testing problem where a class has a static variable which wants to load the Spring Application Ctx. This class DOES NOT come out of the Bean Factory and I cannot change this fact. static ApplicationContext applicationContext = ...; This works fine, but is hard to JMock, or atleast I don't know a way and until I...

Accessing the JDBC ResultSet concurrently in Spring

I am processing a large amount of data in a Spring JDBC DAO. The DAO directly returns an Iterator over the objects which operates on a bounded BlockingQueue using take() while the retrieval operation is happening in a separate thread (using an ExecutorService). Inside this thread I see the following behaviour: the retrieval works but ce...

Spring MVC; avoiding file extension in url?

I just started with Spring Web MVC. I'm trying to avoid file extenstions in the url. How can i do this? (I'm using Spring 2.5.x) Bean: <bean name="/hello.htm" class="springapp.web.HelloController"/> I want it to be: <bean name="/hello" class="springapp.web.HelloController"/> I cannot get it to work. Any ideas? Edit: Url-mapping ...

"NoClassDefFound exception: Could not initialize class" error help!

When I run my project, I get numerous outputs of this error: Sep 9, 2009 8:22:23 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet Jersey threw exception java.lang.NoClassDefFoundError: Could not initialize class SpringFactory at com.point2.prospect.persistence.hibernate.HibernateTran...

How to unit test a Spring MVC controller using @PathVariable?

I have a simple annotated controller similar to this one: @Controller public class MyController { @RequestMapping("/{id}.html") public String doSomething(@PathVariable String id, Model model) { // do something return "view"; } } and I want to test it with an unit test like this: public class MyControllerTest { @Test ...

In what case would a programmer get the webApplicationContext out of DispatchServlet?

I notice that there is getWebApplicationContext in org.springframework.web.servlet.mvc.AbstractController. This means that spring programmers can use getWebApplicationContext to access beans in the spring IoC container. However, I never see people use this way to get beans in all the spring MVC tutorials. So here comes my question, in ...

Spring.NET Expression that References an Object Definition

I'm trying to reference another object I've defined in a Spring config file from within an expression. Specifically, I'm trying to populate a property with the value of an expression where I call a method and then a property on the object returned from that method. I've tried the following (names have been changed): <property name="Nu...

Flex + Spring + BlazeDS + Glassfish + OpenMQ - How do you configure the web-application-config for OpenMQ?

I have the spring-flex-testdrive example (JMS chat application which uses a Topic to pub/sub messages) to work on Tomcat with ActiveMQ now I want to run this example on Glassfish with OpenMQ. This is a related sample config I found online but it doesn't quite work for the Flex/Glassfish/OpenMQ/BlazeDs/Spring-Integration technology com...

Displaying a result of a query from the database in increments

I want to display a list of all the users in my site but I only want to display 10 people per age. I don't know how exactly to do this. I know how to do it by just displaying all the users in one page but that's not very good is it? If I do it with the code I have now, it will only get the first ten users over and over again. I want t...

Java Spring MVC stateless-to-stateful handover

Although I have tagged this as a java/spring question it can be easily asked of any mvc framework with stateless controllers. I know rails uses simple stateless controllers for instance so perhaps you guys know how to best solve this problem. I can best describe the problem with java/spring mvc which is the implementation - forgive the ...

retrieve proxied instance from spring

I am interested in getting the class being proxied from spring, rather than the proxy. ie: public class FooImpl<KittyKat> { @Transactional public void doStuff() { getBar(); // java.lang.ClassCastException: $Proxy26 cannot be cast to // com.my.foo.Bar } } public abstract class AbstractFoo<T...

Hidden features of Spring framework ?

After seeing many hidden features about programming language, i would like to know hidden features of Spring "de facto" framework. As you know, Spring documentation hides many features and would be nice to share it. And you: what hidden feature of Spring framework do you know ? ...

Deploying a CXF web service in Spring Framework

After running through the CXF samples I had a simple web service up and running fine. However I would like to integrate it with a Spring web application inside a servlet container. After updating the servlet.xml config file: <jaxws:endpoint id="HelloWorldService" implementor="path.to.webservice.HelloWorldImpl" endpointName="e:HelloEndp...

Spring: How can you declare name/value pairs outside a Map?

I have a need to set a collection of name/value pairs inside my application - representing effectively a many-to-many map (i.e. keys can have multiple values and vice-versa), so Hashtable and Hashmap don't really work for me. I'd like to be able to declare these via Spring in a format similar to <props>, but of course that won't work di...