spring

Spring + Hibernate: how to have a configurable PK generator?

We use Spring + Hibernate for a Webapp. This Webapp will be deployed on two unrelated production sites. These two production sites will use the Webapp to generate and use Person data in parallel. What I need to do, is to make sure that the Persons generated on these two unrelated production sites all have distinct PKs, so that we can m...

How to make Jetty dynamically load "static" pages.

I am building Java web applications, and I hate the traditional "code-compile-deploy-test" cycle. I want to type in one tiny change, then see the result INSTANTLY, without having to compile and deploy. Fortunately, Jetty is great for this. It is a pure-java web server. It comes with a really nice maven plugin which lets you launch Jetty...

How to connect my Spring + Hibernate based application backend with pure HTML and AJAX based client?

Hi all, I'd like to call methods of my DAOs by AJAX. I'm quite new in that so I would like to ask what is the best way to do that. Is it possible to publish my beans as web services and call them with e.g. jQuery? I think it is not possible :) I've also read about Direct Web Remoting but I don't know which way to go... As I see, there...

How to configure spring HandlerExceptionResolver to handle NullPointerException thrown in jsp ?

From a jsp is thrown a NullPointerException for example using <% null.toString(); %> This exception is not handled by the HandlerExceptionResolver, but thrown to the web container(tomcat) and converted into a code 500 error. How can I configure spring to get that error in my HandlerExceptionResolver ? Details: Spring can be configu...

Progressbar from Spring Context?

I would like to create a window with a progressbar which shows the current status of Spring's object instantiation. From Spring.Net's documentation it seems that IObjectPostProcessors is the right point to start and track whenever an Object has been instanciated. However in order to get "Percentage of instantiated classes" I need to ask...

Spring initialization order

Suppose I have a couple of spring beans: <beans> <bean name="A" ... /> <bean name="B" ... /> </beans> "B" exposes a remote service that doesn't need "A". Assume that "A" takes a non-negligble time to load. What this means is that during a restart cycle, the application hangs the remote client, which can actually connect to the ...

Grails File Upload Problems

I'm trying to emulate the file upload code from the grails website, and I'm running into some problems. I'm using the same code as found here. Here is my code: <g:form action="upload" method="post" enctype="multipart/form-data"> <input type="file" name="myFile" /> <input type="submit" value="Upload" /> </g:form> and def uploa...

Different spring XML files for development environment vs. deployment when using maven

Summary We have a central LDAP server that our deployed Java web app should connect to. Our JUnit tests depend on specific data in the LDAP repository, so they need to connect to an embedded ApacheDS LDAP server, primed with a sample data set. How do we make sure that the ApacheDS server doesn't start up when we deploy our webapp? De...

What is the best way to initialize a bean?

In spring you can initialize a bean by having the applicationContext.xml invoke a constructor, or you can set properties on the bean. What are the trade offs between the two approaches? Is it better to have a constructor (which enforces the contract of having everything it needs in one method) or is it better to have all properties (wh...

In a spring configuration, what is the difference between using name vs id?

In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribute? ...

getResultSet from Spring-JDBC

Hi, I'm using Spring's support for JDBC. I'd like to use JdbcTemplate (or SimpleJdbcTemplate) to execute a query and obtain the result as an instance of ResultSet. The only way that I can see of achieving this is using: String sql = "select * from...."; SqlRowSet results = jdbcTemplate.queryForRowSet(sql); ((ResultSetWrappingSqlRowSet...

spring + tomcat + axis2 == jax-ws web service ?

I'm looking for a straightforward example / tutorial for implementing a JAX-WS (soap1.1 and soap1.2) web service based on wsdl definition using spring, axis2 and tomcat. hint anyone ? -- Yonatan ...

Integrating Captcha with Spring Security

What is appropriate way to integrate SpringSecurity with Capcha ? I have following use case : When user will tries to login, if we he failed to login N times, captcha will be displayed, so authentication will be using three parameters : username, password, captcha. But Spring Security doesn't support built in Captcha handling. I just...

How do I inject a single property value into a string using spring 2.5.x ?

I would really like to annotate a method with a reference to a single property in a property file for injection. @Resource("${my.service.url"}} private String myServiceUrl; Of course, this syntax does not work ;) Thats why I'm asking here. I am aware that I can inject the full properties file, but that just seems excessive, I dont wa...

GWT + Spring

Hi Can I access spring bean that exposed using http invoker (server) from GWT application (client) ? If so is there any example / tutorial for that ? -- Yonatan ...

Illegal attempt to associate a collection with two open sessions

Hi all, I'm trying to add a pojo to a collection in another pojo. I'm sure I'm making a really stupid mistake somewhere along the lines but I can't figure out how to solve it. I have a pojo LookupTable which contains a list of Column's: public class LookupTable { private long id; // More properties go here... private List<Column...

Can anyone point me to Spring MVC, Tiles, Freemarker integration example?

In my Spring MVC based applications i use Freemarker and i like it very much, but it's lacking advantages provided by Composite View pattern. I'm thinking of trying to use Tiles2 together with Freemarker - does anyone know where do i find a simple example of SpringMVC together with Tiles2+Freemarker? ...

Spring-WS: How to access MessageContext from PayloadEndpoint

What is the "canonical" way to access the MessageContext from a PayloadEndpoint? We are using PayloadEndpoint and AbstractMarshallingPayloadEndpoint which do not expose the MessageContext to their invoke / invokeinternal methods, but will now need to access the HTTP request parameters. ...

How do I pass model data beween a view state and action state in Spring Web Flow 2.

In the Web Flow below I bind form data to a flow variable (lifeCycleForm) on a submit event in the view state. I have verified that the name, label and description properties are all populated as expected. However, when the expression in the action state is evaluated all three properties are null. My form bean is serializable and I am j...

SpringSecurity : always redirect logged in users to a page

Spring security has a nice feature, it remembers the url of request resource and redirect users to that resource after authentication is successful. But I want users always redirected to some other page, just after user logs in. How is it done? ...