DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Frameworks Topics

article thumbnail
Build an Online Store With MongoDB, Node.js, and Elasticsearch
Check out the following infographics and brief break-down to help you visualize and understand the decisions involved in choosing a microservice architecture.
March 4, 2016
by Siva Prasad Rao Janapati
· 23,081 Views · 15 Likes
article thumbnail
AWS SQS and Spring JMS Integration
For Java applications, the JMS API is an easy way to use the SQS messaging service in Amazon Web Services, especially with Spring Boot.
March 2, 2016
by Emmanouil Gkatziouras DZone Core CORE
· 45,938 Views · 5 Likes
article thumbnail
How to Make a Stateless (Session-less) Authentication With Spring
In this article, I want to focus on how to deal with automatic re-authentication of each HTTP and HTTPS requests. Read on for more info.
March 1, 2016
by OBEN ISIK
· 106,996 Views · 18 Likes
article thumbnail
Swift for C# Developers
Swift and C# are both high-level programming languages, with shared features, such as being compiled programming languages. Here's a look at Swift from the perspective of a C# developer.
March 1, 2016
by Vidyasagar (Sarath Chandra) Machupalli FBCS DZone Core CORE
· 9,976 Views · 6 Likes
article thumbnail
What is a Provider() in Angularjs?
The provider() function allows us to create a configurable service where we can set input per application for the service created using the provider(). Let's take a look at it in detail.
February 26, 2016
by Josh Anderson
· 37,216 Views · 2 Likes
article thumbnail
Using the jQuery .each() Function (with Examples)
With jQuery dominating JavaScript development, this article is a deep dive into one of the main functions in the library— each().
February 26, 2016
by Paul Underwood
· 99,233 Views · 3 Likes
article thumbnail
Programmatically Extract or Unzip Zip, Rar Files and Check
In this post, we will see how we can extract or unzip the uploaded files and check for some files in it in a programmatic manner. We will use a normal MVC application to work with this demo. Read on for more info.
February 26, 2016
by Sibeesh Venu
· 9,980 Views · 2 Likes
article thumbnail
Fix for “Could Not Connect to the Debugger” While Deploying Xamarin Forms Apps to the Visual Studio Android Emulator
If you've encountered this issue before, author Joost van Schalk discusses how to correct the problem so you can move on with your debugging!
February 26, 2016
by Joost van Schaik
· 18,374 Views · 3 Likes
article thumbnail
Log Management in Spring Boot
A tutorial on how to use Spring Boot to log in an output file, and configure where Spring will store your logs.
February 25, 2016
by Nicolas Fränkel
· 4,728 Views · 4 Likes
article thumbnail
Kill Your Dependencies: Java/Maven Edition
Learn how to kill your dependencies in Java/Maven with these tips, like shooting for zero dependencies, and NOT including Spring.
February 23, 2016
by Sam Atkinson
· 42,934 Views · 36 Likes
article thumbnail
A Second Generation Reactive Foundation for the JVM
Awesome new reactive platform for JVM development.
February 22, 2016
by Josh Long
· 11,691 Views · 9 Likes
article thumbnail
Insights From Stackoverflow: Most Voted for Spring 4 Questions
Spring 4 is widely used, but as with any technology, there are loads of questions. Here are the most asked and answered questions on Stackoverflow, like differences in component and controller annotations, and what the Spring framework is actually used for.
February 20, 2016
by Alex Theedom
· 12,438 Views · 15 Likes
article thumbnail
Angular JS Tutorial – MVC and MVVM Design Patterns
In the first part of a series on Angular JS tutorials, the author walks through some design patterns.
February 20, 2016
by Andrei Prikaznov
· 67,176 Views · 9 Likes
article thumbnail
Don't be Careless With Groovy (Un)checked Exceptions
Groovy language introduced many interesting features from Java programmer's point of view. One of them is the lack of differentiation between checked and unchecked exceptions - a nice quality for programmers who struggled with checked exceptions requirements. It turns out, however, that using this neat Groovy feature with existing frameworks can sometimes be tricky which I've experienced lately. I worked with relatively straightforward microservice written in Groovy. It was built on top of Spring Boot 1.3. Among others, it used @RestController to define REST endpoints and @ControllerAdvice to handle exceptions thrown by the controller or its internals. Very simplified example code looks like this (complete source code can be downloaded from https://github.com/yu55/groovy-undeclared-throwable-demo ): import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @RestController class ExampleRestController { @RequestMapping(value = '/get') String get() { /* Lets imagine this exception is thrown somewhere from deepest layers of our service code and we don't have to be immediately aware of this. */ throw new ExampleRestControllerException() } } Controller advice: import org.springframework.web.bind.annotation.ControllerAdvice import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.ResponseBody @ControllerAdvice class ExampleRestControllerAdvice { @ExceptionHandler(value = ExampleRestControllerException.class) @ResponseBody String onExampleRestControllerException() { return 'ExampleRestControllerException handled in ControllerAdvice' } @ExceptionHandler(value = Exception.class) @ResponseBody String onException() { return 'Exception handled in ControllerAdvice' } } Simple checked exception: class ExampleRestControllerException extends Exception { } When ExampleRestControllerException was thrown, it was handled by onExampleRestControllerException() method in ExampleRestControllerAdvice class. And this worked perfectly fine. But I had to add a simple aspect after the returning of get() method in ExampleRestController to do some additional stuff. @Aspect @Component class RestControllerAspect { @AfterReturning('execution(* org.yu55.ued.controller.ExampleRestController.get())') public void logServiceAccess(JoinPoint joinPoint) { // empty implementation for clarity reasons } With this simple aspect introduced, the microservice began to behave strangely. ExampleRestControllerAdvice started calling the onException() method instead of onExampleRestControllerException() when ExampleRestControllerException was thrown. I didn't expect that. What happened? When the aspect for ExampleRestController.get() method is defined, the Spring generates a proxy for ExampleRestController. Since ExampleRestController doesn't implement any interface, Spring uses CGLIB library instead of java.lang.reflect.Proxy for a dynamic proxy generation [1]. Generated proxy class name is similar to ExampleRestController$$EnhancerBySpringCGLIB$$8d751c8@4481 and it's an ExampleRestController subclass which intercepts all methods calls. There is also another dynamically generated class created: ExampleRestController$$FastClassBySpringCGLIB$$b01891ea which is a ExampleRestController class wrapper. This wrapper class promises faster methods invocations than the Java reflection API [2]. Spring is invoking get() method (via sun.reflect reflection classes) on enhancer class which then invokes get() method (via CGLIB MethodProxy) on fast class instance. When controllers get() method throws ExampleRestControllerException it's rethrown by fast class to an enhancer class and then the enhancer class get() method throwsjava.lang.reflect.UndeclaredThrowableException (which contains ExampleRestControllerException inside). This results in ExampleRestControllerAdvice matchingUndeclaredThrowableException with Exception class and firing handler method different than expected. But why UndeclaredThrowableException is thrown? Because the get() method written in Groovy in fact didn't declare any checked exceptions that it could potentially throw. The proxy doesn't know anything about that controller is written in Groovy and no throws declared means that checked exception may still occur. This behaviour also corresponds to Proxy documentation [3]. The issue can be fixed easily by adding checked exceptions to get() method definition or defining ExampleRestControllerException as runtime exception. Former solution technically works but isn't 'groovy' though and the latter is an approach that Spring prefers and is currently considered to be best practice for exception handling [4]. At the end, I would not blame Groovy for this situation. Instead, I would rather point that despite the fact that Groovy simply don't care about checked exceptions, it doesn't mean that other libraries also don't care. This is not what most programmers think of first when using Groovy. A similar situation may happen with any other JVM language that 'ignores' checked exceptions. The best thing we can do to protect ourselves from situations like this is to prepare tests carefully. Imagine no controller tests for ExampleRestControllerException case - whole application builds and runs perfectly on production until this special case occurs and controller simply returns a wrong answer to the client. A bug like this may not be so obvious and fast to track or fix.
February 19, 2016
by Marcin Pilaczynski
· 20,290 Views · 10 Likes
article thumbnail
How to Build Angular 2 Apps Using Observable Data Services — Pitfalls to Avoid
In this post, we are going to see how an Angular 2 application can be built around the concept of observable data services. Read on to learn more.
February 18, 2016
by Vasco Cavalheiro
· 81,698 Views · 5 Likes
article thumbnail
Write JUnit Tests in Spring With Mocked and Real Objects
How to use mocked and non-mocked data to write unit tests using the free and open source JUnit framework.
February 16, 2016
by Saravanan Kandasamy
· 17,468 Views · 7 Likes
article thumbnail
Create a JSON API REST Service With Spring Boot and Elide
Learn how to make a HSON API REST service using Elide and Spring Boot in this awesome tutorial. The JSON API is a great specification for developers, and is getting much more popular.
February 11, 2016
by Matthew Casperson
· 71,958 Views · 10 Likes
article thumbnail
Python Frameworks: Full-Stack vs. Micro Framework
In part one of this series, we discussed the many different Python frameworks. Building on that, let's categorize them into full vs. micro-stack and analyze some of the top frameworks in each category.
February 10, 2016
by Omed Habib
· 12,891 Views · 3 Likes
article thumbnail
Solr vs Elasticsearch: Battle of The Query DSLs
Comparing Solr and Elasticsearch on how they control ranking, and how their query DSLs stack up against each other.
February 10, 2016
by Doug Turnbull
· 11,100 Views · 11 Likes
article thumbnail
Samy is My Hero - Hacking Spring Boot
Samy Kamar famously authored the MySpace Samy worm, one that basically shut down the social networking site. Here's a quick look at the story of hacking, specifically focused on hacking spring boot.
February 6, 2016
by John Thompson
· 10,271 Views · 5 Likes
  • Previous
  • ...
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×