spring

What exactly is Spring for?

I hear a lot about spring, people are saying all over the web that Spring is good framework for web development. But what exactly is it for? How can I use it for my Web-Java application any examples. ...

Spring parent and child resources

Hi Gurus I am using spring+struts2 and I have a large number of action classes that required a single service (mailService). Instead of injecting service into these action classes, I am wondering is there a way to create a parent class and inject the resources and then have all these classes extending the parent. So I do no need to repe...

Resolve message from property file

How can we resolve a message from properties file? Just like when we use errors.reject ( "xyz.abc" ); in this case "xyz.abc" is resolved from the property file specified in messageResource ( servlet.xml ) ...

Test Cases: Mocking Database using Spring beans

Our application has a service layer and a DAO layer, written as Spring beans. While testing the Service Layer- I do not want to depend upon a real database so I am mocking that by creating a 'Mock' Impl for the DAO layer So when I am testing the Service layer- I chain the Service layer beans to the Mock DAO beans And in Production- wil...

Error reading configuration file for JAAS Authentication Provider in Spring

Really ripping my hair out on this one. I have a JAAS Authentication Provider configured for my Spring webapp. I've created a bean definition for it as follows: <beans:bean id="jaasAuthenticationProvider" class="org.springframework.security.providers.jaas.JaasAuthenticationProvider"> <custom-authentication-provider /> <b...

Spring, log4j and JBoss4

I'm running JBoss 4.2.3.GA, and have a web app that uses Spring and Log4j. I've set up Spring's Log4jConfigurer, but am having a problem since JBoss's log4j file is not on the classpath. It's at jboss.home/server/defaul/conf/jboss-log4j.xml. So, without hard-coding the path in Log4jConfigurer, how can I get Spring to use JBoss's log4j fi...

Spring MVC support for dynamically populating select box

Does Spring 2.5 (or 3.0) include support for dynamically populating a select list based on what the user selects from another form element? For example if you have a form with 2 select for (Car) Make and Model. When the user selects a Make from the first list, the Model select should get populated with the available Models for that Make...

Spring security pre-authentication for development mode

While developing an application it's quite useful to be able to quickly login as different users, with different roles, to see how the application presents itself. Typing usernames and entering password is no fun, and a waste of time. What I'd like to do is: add a page/panel with a list of available usernames; clicking on a username w...

Parent Contexts in spring based web-app

Hey, I'm deploying my EAR/WAR file to Jboss 4.2 and i've wired the web.xml to load the common application context file, so i can share common bean via parent spring context. <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc...

SpringAOP-generated Dynamic sublcass is missing annotation

I'm trying to use Spring AOP to inject behavoir into an object. The target object has a single method which is the join point for this new behavior. That method also has a custom annotation that I want to be able to read from other unrelated code. Because my class doesn't implement an interface, Spring is using CGLIB to dynamically sub...

Neither BindingResult nor plain target object for bean name available as request attr

Hi Experts, I have this controller code which is throwing the above mentioned error. It was working fine till yesterday, I have no clue what colleague did to this code and today I am seeing the error: Neither BindingResult nor plain target object for bean name 'sideForm' available as request attribute Can you please suggest me where...

Can I have multiple security contexts with spring security?

I have one security context definition that uses PreAuthenticatedProcessingFilterEntryPoint for the flex part of my application. How can I have another definition that will use standard form login with html forms for another part of my application? Here's what I currently have: <?xml version="1.0" encoding="UTF-8"?> <beans:beans xml...

SpringIDE and Eclipse Galileo 3.5

Hello, good fellas. I have another very basic question that I need help with. I wanted to try out the great Seam Framework, and I managed to add the JBoss Tools plug-ins to my copy of Eclipse Galileo 3.5. After spending some time using Seam, I decided I wanted to try the Spring Framework. My question is: Apart from adding SpringIDE to ...

Spring - Skip init-method in unit test

I would like to test Spring configuration in Junit test case without invoking init-method on configured beans. I could of coded my init-methods to skip actual work based on system property which could of been set in test case but I am looking for a cleaner solution. ...

Guice Custom Scopes and Spring managed beans

(x-posted to guice mailing list) I'm trialling Guice on a new library that will live in an existing application. All our apps right now are spring apps and we have some common code that is tied to spring, mainly to do with the thread model we tend to use. It basically gives us (what could be seen as) a logical thread. So we can throw j...

Spring Security UserDetails Best Practice

I am using my own implementation of the UserDetailsService interface to load a User object from the Database and place it as UserDetail into my SecurityContext. The User object is then a detached Hibernate object. When I want to access lazy load relations of the authenticated User I need to get it from the SecurityContext and attach it ...

Spring @Transactional Annotation Best Practice

We are currently discussing the Best Practice for placing the @Transactional annotations in our code. Do you place the @Transactional in the DAO classes and/or their methods or is it better to annotate the Service classed which are calling using the DAO objects? Or does it make sense to annotate both "layers"? ...

Spring MVC Domain Object handling Best Practice

Lets assume a simple Spring MVC Controller that receives the ID of a domain object. The Controller should call a service that should do something with that domain object. Where do you "convert" the ID of the domain object into the domain object by loading it from the database? This should not be done by the Controller. So the service m...

Spring JPA Exception Translation

I have configured my application context as stated in the spring documentation to enable Exception Translation from jpa exceptions to spring DataAccessException. Should I also provide the implementation of PersistenceExceptionTranslator? If so, can anyone give me an example of how this is done? ...

What would you go for a back-end web application: Flex, GWT, JQuery?

Hi, I should build a web application for back-office purposes and one of the main requisites is a good UI. On server-side I'll use Java very likely Spring framework, depending on what I'll be using client-side. I think to basically have 3 choices for client-side: a "normal" web application, meaning JSP pages, using JQuery framew...