spring

How to use ThreadLocal within Hibernate by Spring

Hello everyone, Currently we use a session per Operation (anti-) Pattern with Hibernate/Spring for our Swing client/server application. The application grew and requests got more and more complex, which resulted in bad performance issues. Because of that, we decided to reuse the session for complex requests, which need to perform more r...

@Autowired annotation not working

I'm trying to test the Autowire option like this: @ContextConfiguration(locations = { "classpath:applnContext.xml" }) public class Foo { @Autowired private Bar bar; public Bar getBar() { return bar; } public void setBar(final Bar bar) { this.bar = bar; } public static void main(final String...

SpringMVC form bind to command object which is interface

I'm learning SpringMVC 2 and i have a form that i need to bind to an object (the command). But what if i need this command object to be an interface so i can use different implementations for the object (of course all the implementations will have the same fields). For binding a form that represents an Account i have this controller. Is...

Spring app cant find hmb.xml mapping file

Hi, i am working on a spring mvc app using hibernate and i am having some trouble compiling and running my code. This is because it cannot find my FileObject.hmb.xml whenever i try to create a session factory bean. my bean looks like this <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">...

Spring 3 show all available routes

How to show all the routes mapped in a spring based application? In rails this is done using rake routes. I use two mapping methods of spring to create the url-mappings: @RequestMapping SimpleUrlHandler I have used the unix command grep and cut to get all the mappings of @RequestMapping. I wonder if there is some way i can get these...

XStreamMarshaller autodetect annotations -- Cannot flush HierarchicalStreamWriter

My context looks like this: <bean id="xStreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" p:converters-ref="converters" p:autodetectAnnotations="true"/> And if I switch on annotation auto-detection I get org.springframework.oxm.xstream.XStreamMarshaller - Could not flush HierarchicalStreamW...

Encoding in SOAP-Faults (Spring Web Services)

I want to encode a String with special characters in a SOAP-Fault. The client is complaining that in the SOAP-Faults, the encoding is not correct, in the usual SOAP Responses it is. I can't find out how to specify encoding (with Spring Web Services) for SOAP-Faults. The only way I found is specifying the Locale for the Fault text with S...

spring 3 RequestMapping get path value

Is there a way to get the complete path value after the requestMapping pathvariable values has been parsed. That is: /{id}/{restOfTheUrl} should be able to parse /1/dir1/dir2/file.html id=1 and restOfTheUrl=/dir1/dir2/file.html Any ideas would be appreciated. ...

How to extract attachments from a Soap Message in Spring

The soap message successfully comes across, and I can print out the envelope just fine, but the attachments are always zero. Even though I put the exact request through SoapUI, and the attachments show up fine in that. Maybe this isn't a valid way to extract the attachments. I'm adding this to the sendandreceive method. private class At...

simple spring app - why use service layer?

hi. i looked at the example on http://solitarygeek.com/java/developing-a-simple-java-application-with-spring/comment-page-1#comment-1639 because i'm just getting started with spring. And, i'm trying to figure out why the service layer is needed in the first place in the example he provides. if you took it out, then in your client, you ...

Spring Roo addon creation exception

I am trying to create a simple addon using the script provided with the roo 1.1.0M3 zip but I am getting this error Could not locate '/org/springframework/roo/addon/creator/simple\roo-addon-simple-template.xml' in classloader Script execution aborted Can anybody please help me solve this problem? Thanks Shekhar ...

Spring: "SimpleLogger does not seem to be location aware" exception

I'm getting an exception in a Spring app on my first line of code: ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); I have commons-logging-1.1.1.jar configured as a project library. Here is the stack trace: java.lang.UnsupportedOperationException: The logger [org.slf4j.impl.SimpleLogger(org.springframewo...

Spring 3+ How to create a TestSuite when JUnit is not recognizing it

I'm using Spring 3.0.4 and JUnit 4.5. My test classes currently uses Spring's annotation test support with the following syntax: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration (locations = { "classpath:configTest.xml" }) @TransactionConfiguration (transactionManager = "txManager", defaultRollback = true) @Transactional pu...

Spring2 web MVC - dynamic views for controller ?

Is there a way in Spring2 to build dynamic views to which a Controller can redirect to? I have a form with a hidden field for an ID. If the form is submited or other exception occurs i want to redirect back to the form (i have set formView). It redirect ok, but when it redirect back to form it is loosing the ID parameter. Is there a way...

Approach for validating 1 of n fields must be valid?

What's the preferred approach for validating that at least one of fieldA, fieldB, or fieldC is valid using a Spring 3 validator? In other words, any 2 of the fields can be invalid, as long as the third is not. ...

Books/tutorials that learn by writing an appliaction?

Ok so how I see it the best way to learn is to write a real app so I've been wondering are there any books/tutorials that get you through different languages/frameworks by writing a single app and not by showing some random code snippets. What I mean is that in chapter one we create the app, then in chapter 2 we add some features and inc...

How do I resemble the typical "confirmation of account" procedure seen in multiple websites?

I want to resemble the typical "confirmation of account" procedure seen in multiple websites. When a user registers an email is sent to him with a confirmation link. Once the user goes to that confirmation link its account gets confirmed. Don't worry about the email sending process. The thing is that I need to generate a URL to which the...

Howto get rid of <mvc:annotation-driven />?

Up to now, <mvc:annotation-driven /> has caused plenty of trouble for me, so I would like to get rid of it. Although the spring framework docs clearly say what it is supposed to be doing, a listing of tags actually summar <mvc:annotation-driven /> is lacking. So I'm stuck with removing <mvc:annotation-driven /> and now getting the erro...

Can I inject a Java object using Spring without any xml configuration files?

I want to inject a plain java object using Spring programmatically without using any xml configuration. Want to inject fields/methods annotated with tags Like @EJB, @PostConstruct etc. Is that possible? Thanks! ...

How can you print out the values of undeclared HTML form values from a Spring (3) controller action method?

If my HTML form contains two form inputs (input1 and input2), I could access them like this: @RequestMapping(value = "/foo", method = RequestMethod.POST) public String foo(HttpServletRequest request, ModelMap modelMap, @RequestParam(value = "input1") String input1, @RequestParam(value = "input2") String input2) { log...