spring-3

@EnableTransactionManagement annotation with 2 transaction managers

此生再无相见时 提交于 2019-12-17 17:55:31
问题 I am using @Configuration annotation for configuration of spring instead of xml file. I am configuring 2 datasources with different session factory and different transaction managers. I am stuck with a problem here for @EnableTransactionManagement annotation. I read in its documentation that, @EnableTransactionManagement is more flexible; it will fall back to a by-type lookup for any PlatformTransactionManager bean in the container. Thus the name can be "txManager", "transactionManager", or

webflow.xsd - Start state is missing. Add at least one state to the flow

空扰寡人 提交于 2019-12-14 02:58:22
问题 I am working with Spring Core 4.0.7 and Spring Web Flow 2.4.0 Using Spring Tool Suite I am able to create a Spring Web Flow Definition File For the <flow> tag it generates <?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> Observe spring-webflow-2.0.xsd When

How to obtain Spring transaction manager instance?

别来无恙 提交于 2019-12-12 13:22:26
问题 I use annotations to mark methods which should be executed in a transaction. But, in one place I need to do transactionManager.rollback() manually, without annotation. How can I obtain transactionManager object? 回答1: If you want to rollback the current transaction, you may use TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Note that it doesn't rollback the transaction immediately - it sets the "rollback only" status, so transaction will be rolled back during attempt to

Loading up properties file to a class in Spring

眉间皱痕 提交于 2019-12-12 03:48:56
问题 I am trying to load a property file (.properties) into my class, I am following the example in another thread here: How to read values from properties file? - but it's not working for me. here's my quick implementation: applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org

Inner object id save in Spring 3

别等时光非礼了梦想. 提交于 2019-12-12 02:49:21
问题 I want to save Village object through hibernate where already persisted District id need to be saved. I populated district object in dropdown. I coded similar work in spring 2, but in spring 3 it doesn't work. here, if I log village.getDistrict() in POST, id is set perfectly as I set to dropdown but other value of district object is null. @SessionAttributes({"village"}) @Controller public class VillageController{ @Autowired(required=true) private AddressService addressService; @RequestMapping

How to use a properties file in Spring beans XML file?

久未见 提交于 2019-12-12 02:33:44
问题 I have some properties files that I'd like to make available in the Spring XML config files. For example, in hello.xml : <bean id="theFoo" class="learnspring.Foo"> <property name="color" value="${foo.color}"/> </bean> In Java code: ApplicationContext ac = new ClassPathXmlApplicationContext("hello.xml"); File props = new File("path/to/hello.properties"); File moreProps = new File("path/to/more.properties"); // What to do here? Foo foo = (Foo)ac.getBean("theFoo"); System.out.println(foo

Session is closed Exception

旧巷老猫 提交于 2019-12-12 00:24:14
问题 I am building an application with Struts 2 hibernate spring 3 with my sql as back end and c3p0 connection pooling(c3p0-0.9.1.1 jar). Sometimes, when executing a query, I get the below error. When ever I am executing query I check if the connection is closed or not, and if it's closed I will open a new connection before executing the query. public List<T> find(final Query query, final Object[] values) throws HibernateException, NullPointerException { if (values != null) { for (int i = 0; i <

How long will Spring 3.x continue to be supported?

大城市里の小女人 提交于 2019-12-11 19:58:28
问题 I've recently inherited a project that's built on some older technologies, including iBATIS 2.x, and Struts 1.x. Both of those seem to be supported (though @Deprecated) in Spring 3.2.x, and not at all in Spring 4.x: org.springframework.orm.ibatis, Object Relational Mapping (ORM) Data Access - iBATIS SQL Maps org.springframework.web.struts, Integrating with other web frameworks - Apache Struts 1.x and 2.x However, before I start the effort of migrating to Spring 3, I want to know how much

Pretty URL Mapping with Spring 3.0

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 19:46:03
问题 I'm getting the following error when trying to map a URL path called "new" to a Controller method which does some logic, then displays the view "index.jsp": WARNING: No mapping found for HTTP request with URI [/springguestbook/index.jsp] in DispatcherServlet with name 'springguestbook' This is my Controller method: @RequestMapping(value = "/list", method = RequestMethod.GET) public String showGuestbookEntries(HttpServletRequest request, Model model) { HttpSession session = request.getSession

How to get hold of user details in custom expression handlers

孤者浪人 提交于 2019-12-11 17:57:15
问题 I am using a custom security expression handler and using spring 3.2.0. Here is the custom expression root class : public class CustomerPortalSecurityExpressionRoot extends WebSecurityExpressionRoot { private static final Log logger = LogFactory.getLog(CustomerPortalSecurityExpressionRoot.class); private CustomerPortalPanicService customerPortalPanicService; public CustomerPortalSecurityExpressionRoot(Authentication a, FilterInvocation fi) { super(a, fi); } public boolean isPanicking() { if