spring

Cannot use Spring LDAP with Spring Security

Hi, I want to authenticate users against our AD so I understand that I need spring security and spring ldap. Here is what is in my POM: <groupId>org.springframework.security</groupId> <artifactId>org.springframework.security.core</artifactId> <version>3.0.0.RELEASE</version> </dependency> ... <dependency> <groupId>org.springframew...

Spring MVC 2.5, JsonView, and ModelMap

I want many of my controllers to create and return ModelMaps and to have these ModelMaps subsequently sent to/processed by a JsonView. (These controllers will service AJAX requests.) I assume I need setup a ViewResolver; what is the best way to do this? Is there a better alternative to Spring-Json View? EDIT: How do I wire a view w...

How to reuse test code from open source project

I'm writing a unit test for a custom subclass of org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T> and I need a stub implementation of org.springframework.http.HttpInputMessage. Looking through the Spring unit tests in the SVN repository, I found the class MockHttpInputMessage, which does exactly what I want. Now...

Configuring an @Autowired bean with a property value

I've got an @Autowired bean and need to pass in a String value from a property file. What is the best way to do this? ...

Is there any advantage to use spring DataAccessExceptions instead of JPA PersistenceExceptions ?

I'm using JPA in my DAOs outside of Spring . The Spring framework defines DataAccessExceptions that are independent of databases implementations. Is there any advantage for a non Spring user to use the Spring data access exceptions instead of those of JPA ? I guess that the Spring DataAccessExceptions exist since Spring handle several u...

using http request parameters in spring mvc

I am generating a table of data from a simple list of objects that I am displaying in a jsp page. Each row has a View hyper link attached to it. When the user clicks on the hyper link I need to send them to another controller (hooked up via a bean) to display more detailed information. I am trying to pass a unique id but in the controlle...

Do I understand Spring @Transactional behaviour correctly?

I was hoping someone could confirm my understanding of transaction behaviour in a Spring service. Firstly, am I correct in believing that When using TransactionManager, all services which result in persistence to the database must be invoked from within a @Transactional method in order for the update to persist to the db? Eg, Given the...

In Spring can you alter property placeholder values using a BeanDefinitionDecorator?

I have a BeanDefinitionDecorator that makes modifications to properties that a user would set on a bean. It works fine; except if the bean is using placeholders. I am trying to find a strategy to modify those values while still have access to the original value at runtime. An example of what this would look like in XML: <bean id="bean"...

AbstractTransactionalJUnit4SpringContextTests: can't get the dao to find inserted data

I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal is really simple: insert some data into the database using the simpleJdbcTemplate, read it back out using a DAO, and roll everything back. JPA->Hibernate is the persistence layer. For my tests, I've created a version of t...

FileSytemResources in Spring Framework

Hi, I am trying to retrieve xml file (containing bean definition) in my Spring MVC project. If I have the xml file under WEB-INF directory, then what path should I put into FileSystemResource in my servlet to retrieve the xml? i.e. BeanFactory factory = new XmlBeanFactory(new FileSystemResource("xml")); Thanks ...

Spring Map a file to a Url / URI

I have a spring webservice for which I have the schema in a directory as: WebRoot/DataContract/person.xsd WebRoot/DataContract/sub-person.xsd Where sub-person.xsd is included in person.xsd that is: in Person.xsd: <xsd:import namespace="http://www.mynamespace.org/xml/sub-person" schemaLocation="sub-person.xsd"/...

@Resource annotation not injecting a subclass

The @Resource annotation for a service is not injecting a subclass unless I explicitly include the @Component annotation in the subclass. Is there a way to request a subclass be "wired" with the parent @Resource without requiring annotations in each child class? The way I discovered this was by creating a subclass and failing to include ...

Hibernate sessionFactory rebuilt for each unit test (using spring framework)

I'm using Spring's AbstractTransactionalDataSourceSpringContextTests for my persistence unit tests and my problem is my tests are too slow: 1 method=5s, and each additional method is at least another second. I've over 300 db tables so a slow startup is perhaps understandable. However I've gone through the logs and one of the surprising t...

how to get a Spring bean that is local to the current HttpRequest

I would like to be able to create a bean whose scope is limited to the currently serviced HttpRequest. I considered ThreadLocal but the problem I see is that threads can be reused to service an HttpRequest by the container. I would like to use said bean in a bean that has no concept of the currently serviced HttpRequest. Any guidanc...

What approach should I take to understand a large J2EE application if I don't know any of the frameworks involved yet?

I started working in my company 5 or 6 years ago as a junior Java developer, and I got to do some J2EE programming using Servlets and Jsp. I didn't spend much time in that position and I went to work with databases, so I distanced myself from the software development world. Now I've had to go back to Java programming, and I was given a W...

What is wrong about my embedded jetty spring web application configuration?

I have a spring application that uses an embedded Jetty instance. Since I am programmatically defining my web.xml, here is how I am adding the dispatcher. DispatcherServlet dispatcherServlet = new DispatcherServlet(); dispatcherServlet.setContextClass( AnnotationConfigWebApplicationContext.class); ServletHolder ...

Spring bean initialized on web app starts up

This is probably due to my ignorance of the Spring framewok but i am building a JSF+Facelets+Spring web app, i have a bean that whose init method i want to get called at the time the application is started. My problem is getting the bean initialized. I can reference the bean on a page, and when I go to the page, the bean is initialized,...

In Spring, can I autowire new beans from inside an autowired bean?

I normally just @Autowire things into spring objects. But I've encountered a situation where I need to dynamically create some objects which require values that could be autowired. What should I do? What I could do is just manually pass the autowired values into the constructor of the new objects. What I would like to do is just autowir...

Initialize Spring beans packaged inside a jar file

In a web-app, we define the context config location for spring to initialize all the beans like this <!-- Spring Application Configuration --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/ctx-*.xml</param-value> </context-param> <listener> <description>Spring Context Listener</des...

benchmark/profiling maximum users can support on web application

any easy to use utility/tool/profiler/benchmark that able to test what is the maximum users a web application able to support by analyzing session size , cpu speed, memory size..etc and 'PREDICT' when server is overpacked/overloaded? ...