spring

Spring framework best practices: deploying a non-bean compliant component

I want to build an MVC app using Spring (first timer here). As such I want to embed Jetty as the servlet engine. Jetty however doesn't stricly follow the java beans pattern, so I can't launch some classes from Spring (they use overloaded setters or non setter init methods like addXYZ). What is the accepted/recommended practice for stru...

What is SSO authentication touch point used for?

I find there are following code in NTLMAuthenticationFilter.java which used for alfresco share SSO authenticate: Response remoteRes; if (cachedNtlm) { Connector conn = connectorService.getConnector(this.endpoint, session); ConnectorContext ctx = new ConnectorContext(null, getConnectionHeaders(conn)); remote...

spring-mvc + jpa: data binding

I have simple application which manages football teams and matches. I am using JPA, in the form editMatch.jsp i have property team_1, team_2 (instance of class Team) for choosing the team from the list. The problem is when editing match, the team_1 and team_2 dont select in the list, and after submitting the error message is: Property t...

Spring: How should application+web contexts be organized?

The scenario: Start the app and load ClassPathXmlApplicationContext in main(), this starts a Jetty webapp. dispatcher servlet then loads a XmlWebApplicationContext dispatcher servlet then looks for WEB-INF/applicaitonContext.xml to load as the root context I'm just trying to get my head around contexts. Should I use 3 contexts as ...

Mapping Path Variable to Command Property

@RequestMapping(value = "/post/{postThreadId}", method = RequestMethod.GET) @ResponseBody public String paramTest(PostParams params) { return params.toString(); } Spring MVC Path Variable ("postThreadID") can be mapped to Command object field? PostParams have setPostThreadId(int ...) But, it looks not working. ...

Spring 3 MVC - Controller is called but views are not found

Hi, I'm trying to set up a skeleton Spring 3 MVC project but i'm having difficulties getting the views to render. I have followed the structure as described in the mvc-basic sample project and at http://blog.springsource.com/2009/12/21/mvc-simplifications-in-spring-3-0/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+...

Is the SimpleJdbcTemplate in Spring safe from SQL Injection?

I realise it's possible to pass in a manually constructed String to the execute(String) which is vulnerable. However I'm interested in where you pass the parameters to the query using MapSqlParameterSource or one of the other exposed methods such as in the below examples. Digging into the source it looks like it's using a prepared stat...

Does scala affect AspectJ/Spring AOP at all? I'm having a thread locking problem when running tests when an @Configurable is being called

I have a strange problem where when I run my tests using maven, it locks whenever a test method calls into an object with an annotation @Configurable. I can run the tests fine in IDEA using the AspectJ Weaver plugin (remarkably), but I cannot do it with maven (whether I execute them in IDEA or just in a terminal). Even weirder, if I pre...

Spring 3 validation error

I'm trying to get some validators working with Spring 3. I keep getting an error: org.springframework.beans.NotReadablePropertyException: Invalid property 'name' of bean class [java.lang.String]: Bean property 'name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the se...

Best way to debug MySQL connections that are being closed on me after ~39 minutes?

I have hibernate 3.3, c3p0, MySql 5.1, and Spring. The MySQL connections in my service calls are consistently being closed after ~39 minutes. The natural running time of my service call is on the order of ~5 hours. I've tried changing various c3p0 config, etc, to avoid the 39 minute cap. No luck. Is there a more direct, systematic wa...

Hibernate using multiple databases

I need to have multiple databases for different customers. How can I handle multiple databases with Hibernate? Are there any good examples how to do this? I could create Configuration object and then build SessionFactory, but that would create always a new session factory which wouldn't be very wise. EDIT: Now I can get hibernate Conf...

Different classloaders cause ClassCastException when persisting data via Spring

I'm creating an MVC Spring webapp. Using: Jetty (servlet container), DataNucleus (dao platform), DB4O (embedded datastore). When I persist an object (done from within a Spring Controller) using JDO from DataNucleus, it stores to the DB fine. @PersistenceCapable public class Test { @Persistent private String testString; //g...

Spring MVC and JSR-303 hibernate conditional validation

I've a form I want to validate. It contains 2 Address variables. address1 has always to be validated, address2 has to be validated based on some conditions public class MyForm { String name; @Valid Address address1; Address address2; } public class Address { @NotEmpty private String street; } my controller aut...

Make something after remember me authentication ?

greetings all i am using spring security 3.0.2 and i am using the following configuration for remember me <http use-expressions="true" > <remember-me token-repository-ref="tokenRepository" token-validity-seconds="1209600"/> <beans:bean id="tokenRepository" class="org.springframework.security.web.authentication.reme...

Problem with Jasig CAS webflow

I have CAS 3.4.3 in my pom. From Jasig CAS zip I included all configuration including login-webflow.xml The same configuration was working for me when I built my application with CAS source. Currently I get an exception: org.springframework.expression.spel.SpelParseException: EL1041E:(pos 33): After parsing a valid expression, there is...

Annotated Controllers in Spring, passing parameter to jsp

Hello, I'm trying to complete that tutorial with annotated controllers. I got stuck on the Step 2. Here is what they have for Simple Controllers: public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String now = (new Date()).toString(); logg...

Is there a java library that converts strings describing measures of time (e.g. "1d 1m 1s") to milliseconds?

When setting issue estimates in JIRA, you can enter a string like "1d 2h 30m" and JIRA will translate this (I'm assuming) into a corresponding number of milliseconds. Is there an available Java library that does this? I'm using a Spring managed bean that takes a property indicating how often a directory ought to be purged, and I'd like...

spring <util:properties /> with wildcards

I'd like to load key-value pairs from multiple locations. My first guess was: <util:properties id="requestProcessorRepository" location="classpath*:*requestProcessors.properties"/> but it is not valid Invocation of init method failed; nested exception is java.io.FileNotFoundException: class path resource [classpath*:*requestProcess...

what is Java Internationalization best practice for web based spring application?

what is Java Internationalization best practice for web based spring application? ...

Spring MVC: @SessionAttributes shared among controllers?

I have an abstract controller support class for searches and result lists: @Controller @SessionAttributes("query") public abstract class SearchController<Q extends SearchQuery> { @RequestMapping public String performSearch(@ModelAttribute("query") Q query) { .... } @ModelAttribute("query") public abstract Q ...