spring

how to set SqlMapClient outside of spring xmls

I have the following in my xml configurations. I would like to convert these to my code because I am doing some unit/integration testing outside of the container. xmls: <bean id="MyMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation" value="classpath:sql-map-config-oracle.xml"/> ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and annotations to realize that. e.g. @Component @Scope("application") public class SomeForm { @PersistenceContext EntityManager entityManager...

SpringFramework JdbcTemplate RowMapper

Hi, I am wondering if JdbcTemplate and RowMapper supports complex object retrieval. I couldn't find anything with google on this matter (Wrong criteria?). :( Example: public class Person() { private Long id; private String name; private PersonDetail personDetail; } public class PersonDetail() { ... } Tables will loo...

Spring web Dependency Injection(IOC) and the ServletContextListener

Hi all, I have code which is structured as Spring beans and dependencies among them. This is only a small part of the code since the rest is 'legacy' code. At this point in time I would like to perform an action on one of these beans in an existing 'legacy' class that extends javax.servlet.ServletContextListener. This class initializes...

Testing simultaneous calls to transactional service

How should I test a service method that is transactional for its simultaneous use (it updates a database row by decreasing a value)? I have setup a JUnit test class with SpringJunit4ClassRunner and components are @autowired. Just spawning threads which would call the method doesn't seem to work. I'm not sure whether this has something ...

Spring webflow validation

Hi, complete and utter newbie on spring webflow (and indeed, spring mvc). 30 minutes in... got the first page of my flow appearing, which happens to be a captcha, an input field and a submit button. The actual captcha value is stored in session and i need to validate that the input field values matches the value in session. In order to...

How to update a postgresql array column with spring JdbcTemplate?

Hi, I'm using Spring JdbcTemplate, and I'm stuck at the point where I have a query that updates a column that is actually an array of int. The database is postgres 8.3.7. This is the code I'm using : public int setUsersArray(int idUser, int idDevice, Collection<Integer> ids) { int update = -666; int[] tipi = new int[3]; tipi[0] = j...

How can I create a typed Tuple2 from Java / Spring?

I want to be able to create a Tuple2 from spring config where I explicitly declare the types of my parameters: <bean class="scala.Tuple2"> <constructor-arg index="0" value="Europe/London" type="java.util.TimeZone" /> <constructor-arg index="1" value="America/New_York" type="java.util.TimeZone" /> </bean> This does not work...

instantiating spring bean outside the container (for testing)

I have following in my applicaionContext.xml <bean id="IbatisDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="oracle.jdbc.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@123.210.85.56:1522:ORCL"/> <property name="username" value="mydb"/> ...

Spring formBackingObject, Business Object Creation, and Factories

Design question for using Business Objects as formBackingObjects in a Spring SimpleFormController. Our controller's responsibility is to allow an End User to add a new Business Object to our web application. So we are passing our Business Object though the formBackingObject(HttpServletRequest request) method. However, we've run into a...

Is the following utility class thread-safe?

First let's look at the utility class (most javadoc has been removed to simply the example): public class ApplicationContextUtils { /** * The application context; care should be taken to ensure that 1) this * variable is assigned exactly once (in the * {@link #setContext(ApplicationContext)} method, 2) the context is...

Elegant ways to separate configuration from WAR in Tomcat

I am trying to find the best way to pass complex configurations in a Spring webapp running in Tomcat. Currently I use JNDI to pass data sources and strings from the Tomcat context into the webapp, and this works well. But, lets say I need to select the implementation of a notification service. There is no way that Spring can conditiona...

ContextLoaderListener problem while spring is loading up

When my spring is loading up, it says applicationContext.xml is not found in the classpath by throwing FileNotFoundException as can be seen below. Please help me resolve this problem. my web.xml content is as follows, <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.or...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered is in naming services Example SomthingGatewayService.groovy can't be initialized in both these ways - SomthingGatewayService somtinggatew...

Jaxb2Marshaller and primitive types

Is it possible to create a web service operation using primitive or basic Java types when using the Jaxb2Marschaller in spring-ws? For example a method looking like this: @Override @PayloadRoot(localPart = "AddTaskRequest", namespace = "http://example.com/examplews/") public long addTask(final Task task) throws AddTaskFault { // do som...

Ibatis2 and test context

Hi everyone, I'm having a stupid configuration issue with Ibatis in my Spring project. Please don't jump on me about how all this was setup, I'm just following the "in house project structure policy". So here is the structure, we have the "src/main/resources/META-INF/" folder that contains all of our config files used by the applicati...

SSL Handshake issue using Spring RESTTemplate

Im using the Spring RESTTemplate on the client side to make calls to a REST endpoint. The client in this case is a spring app and using Tomcat as the servlet container. I'm running into issues making a connection to a https endpoint. I am receiving the following error: org.springframework.web.client.ResourceAccessException: I/O error:...

Spring Properties File

Hi. Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using native2ascii and it solved my problem. Is there no other way of converting the file through setting the encoding to ascii in the confi...

SimpleFormController help

Hi, I am very new to Spring and I have been given some basic instructions to move some code into a new project that uses Spring and I am having trouble with the SimpleFormController (which I was instructed to user). I have a page and when it loads it has a drop down with data populated from the DB. A list of "messages" is retrieved fr...

Spring MVC on Oracle 11gR1

Hi I am using Eclipse webtools to develop a hello world application that runs on oracle 11gR1 development server. I use the Oracle eclipse tools to perform the deployment on the server. I am following the 'Developing a Spring Framework MVC application step-by-step' guide. I passed step 1 by having a simple jsp work. But step 2 brings m...