spring

Dealing with command line arguments and Spring

When I'm writing a Spring command line application which parses command line arguments, how do I pass them to Spring? Would I want to have my main() structured so that it first parses the command line args and then inits Spring? Even so, how would it pass the object holding the parsed args to Spring? ...

Workaround for Spring/Hibernate due to non-standard behaviour of UNIQUE constraint in MS SQL

There is a UNIQUE database constraint on an index which doesn't allow more than one record having identical columns. There is a piece of code, managed by Hibernate (v2.1.8), doing two DAO getHibernateTemplate().save( theObject ) calls which results two records entered into the table mentioned above. If this code is executed without ...

What parts of application you prefer to be externalized as configuration and why?

What parts of your application are not coded? I think one of the most obvious examples would be DB credentials - it's considered bad to have them hard coded. And in most of situations it is easy to decide if you want something to be externalized or coded.For me the rules are simple. Some part of the application should be externalized if:...

How do you acess a property of a bean for reading in a spring xml config file?

I want to do something like the following in spring: <beans> ... <bean id="bean1" ... /> <bean id="bean2"> <property name="propName" value="bean1.foo" /> ... I would think that this would access the getFoo() method of bean1 and call the setPropName() method of bean2, but this doesn't seem to work. ...

How to properly setup a multi module SpringMVC application created by appfuse in Eclipse?

I am trying to setup a multi module SpringMVC appfuse applicaiton in Eclipse but it seems that I'm facing lots of errors in Eclipse after I import the project in Eclipse. Can anyone please help me with a step by step guideline showing the ideal way to setup such application in Eclipse? ...

Separation of Presentation and Business Tiers with Spring

Hi there, In my just-completed project, I was working getting distributed transactions working. We implemented this using JBoss's Arjuna Transaction Manager, and Spring's declarative transaction boundaries. Our request sequence looked like: browser -> secured servlet -> 'wafer-thin' SLSB -> spring TX-aware proxy -> request-handler PO...

download mail attachment with Java

Hi, I had a look in the reference doc, and Spring seems to have pretty good support for sending mail. However, I need to login to a mail account, read the messages, and download any attachments. Is downloading mail attachments supported by the Spring mail API? I know you can do this with the Java Mail API, but in the past I've found th...

Hibernate SessionFactoryBean for multiple locations of mapping files

We have a project consisting of multiple subprojects. With each subproject we potentially have some hibernate mapping files but in the end only one actual hibernate session. Those subprojects could be combined in several ways, some depend on each other. My problem is that actually I want to have a SessionFactoryBean which would be able t...

Cause of No suitable driver found for...

I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my dao (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've overriden the configLocations as follows: protected String[] getConfigLocations(){ return n...

Dynamic breadcrumb generation - how to do?

I'm in the early phases of developing a brand spanking new site with Spring + Tiles. The site needs dynamically generated breadcrumbs. What I mean by dynamic is that the user may reach a certain site from multiple starting points. If I have views for Customers, Orders and Products, the user could reach a Product directly: Products -> P...

What is the role of Spring in Struts + Spring + Hibernate?

What role is Spring taking in Struts + Spring + Hibernate? ...

Spring MVC Form tags: Is there a standard way to add "No selection" item?

There is a select dropdown and I want to add "No selection" item to the list wich should give me 'null' when submitted. I'm using SimpleFormController derived controller. protected Map referenceData(HttpServletRequest httpServletRequest, Object o, Errors errors) throws Exception { Map<String, Object> map = new HashMap<String, Object...

How best to modify my model in Spring MVC if I care about IOC

I am building an application using Spring MVC. I want to make certain changes to my Model for every Controller in the application. In particular, I want to insert certain extra data into the model which will be present for all pages of the application. I could do this several ways: just add the data at the end of every Controller, use a...

Spring: Obtaining ResourceBundle based on MessageSource

I'm using hibernate validator framework with Spring. A class implementing the Spring Validator validates objects with Hibernate's ClassValidator. To localize ClassValidator's error messages I need to pass a ResourceBundle into the class' constructor. My ApplicationCountext has a MessageSource bean (ReloadableResourceBundleMessageSource) ...

Autostart spring app

So is there a way to initialize and start a command line Spring app without writing a main method. It seems like all such main methods have the same form public static void main(final String[] args) throws Exception { ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", Boot.class); FooService fooService = ...

Multiple instances of a java web application sharing a resource

Hi All, I have a web service, that takes an input xml message, transforms it, and then forwards it to another web service. The application is deployed to two web logic app servers for performance, and resilience reasons. I would like a single website monitoring page that allows two things ability to stop/ start forwarding of message...

Spring webflow : Move through view states

Within a spring webflow, i need to implement a navigation bar that will allow to "step back" or resume the flow to one of the previous view. For example : View 1 = login View 2 = My informations View 3 = My messages View 4 = Close session For this example, i would like to return back to view 2 from the view 4 page. ...

Unmanaged Threads Spring Quartz Websphere Hibernate

It appears that our implementation of using Quartz - JDBCJobStore along with Spring, Hibernate and Websphere is throwing unmanaged threads. I have done some reading and found a tech article from IBM stating that the usage of Quartz with Spring will cause that. They make the suggestion of using CommnonJ to address this issue. I have ...

Strange Hibernate Cache Issue

Hello We are using Hibernate 3.1 with Spring MVC 2.0. Our problem occurs when data is updated on the database directly (not in the application). We use a Filter to filter a collection of results by whether the orders are opened or closed. If we change an order on the DB to be closed, the filter returns the correct list, however, the ...

Xml configuration versus Annotation based configuration

In a few large projects i have been working on lately it seems to become increasingly important to choose one or the other (XML or Annotation). As projects grow, consistency is very important for maintainability. My question is, what do people prefer. Do you prefer XML based or Annotation based? or Both? Everybody talks about XML conf...