spring

entitymanager.merge does not seem to commit

I have an application using Tomcat/Spring 3/JPA/Hibernate but my merges do not commit to datbase. This is the configuration: spring-conf.xml: <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jd...

Sharing a Spring transaction between hibernate & JdbcTemplate within a AbstractTransactionalTestNGSpringContextTests

I'm running a test within a subclass of AbstractTransactionalTestNGSpringContextTests, where I execute tests over a partial Spring context. Each test runs within a transaction, which is rolled back at the end to leave the database unchanged. One test writes to the database through Hibernate, while another reads from the same database us...

Can I annotate a method as cacheable in Spring?

I would like to use an annotation that marked the result of a method call as cacheable. When provided it would use a caching provider to cache the output for the given input. For example: @Cacheable public Bar doExpensiveCalculation(Foo foo) { Bar bar = jiggeryPokeryWith(foo); return bar; } ... Foo foo1 = new Foo(...); Foo foo...

Spring @Transactional concurrency

Hi; class MyService { public void a() { synchronized(somekey) { b(); } } @Transactional(propagation = Propagation.REQUIRES_NEW) public void b() { ...do DB works... } } My aim is 1 - get the key 2 - start transaction 3 - commit transaction 4 - release the key When i call a() method from outsid...

Determine secure url in JSP with spring security

Like many websites, I have a login popup on every webpage of my site. Most of these pages are http (non-secure). But the login mechanism has to post to a secure url. All this works great. The problem is the secure url changes in the various dev environments, staging and different production environments. So not too big of a deal, I ...

java.lang.IllegalStateException: Cannot deserialize BeanFactory with id org.springframework.web.context.WebApplicationContext

When I stop my server I get this exception: SEVERE: Exception loading sessions from persistent storage java.lang.IllegalStateException: Cannot deserialize BeanFactory with id org.springframework.web.context.WebApplicationContext:/Life: no factory registered for this id at org.springframework.beans.factory.support.DefaultListableBean...

Spring declarative transaction management not working

I am using spring 3.0.3.RELEASE along with mybatis-3.0.2 and mybatis-spring-1.0.0 running in Apache Tomcat 6.0.29 with JDK 1.6.0_21. I created my DAO class and Service class and defined following declarative transaction control - <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:...

How does work context:include-filter and context:exclude-filter from spring 3.0?

I have several services: example.MailService example.LDAPService example.SQLService example.WebService example.ExcelService annotated wiht @Service tag. How can i do exclude all services exept one? For example: only use MailService. I use the next configuration: <context:component-scan base-package="example"> <context:include-f...

Spring AOP and transaction add custom interceptors

My spring definition regarding trasnsaction are defined as following: <bean id="txInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager"/> </bean> <aop:config> <aop:pointcut id="defaultServiceOperation" ex...

JACKSON JSON custom deserializer

Hi, I am using Jackson library's ObjectMapper for deserializing JSON into JAVA objects. I am using Spring 'wiring'. I have created custom deserializers to do the conversion from JSON string to POJO. However, when the input is bad (eg. a number is passed as "124A" - illegal character) a default deserialiser is invoked and bombs with the ...

How to integrate Spring security 3 with jboss realms and user roles?

How would I get Authentication and roles information from a JBoss realm that uses kerberos/SPNEGO from MSAD into a web-app using Spring security 3? Do I need to create a custom AuthenticationProvider or UserdetailsService? I've noticed that Spring Security 2 had container adapters, but they decided it was too much of a pain to keep the...

Does Spring (3) have any built in support for pagination?

I have a model I need to paginate (Book listings - as explained in a previous question.). This seems like a common enough feature that I would expect some pre-built solutions for it without having to build a custom solution. Does Spring (3) have support for pagination? ...

Meaning and solution for Spring 3 error message? "Using getResponseBodyAsStream instead is recommended"

I'm using Spring 3 and every time I submit a HTML form to a Spring controller I get this message, which I don't understand: org.apache.commons.httpclient.HttpMethodBase getResponseBody WARNING: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended. Is there a configuration change...

Problem with FileUpload - Null Value for Multipart File

I am working on a Spring web application and need to implement a simple FileUpload for one of my pages. The page for the JSP contains the following snippet of code which included an upload field for uploading the file. <form:form commandName="editMemberInfoModelObj" method="post" enctype="multipart/form-data"> <h1>Edit Member I...

i18n translation in JSP custom tag

Is it possible to write a custom JSP tag to take an i18n message key and output the translation phrase for the given request? Normally in JSP/JSTL, I do: <fmt:message key="${messageKey}"><fmt:param>arg1</fmt:param></fmt:message> And I get the translation phrase. Now I need to do the following (there's a good reason for this): <cust...

Pattern for working with different database dialects via JDBC

I'm creating an application that has to work with different databases (Oracle, MSSQL, MySQL...) through JDBC. I have to work via JDBC because my application calls stored procedures in these databases. What is the best aproach for building such applications? Are there any frameworks for this? Important: The solution must nicely deal wit...

What is plain-vanilla JavaBeans & plain-vanilla Java Class ??

Hi , what is the Technical meaning of this context plain-vanilla Java Beans & plain-vanilla Java Class ??. ...

Hibernate/Spring: Error loading lazy collection in a @Transactional

I though I understood lazy/eager loading, but obviously I don't: I have a service that is marked @Transactional, yet when I try to manipulate the list I get (accessing its objects), I get "org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: tld.myproduct.data.entities.CategoryType.translatableTex...

Spring 3 bind obscures real values of command object.

I have a controller that allows users to add or edit an entity. I've removed myForm.myEntity.name from myForm but spring still shows it when the spring:bind tag is used. See the example below: The snippet below outputs a value: <spring:bind path="myForm.myEntity.name"> <h1>${status.value}</h1> </spring:bind> The snippet below doesn't...

Application run well from eclipse, but fails to start, when it is deployed manually

I have web application using SpringFramework3.0.3.RELEASE, developed in Eclipse with m2eclipse plugin and deployed into Tomcat6.0.26. I can run it from Eclipse, but when copy target WAR int same tomcat instance ( removing WTP webapp first ) and restart I see following exception: Sep 14, 2010 5:54:42 PM org.apache.catalina.core.Applicati...