spring

Unable to acquire a connection from driver [null], user [null] and URL [null]. / EclipseLink 1.2 / Spring 2.5.6 / OSGI

Hi, I try to deploy a project where EclipseLink JPA is used as ORM tool on an OSGI platform. The project works fine when running outside of a OSGI container. Version used : Spring 2.5.6, EclipseLink 1.2.0 Unfortunately, I get this error on the OSGI platform : Exception Description: Unable to acquire a connection from driver [null], u...

Spring @Autowired and WebApplicationContext in Tomcat

@Autowired works only once. What to do to make it wire the bean every time the Servlet is recreated? My web-app (Tomcat6 container) consists of 2 Servlets. Every servlet has private fields. Their setters are marked with @Autowired In the init method I use WebApplicationContextUtils ... autowireBean(this); It autowires the prope...

Loading Properties with Spring (via System Properties)

My problem is as follows: I have server.properties for different environments. The path to those properties is provided trough a system property called propertyPath. How can I instruct my applicationContext.xml to load the properties with the given propertyPath system property without some ugly MethodInvokingBean which calls System.getP...

inject a mockups to a bean that has @Autowired annotations

I have a bean that has a couple of beans injected with the autowire annotation (no qualifier). Now, for testing reasons I want to inject some mocks to the bean instead of the ones being autowired (some DAOs). Is there any way I can change which bean is being injected without modifying my bean? I don't like the idea of adding annotations ...

Application context invalid in maven test

Upon running 'mvn test' I get the following error(s): java.lang.IllegalStateException: Failed to load ApplicationContext ... Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParse...

hibernate3-maven-plugin: entiries in different maven projects, hbm2ddl fails

I'm trying to put an entity in a different maven project. In the current project I have: @Entity public class User { ... private FacebookUser facebookUser; ... public FacebookUser getFacebookUser() { return facebookUser; } ... public void setFacebookUser(FacebookUser facebookUser) { this.facebookUser = facebookUser; } Then Fa...

How to use SQLErrorCodeSQLExceptionTranslator and DAO class with @Repository in Spring?

I'm using Spring 3.0.2 and I have a class called MovieDAO that uses JDBC to handle the db. I have set the @Repository annotations and I want to convert the SQLException to the Spring's DataAccessException I have the following example: @Repository public class JDBCCommentDAO implements CommentDAO { static JDBCCommentDAO i...

What are annotations and how do they actually work for frameworks like Spring?

I am new to Spring and now a days I hear a lot about Spring Framework. I have two sets of very specific questions: Set No. 1: What are annotations in general ? How does annotations works specifically with Spring framework ? Can annotations be used outside Spring Framework or are they Framework specific ? Set No. 2: What module o...

How to collect and inject all beans of a given type in Spring XML configuration

One of the strongest accents of the Spring framework is the Dependency Injection concept. I understand one of the advices behind that is to separate general high-level mechanism from low-level details (as announced by Dependency Inversion Principle). Technically, that boils down to having a bean implementation to know as little as possi...

spring - constructor injection and overriding parent definition of nested bean

I've read the Spring 3 reference on inheriting bean definitions, but I'm confused about what is possible and not possible. For example, a bean that takes a collaborator bean, configured with the value 12 <bean name="beanService12" class="SomeSevice"> <constructor-arg index="0" ref="serviceCollaborator1"/> </bean> <bean name="servi...

Setting session timezone with spring jdbc oracle

Hello I have a spring/jdbc/oracle 10g application. The Oracle server database timezone is set to GMT + 2 JVM timezone is GMT + 2 (even though it doesn't matter in my case). I have a stored procedure that performs some date operations. The problem is that session timezone is different(GMT) than database timezone even though I do not set...

Maven archetype for basic spring hibernate struts2 application

Hello I am looking for a basic maven archetype which can help me create a spring hibernate struts2 application. I have tried using appfuse but it sucks. It took more than half an hour to download n number of dependencies and the project it created was having errors also. if you know anyother maven archetype please tell me. Thanks...

"session" bean scope in a web application - reliable ?

Can you rely on this scope and be sure that every time 1) a new session starts, the Spring bean will be initialized with default values 2) while session is kept alive, the current object will store its state during session life, will never be lost or corrupted and can always be got with [webappcontext].getBean ? ...

Grails domain class initialization

Hi, My Grails app has the following Spring bean defined in spring/resources.groovy calendarService(CalendarService) { bean -> bean.initMethod = "init" } This method looks something like: class CalendarService { void init() { User.findByEmail("[email protected]") } } When I call the dynamic finder findByEmail ...

Spring bean's DESTROY-METHOD attribute and web-application "prototype"d bean

Can get work the attribute "destroy-method". First, even if I type non-existing method name into "destroy-method" attribute, Spring initialization completes fine (already strange!). Next, when a bean has a "prototype" scope, then I suppose it must be destroyed before the application is closed. That not happens, it is simply never ca...

How to pass Endpoint parameter to Endpoint defined as bean in Spring conext

I have camel Fileendpoint defined in following way: <bean id="hotfolderEndpoint" class="org.apache.camel.component.file.FileEndpoint" factory-bean="camel" factory-method="getEndpoint"> <constructor-arg ref="hotfolder" /> </bean> I want to define some File parameters such as preMove, move ...

How to execute query with IN clause in spring?

I have following code : try { MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue("ids", year); return this.template.getJdbcOperations().query( "SELECT * FROM INCOME WHERE PROVNUM=? AND FISCALDATE IN ( :ids )", this.rowMapper, parameters); ...

Programmatic login in Spring Security 2

I'm trying to find a way to skip the login form when a user clicks on an "activate account" link that he has received by email. This link contains a single-use random token that can serve as an authentication method. By this token I can retrieve the user details and activate its account, but I am yet to find a way to sign-in programmati...

LazyInitializationException with @Transactional annotation in MessageConverter

Hi, I have a REST-service exposed through Spring-MVC. I have a particular method which is correctly mapped and called through a HTTP-call. My Spring application contains the HibernateTransactionManager and transactions are configured through @Transactional-annotations. I annotated the method like this: @Transactional(readOnly = true) @...

How to make Spring load a JDBC Driver BEFORE initializing Hibernate's SessionFactory?

I'm developing a Spring(2.5.6)+Hibernate(3.2.6) web application to connect to a custom database. For that I have custom JDBC Driver and Hibernate Dialect. I know for sure that these custom classes work (hard coded stuff on my unit tests). The problem, I guess, is with the order on which things get loaded by Spring. Basically: Custom ...