spring

count active users

I'm using spring security 2. 1.may i know how to use securitycontextholder to get total number of active users? 2. can retrieve sessionregistry from securitycontextholder? ...

Using Spring defined transactionManager in JPA/Hibernate

Suppose you use JPA with Spring, with Hibernate as JPA implementation. JPA transaction mode is "JTA", so you need to pass the container transactionManager to Hibernate. The classical answer is to set hibernate.transaction.manager_lookup_class to the matching class for your server. However, I think it's a shame to have this depend of ser...

Spring MVC: JSP or JSON view in Controller method depending on request

Using @ResponseBody my controller returns a JSON representation of my pojo by default, but is possible to change the view to JSP by default, and return a JSON response only when your content type is application/json? @RequestMapping(value="/myRequest") public @ResponseBody myPojo myRequest() throws Exception { return service.g...

Tomcat serving static content

Hi, I have a Spring app and I'm wondering the best way to serve static content. I have tried the following: <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>app</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> Th...

Spring ORM or Hibernate

Hi! I'm just wondering why the combination of Spring and Hibernate is so popular, when it would be possible to leave Hibernate out and use just Spring ORM? ...

How to get web session on Spring AspectJ

Hi all,I have a question for using Spring AspectJ.I want to create audit log when user do something and get user information from web session to create audit log. Can anyone provide examples of how to do this? ...

Is Spring's ThreadPoolTaskExecutor blocking something?

We are using the ThreadPoolTaskExecutor within Spring (inside of Tomcat) to launch a concurrent server which listens on a port (3001). Our code looks a bit like: .... ServerSocket listener = new ServerSocket(port); Socket server; while (true) { PollingTask pollingTask; server = ...

Unit testing controllers with annotations

Hi there, I'm trying to write some unit tests for my controllers in a Spring MVC web app. I have already got a fairly comprehensive set of unit tests for the domain model, but for completeness I want to test the controllers too. The issue I'm facing is trying to test them without loading a Spring context. I thought I could get around...

Spring http invoker, bean scope not honored?

I am exposing a bean that is not thread safe via Spring's http invoker. What I want is that every remote call should get a new instance of the bean. I started by setting the scope to prototype for the bean that I am exposing in the Dispatcher servlet XML. But it still seemed to create only one instance. So all client threads were concurr...

Spring serving static content with mvc:resources, invalid xsd

As recommended by http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources I wish to use <mvc:resources> for serving my spring static content. I have tried the following XML, but the .xsd file doesn't contain a declaration for <mvc:resources> and I cannot find an alternative .xsd. I ...

Spring Bean Configuration: How to mark beans as mandatory/optional?

Hi, I am making heavy use of Springs XML Configuration for Java Beans. Is there a best practice to mark a property of a bean as optional or required? I am currently initializing the optional beans in the default constructor. If one of the required properties it not set in most cases a NullPointerException will be thrown, but that doesn'...

Prototype scope not working

Hi, I've created a prototype scoped bean in my application and I'm injecting that to another bean using a setter. But when I'm using the injected bean in my class it is always using the same instance instead of new instance every time. Here is a snapshot of the code <bean name="prototypeScope" Class="A" scope="prototype"> </bean> <be...

spring 3.0 aop Pointcut is not well-formed: expecting 'name pattern' error

The following is my pointcut and advise declaration //PointCut on A method which takes two parameters and is in a DAO @Pointcut("execution(backend.repository.QuestionsRepository.AnswerQuestion (..))") public void answerQuestionPointCut() {} @Around( value="web.activity.advisors.UserActivityAdvisor.answerQuestionPointCut()", arg...

Complex reports with JPA and JasperReports

I have been reporting with jasperreports and JPA, all this reports are just "catalogs" in which the only information is an entity or some times an entity with it's related entities. Now i have to design reports with very complex information (grouping, summarization, fields not part of an entity and so on) which is not possible with my e...

How do I resolve the grails bootstrap execution error "postProcessBeanDefinitionRegistry already called for this post-processor"?

I'm building a Grails (1.3.4) app configured with the grails plugin tomcat-1.3.4 and using Spring (3.0.3RELEASE) but reusing an existing Spring applicationContext.xml file. I copied the relevant portions of the old file into the one generated by Grails (just below the characterEncodingFilter bean). After making sure that all the requir...

Adding Spring Configuration File to classpath via Manifest file

I have a WAR project and I am trying to store spring configuration files within the /WebContent/WEB-INF/Spring/ folder (as required by my employer), but when I do that I have not found a way to be able to reference those files within my junit tests. I was told today that I can modify my MANIFEST.MF file so that the spring configuration ...

How to debug ContextLoader - Context initialization failed and BeanCreationException

I see a number of posts on the various problems folks have with troubleshooting this problem: ERROR context.ContextLoader - Context initialization failed org.springframework.beans.factory.BeanCreationException: Is there a way to turn on debugging to isolate the problem? Its complaining about "No such property: getOrg for class: groovy...

Spring framework question

Spring is well used these days. Are there any deficiencies of spring. Can it handle very heavy load? ...

How to retrieve a JSON object from HttpServletResponse in Spring?

I have a Spring controller in which I have to read a JSON object from a URLConnection. Currently I am doing this by reading from the connection's input stream line by line. Basically I am reading the text contents of the response line by line. Is there any JSON api that I could use to populate the JSON object directly from the URLConnec...

Using rich datascroller With Hibernate Pagination on Server

I am having rich:datatable having 500(row) data and I am using rich:datascroller for pagination but the problem is all the data are fetched on 1st time, so if anybody having a way that click on page 2 hibernate fetches rows from table (11-20). I am using Spring+Hibernate. Please Give solution in detail. ...