FAQ Database Discussion Community


how to set default beans init-method by annotations in spring 4?

java,spring,dependency-injection,annotations,spring-4
i am learning using Spring 4 by Java annotations, and i could not find how to set default init-method to all beans that belong to specific configuration, without adding the @PostContruct annotation to initialize method at all clases and neither making them implement the InitializeBean interface... I just want to...

hibernate rollback not working in service layer

hibernate,postgresql,transactions,junit4,spring-4
i have issue in rollback insert/update data in postgresql database, in service layer, where as in DAO layer it is working fine. My DAO junit test Code @ContextConfiguration("classpath:datasource-context-test.xml") @RunWith(SpringJUnit4ClassRunner.class) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true) @Transactional public class SellerDAOTest { @Test @Rollback(true) public void testAddSeller() { try { SellerDO sellerDO...

spring : Input page forwarding when exception like struts

spring-4
Business validations are implemented by throwing CustomeException(key) such that user will be displayed error messages when something goes wrong. I have to forward to input jsp (like struts) when business exception raised, to correct the user actions then continue with application. we have custom HandlerExceptionResolverImpl to handle the all exceptions...

Spring: How can I debug a BeanCreationNotAllowedException?

java,spring,spring-4
I am trying to add a new Spring bean to one of my projects. The bean is defined and created in another package like so: @Configuration public class UtilityBeans { public static String MY_BEAN_NAME = "my.bean.name"; @Bean(name = MY_BEAN_NAME) public MyUtilBeanClass getMyBeanClass() { return new MyUtilBeanClass(); } } I use...

Spring 4 cannot execute Java 8 default methods

spring,java-8,spring-4
I have defined interface public interface MyInterface { default void setOrder(int a){ } default int getOrder(){return 123;} } and implementation public class MyInterfaceImpl implements MyInterface {} In my spring configuration file I have defined following bean: <bean id="a" class="my.package.MyInterfaceImpl"> <property name="order" value="999"/> </bean> When I create spring context I got...

Using maven profiles to configure code based a Spring application

properties-file,spring-4,maven-profiles
I have a Spring application which is complete code based configured. And I am trying to combine maven profiles to setup my db connections. I defined some properties for a local, live and staging issues. Now I try to get control over maven profiles. Every profil defines my MySql db...

AbstractStatelessSessionBean missing from SpringFramework 4

java,spring,spring-4,spring2.x
I'm trying to update a big projekt from Spring 2 to Spring 4. On the deep end of the Beans hierarchy i found a class called CustomAbstractStatelessSessionBean and that extends the AbstractStatelessSessionBean class from org.springframework.ejb.support.AbstractStatelessSessionBean. The content of the class: public abstract class CustomAbstractStatelessSessionBean extends AbstractStatelessSessionBean{ /** * */ private...

No bean named 'transactionManager' is defined - Rename transactionManager

java,junit4,activiti,spring-4
Im running a unit test under jUnit4 + spring4 and the thing is: my transactionManager is not called "transactionManager", it is called "transactionManagerActiviti". If I change the name everything is fine. I tried with this and this very similar question but I can't find the solution to this simple rename...

Weblogic11: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable

java,logging,weblogic11g,spring-4
I know that this error already appears on stackoverflow and normally it translates to a classpath problem. In my case this is my context: Application Server: Weblogic 10.3.6 Using Spring 4 + log4j. Weblogic User domain lib folder: log4j-1.2.17.jar commons-logging-1.1.3.jar spring-beans-4.1.2.RELEASE.jar spring-core-4.1.2.RELEASE.jar spring-jdbc-4.1.2.RELEASE.jar spring-tx-4.1.2.RELEASE.jar When I try to use the...

Two Spring Controller Methods, One Returns 200, Other Returns 404. Only Differ By The Mapping URL

java,json,spring,spring-mvc,spring-4
I have two controller methods shown below, the /garages/a works when I post JSON to it (response is a 200) but the /garages/a/brand gives a 404. They only differ by the mapping value. I am using Spring 4.1.4.RELEASE and Java config. I am not using Spring Boot. Controller methods: @RequestMapping(value...

what is the difference between using or not Spring Beans?

java,spring,dependency-injection,spring-4
Probably i'll get a lot of downvotes, but it's so confusing for me all this fact of whether use beans or not. Lets suppose this example interface ICurrency { String getSymbol(); } public class CurrencyProcessor { private ICurrency currency ; public CurrencyProcessor(ICurrency currency) { this.currency = currency; } public void...

Missing SpringBeanJobFactory in Spring 4

java,spring,maven,spring-4
Looking at upgrading from Spring 3.2.3 to 4.1, this class seems to have disappeared,is there a migration path for it? is it perhaps just not pulled in by Spring core anymore? import org.springframework.scheduling.quartz.SpringBeanJobFactory; ...

Using one DataSource object for multiple DB connections - using only one connection at a time

spring,spring-jdbc,spring-4
Can we define only one DataSource object and wire it dynamically at runtime connecting to different databases ? I need to connect to only one database at a time. I will be passing the name of the Database as argument. I will lookup the DB URL and other details from...

Customize Spring @RequestParam Deserialization for Maps and/or Nested Objects

spring,spring-mvc,spring-boot,spring-4,http-request-parameters
@RestController class MyController { @RequestMapping(...) public void test(Container container) { ... } } Spring by default uses Dot-Notation to deserialize a nested @RequestParam: class Container { A a; } class A { String val; } works with: http://.../myController?a.val=foo But for Maps it uses Square Bracket notation: class Container { Map<String,...

Rest Custom HTTP Message Converter Spring Boot 1.2.3

spring,spring-boot,spring-4,spring-restcontroller,spring-json
I want to create a custom of HttpMessageConverter using Rest, Json, Spring Boot 1.2.3 and Spring 4, However my custom HTTPMessageConverter its' never called. I have preformed the following steps : 1: Created a class that extends AbstractHttpMessageConverter @Component public class ProductConverter extends AbstractHttpMessageConverter<Employee> { public ProductConverter() { super(new MediaType("application",...