spring

Package and run a Java application with spring dependencies

I built a stand-alone Java application that has a bunch of dependencies (Apache Commons libs, etc) as well as a dependency on the Spring framework, which in turn has a bunch of dependencies. I built this in Eclipse, where it runs fine. Now I need to deploy it to production and so I'm trying to figure out the best way to package it with ...

Spring beans redefinition in unit test environment

Hi all, we are using Spring for my application purposes, and Spring Testing framework for unit tests. We have a small problem though: the application code loads a Spring application context from a list of locations (xml files) in the classpath. But when we run our unit tests, we want some of the Spring beans to be mocks instead of full-...

Simple autosave for Spring MVC form

I have one page form done with Spring MVC. User has to register first and I would like the form to be saved automatically so user can come later to finalize it. Traditional form submission with a timer is not what I'm looking for. Instead, I am planning to use some ajaxy way to send fields to the server at each onFocus event. Any sugges...

Grails: Accessing spring beans in the destory closure of Bootstrap code?

Hello, I'm looking to access a bean in my destroy closure in the Bootstrap.groovy of my grails project. Any ideas on how to achieve this? I seem to have no access to servletContext...? ...

Spring introductions with dynamic implementation

I am trying to use Spring framework to dynamically implement a specific interface (lets call it I) for a class (let call it C). In Spring this is called introduction (mixin in other languages). In compile time C doesn't implement I. Using the @DeclareParents annotation I can do it in AspectJ syntax. The problem is that the actual imple...

Create a Java File object (or equivalent) using a byte array in memory (without a physical file)

I want to create a Java File object in memory (without creating a physical file) and populate its content with a byte array. Can this be done? The idea is to pass it to a Spring InputStreamSource. I'm trying the method below, but it returns saying "the byte array does not contain a file name.". MimeMessage message = mailSender.create...

How to integrate jBPM and Spring via scripts and EL.

I'm using/anticipating the following technology stack: JSF Seam jBPM Spring Of course, I'd like Seam to access Spring beans directly and have got this much to work fine. I'd now like to move down into jBPM and develop a proof of concept process definition that accesses Spring beans to perform actions and make decisions. To promote s...

Error while splitting application context file in spring

I am trying to split the ApplicationContext file in Spring. For ex. the file is testproject-servlet.xml having all the entries. Now I want to split this single file into multiple files according to logical groups like : group1-services.xml, group2-services.xml I have created following entries in web.xml : <servlet> <servlet-name>t...

Permissions checking in server-side API

Hi all, our product is built on a client-server architecture, with the server implemented in Java (we are using POJO's with Spring framework). We have two API levels on the server: the external API, which uses REST web services - useful for external clients and integrations with other servers. the internal API, which uses pure Java cl...

Split Application Context File in Spring

Hello, I would like to have step-by-step information on : how to split the ApplicationContext file (eg.: myapp-servlet.xml) into multiple XML files in Spring with some examples ? I have tried configuring web.xml with "ContextLoaderListener" and have contextConfigLocation like : <init-param> <param-name>contextConfigLocation</...

Spring-modules caching not working... silently.

I'm trying to use declarative caching from the Spring Modules project. It's not working ie. nothing appears to be getting cached. Here's my configuration: <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> </bean> <bean id="cacheProviderFacade" class="org.springmodules.cache.provider.eh...

Putting Spring integration tests in different classes and packages

I am using AbstractTransactionalSpringContextTests to run spring integrations tests. The spring context is loaded just once and then all the tests are run. How do I do the same if I want my tests to be in many classes and packages. Of course, the spring context should be loaded just once for all my tests (in all classes and packages), a...

How can I improve my junit tests

Right my junit tests look like a long story: I create 4 users I delete 1 user I try to login with the deleted user and make sure it fails I login with one of the 3 remaining user and verify I can login I send a message from one user to the other and verify that it appears in the outbox of the sender and in the inbox of the receiver. I...

Is there a static way to get the HttpServletRequest of the current request

I am using Spring annotations, I can pass the HttpRequestContext from the Controller to the Service. I am looking for a static way or any better solution than passing RequestContext around. ...

Having spring bean properties refreshed automatically from properties file

I'm using Spring 2.5.6. I have a bean whose properties are being assign from a property file via a PropertyPlaceholderConfigurer. I'm wondering whether its possible to have the property of the bean updated when the property file is modified. There would be for example some periodic process which checks the last modified date of the pro...

Spring as a glorified factory; is this acceptable?

I just inherited a Java application and upon inspection of the code, I'm seeing what IMHO is a bastardization of the Spring framework. You see, the Java team seems to have an aversion to interfaces, so we end up with things like this: @Autowired private SomeConcreteFinalClass _myField; There's no Spring configuration, no bean defined...

Spring MVC with an externally rendered PDF as the view

Is there a built-in mechanism in Spring that would allow me to display an externally rendered PDF as a view? I've fetching PDF via a webservice (returned an attached DataHandler) so I'm not looking to subclass AbstractPdfView to render PDF. This isn't a hard problem to solve on its own; it would be easy enough just to write the PDF to...

Splitting applicationContext to multiple files

What is the correct way to split Spring's configuration to multiple xml files? At the moment I have /WEB-INF/foo-servlet.xml /WEB-INF/foo-service.xml /WEB-INF/foo-persistence.xml My web.xml has the following: <servlet> <description>Spring MVC Dispatcher Servlet</description> <servlet-name>intrafest</servlet-name> <servlet-class> ...

How can I access the ApplicationContext from within a JAX-WS web service?

Similar to How can I access the ServletContext from within a JAX-WS web service?, is there a way to access applicationContext, easier than this? import javax.annotation.Resource; import javax.jws.WebService; import javax.servlet.ServletContext; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.MessageContext; import or...

Spring PropertyPlaceholderConfigurer for .NET web.config/app.config

Is there an equivalent for the Sprint PropertyPlaceholderConfigurer for .NET app.config or web.config files? We are currently using different version of app.config for different environments (web.prod.config, web.qa.config, etc.) which get renamed when the app is deployed. However, most of the config file is the same for each environme...