This post will illustrate a way in which exception handling can be implemented for RESTful web services in Spring in such a manner that the exception handling concerns are separated from the application logic.
Continue reading “RESTful Error Handling with Spring”
Logging JAX-WS SOAP messages in Spring
Whenever you’re using JAX-WS within Spring you’ll probably want to log the incoming and outgoing SOAP messages – if only for debugging during development. So the first thing to do is increase the log levels, right? Unfortunately this will have no effect. What you will have to do is to make use of the javax.xml.ws.handler.HandlerResolver
interface. So how do we do this?
Continue reading “Logging JAX-WS SOAP messages in Spring”
Documenting Spring RESTful APIs
Lately, I’ve been writing alot of RESTful services using the Spring framework and its @RestController. The only thing I really missed was an easy way to document the RESTful API. I’ve looked into various options, and like most people, I found that Swagger seemed to be the only viable option. However, after having tried it, I found some serious issues. Besides being a very bulky dependency to have to include, having a visually attractive but very cluttered front-end in the form of SwaggerUI, what I disliked the most was the pollution of my code with alot of additional annotations.
Continue reading “Documenting Spring RESTful APIs”
Server side logging from browser side JavaScript code
Application logging is something we all do in our applications that get deployed on an application server, right? Using frameworks like Log4J or Logback seems like a no-brainer to most Java developers. But what about the code we’ve written that is running in those pesky browsers? I guess that, apart from the occasional console.log() statement used during debugging, we don’t give much thought to JavaScript logging. I find this situation very regrettable since nowadays the trend appears to be to move our application logic to the browser. And with it, interesting events happening in the browser might go unnoticed, or any bugs that will happen, no matter how well we’ve developed and tested our client side code, might prove needlessly hard to reproduce and therefore fix. In this blog post I’ll demonstrate a very basic setup to log messages from the browser on the server using some very basic JavaScript with jQuery, and a simple Spring controller with Slf4J. Continue reading “Server side logging from browser side JavaScript code”
My First Real AngularJS Project (with Spring REST and Data JPA)
I’ve been playing around with AngularJS since March this year but only in my spare time. So I was thrilled to be able to use AngularJS on an actual real-world project at my day job at the Academic Medical Center in Amsterdam.
So for the last three weeks I’ve been working at a small but nice web site. The web site is a training course catalogue for the nursing education program, which is ordered according to the CanMEDS Framework. Last week I released version 1.0 and next wednesday it will be formally presented to the public during an important conference.
The application is split into a backend with a REST interface and a Single Page frontend that’s basically a master-detail page with some filtering options, and added to it some necessary administration pages. I’ve built the backend of the application with Spring Data JPA, Spring REST, and Spring Security. For the frontend I’d chosen AngularJS and Boostrap 3. Below I will describe some of my experiences from the last couple of weeks.
Continue reading “My First Real AngularJS Project (with Spring REST and Data JPA)”
Devoxx 2013 recap
Last week I attended the 2013 edition of what is likely the best Java conference around: Devoxx. This year I decided to put a small recap of the week on my blog. Continue reading “Devoxx 2013 recap”
Integrating Wicket with Wicket Auth/Roles and Spring Security
In this tutorial I describe how you can setup Wicket 1.5 to use Spring Security 3.1 for authentication and Wicket Auth/Roles for authorization.
Spring Security is a very complete and flexible solution for all kinds of security needs. It offers a lot of functionality out-of-the-box and it is quite easy to extend to fit your own custom needs. Visit the Spring Security website (http://static.springsource.org/spring-security/site/index.html) for more information.
Wicket Auth/Roles makes it easy to annotate components with authorization information. E.g., the @AuthorizeInstantiation configures what roles are allowed to instantiate the annotated component or package, and the @AuthorizeAction annotation controls wether the component is rendered or not based on the roles.
At the and of this tutorial you will have a sample Wicket project that uses Spring Security to look up the user – including roles, full name, etc. -, validate the password, and manage the current user session. Wicket Auth/Roles validates whether the current user has access to a particular page, or even a particular component. Continue reading “Integrating Wicket with Wicket Auth/Roles and Spring Security”