spring-3

Spring under Geronimo v2.1 with Jetty

这一生的挚爱 提交于 2019-12-11 15:36:14
问题 I trying to deploy Java EE web application on Geronimo container with Jetty web server. Unfortunately I have some troubles, I'm getting NoSuchMethod error. I saw that somebody had similar problem, and the solution was to remove redundant spring-framework library from classpath. But it doesn't work for me, my classpath is correctly constructed. Here's contents of WEB-INF/lib directory: aopalliance-1.0.jar commons-collections-3.2.1.jar commons-logging-1.1.1.jar dom4j-1.6.1.jar h2-1.3.164.jar

How to make embedded Jetty use the AppContext it's defined in as parent context for servlets

心已入冬 提交于 2019-12-11 08:34:23
问题 I have a standalone java app that now runs an embedded Jetty server to expose a RESTful API for HTTP. It does make heavy use of Spring beans for everything from Hibernate to Jetty. I have Jetty configured with a DispatcherServlet ( the thought being that adding a non-REST API in the future will be as simple as making the new Controller and mapping it correctly for the dispatcher). My app has a class with a main method that creates a ClassPathXmlApplicationContext from my appContext.xml to

Spring 3.1: Handling session timeout

放肆的年华 提交于 2019-12-11 06:45:50
问题 I have an application that is wired with Spring 3.1 authentication. I have some pages which makes AJAX requests to show some information on the dialog. Now, if the user's session has timed out, the Spring redirects to the login page. I don't want an AJAX based login page. I would like the user to be navigated to the login page entirely, by canceling current operation. Once user logs in, navigate user back to the last page where he was (from where the AJAX request was made). The redirection

Submit Spring Form using Ajax where Entity has Foreign Entities

若如初见. 提交于 2019-12-11 05:16:25
问题 Here's my entity: @Entity @Table( name = "tbl_license" ) public class License implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue @Column( name = "id", nullable = false, columnDefinition = "serial" ) private int id; @Column( name = "key", nullable = false, columnDefinition = "text" ) private String key; @Column( name = "users", columnDefinition = "text" ) private String users; @Transient private final SimpleDateFormat dateFormat = new

How to implement Spring's 3.1 MvcAnnotationDriven?

家住魔仙堡 提交于 2019-12-11 05:02:34
问题 This is the code example from Spring 3.1 Spring Source Blog: From XML to @Configuration I'm trying to implement in my application (which was done in Spring 2.0 not by me so it's lot of learning). @FeatureConfiguration class MvcFeatures { @Feature public MvcAnnotationDriven annotationDriven(ConversionService conversionService) { return new MvcAnnotationDriven().conversionService(conversionService) .argumentResolvers(new CustomArgumentResolver()); } // ... } However, I can't understand the

@ExceptionHandler not working with Spring MVC 3.1 unit test

旧时模样 提交于 2019-12-10 21:03:11
问题 I'm able to do nearly all of the unit test on my Spring MVC controller by instantiating the object outside of the normal servlet context. But I would like to be able to run some tests to insure that my object serialization is working properly, headers are being generated, etc. To run a test inside the servlet context, I create a modified context file so that various beans are NOT constructed, then I create mocked versions of those beans in my test case using EasyMock. I then invoke my handler

Problems with @Autowire annotation (null)

依然范特西╮ 提交于 2019-12-10 21:00:06
问题 I have problems with two services that i autowired in a validator class. The services works ok because in my controller are autowired. I've an applicationContext.xml file and MyApp-servlet.xml file. My base package is es.unican.meteo and i have problems with the package es.unican.meteo.validator. The package es.unican.meteo.controller and es.unican.meteo.service can autowire the services properly. applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www

Set HTTP status code for redirect when returning a String in a Spring 3 controller

青春壹個敷衍的年華 提交于 2019-12-10 18:15:17
问题 Is there a way to specify the HTTP status code when returning "redirect:/new/url" in Spring 3? 回答1: Haven't tried it, but looking at the source of org.springframework.web.servlet.view.RedirectView it has getHttp11StatusCode() method that determines the HTTP status of response. It seems like you can override the default response code by settings org.springframework.web.servlet.View#RESPONSE_STATUS_ATTRIBUTE property on request. Simply set: httpServletRequest.setAttribute(View.RESPONSE_STATUS

customizing spring 3 mvc:annotation for RequestMappingHandlerMapping

别等时光非礼了梦想. 提交于 2019-12-10 03:47:09
问题 I am using <mvc:annotation-driven/> and I would like to configure RequestMappingHandlerMapping for disabling useTrailingSlashMatch . When I declare another RequestMappingHandlerMapping, I will end up 2 RequestMappingHandlerMapping . How can I configure RequestMappingHandlerMapping ? 回答1: As you have already noted, this is feasible in xml by removing mvc:annotation-driven and replacing with the entire xml equivalent: <bean name="handlerAdapter" class="org.springframework.web.servlet.mvc.method

How can I qualify an autowired setter that I don't “own”

 ̄綄美尐妖づ 提交于 2019-12-10 02:21:34
问题 The gist is that the Spring Batch (v2) test framework has JobLauncherTestUtils.setJob with an @Autowired annotation. Our test suite has multiple Job class providers. Since this class is not something I can modify, I'm not sure how I can qualify which job it gets autowired with, which may be different per test. STDOUT [WARN ] [2015.04.15 11:14:42] support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans