aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Cloud-Native

Three Things To Know Before Debugging Your Spring Application

  • aster.cloud
  • May 10, 2022
  • 5 minute read

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Brian W. Kernigham

Debugging is hard, and in some places—like in the cloud, production, or Java Spring—it’s even harder. Moreover, debugging isn’t just about finding or fixing bugs in code. It also allows developers to better understand existing codebases by allowing them to see the flow of the entire application when starting work on a project they’ve just joined, or to refresh their memory before beginning to code new features. In situations like these, it’s a smart move to begin by running your code in debug mode to ensure you understand the whole flow of the application.

If debugging is the process of removing software bugs, then programming must be the process of putting them in.

Edsger W. Dijkstra

If you want to produce a stable application, debugging is just as important as programming. In order to debug a Spring application, we need to be able to do the following:


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

  • Control the execution of the code by setting breakpoints.
  • Suspend threads and step through the code.
  • Examine the contents of the variables.

In this article, you’ll learn about three things you should be mindful of before you debug your Spring applications, and how a tool like Rookout can make the debugging easier and faster.

What Are Some Java Features Developers Should Be Aware of When Preparing to Debug?

Before you start debugging, you should be aware of some of Java’s features.

  • Remote debugging an application running in production is both risky and tricky. It can affect your application performance, and make it unusable when it hits a breakpoint.
  • Java is increasingly used in distributed environments because it supports multithreading, core networking api, and rich data structures. Debugging a multithreaded application is complicated, as you have to track multiple threads simultaneously.
  • You should know that JVM’s default behavior is to disable debugging. Due to the security concerns posed by opening ports for the debugger to access the server, enabling remote debugging for applications in production isn’t recommended.
Read More  10 Ways To Make Your Software Pipeline More Observable

To enable the debug mode on the Java Virtual Machine (JVM) for a Maven-based Spring Boot application, you can pass the following command-line arguments to the JVM.

<span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=500</span><span class="token template-punctuation string">`</span></span>

Another option is to provide the following configuration with the Spring Boot Maven plugin in your Maven pom.xml file.

      <span class="token tag"><span class="token punctuation"><</span>plugin<span class="token punctuation">></span></span>
        <span class="token tag"><span class="token punctuation"><</span>groupId<span class="token punctuation">></span></span>org.springframework.boot<span class="token tag"><span class="token punctuation"></</span>groupId<span class="token punctuation">></span></span>
        <span class="token tag"><span class="token punctuation"><</span>artifactId<span class="token punctuation">></span></span>spring-boot-maven-plugin<span class="token tag"><span class="token punctuation"></</span>artifactId<span class="token punctuation">></span></span>
        <span class="token tag"><span class="token punctuation"><</span>version<span class="token punctuation">></span></span>2.2.6.RELEASE<span class="token tag"><span class="token punctuation"></</span>version<span class="token punctuation">></span></span>
        <span class="token tag"><span class="token punctuation"><</span>configuration<span class="token punctuation">></span></span>
          <span class="token tag"><span class="token punctuation"><</span>jvmArguments<span class="token punctuation">></span></span>
            -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
          <span class="token tag"><span class="token punctuation"></</span>jvmArguments<span class="token punctuation">></span></span>
        <span class="token tag"><span class="token punctuation"></</span>configuration<span class="token punctuation">></span></span>
        ...
      <span class="token tag"><span class="token punctuation"></</span>plugin<span class="token punctuation">></span></span>

After this, all you need is an IDE with support for debugging.

Three Issues You Should Be Aware of When Preparing to Debug a Java/Spring Application

When you’re going to debug your applications remotely, there are some issues you should plan for ahead of time. We’ll cover three of the big ones now, and will also discuss how tools like Rookout can help overcome these challenges.

Remote Debugging

Java is optimized to be debugged locally, and requires care and attention when debugged in non-local environments. Normally, debugging happens in an IDE, which requires a unique setup on a server. This works well if you’re planning to debug the application locally, but it’s an entirely different situation when you have to debug an application running live in production, serving requests. Advanced live debugging options provided by tools like Rookout can help ease the process of remote debugging in production. With Rookout, you can set non-breaking points without stopping your application, and inspect the code without worrying about application performance.

Read More  Cloudflare Expands Its Zero Trust Platform To Become The Only Cloud-Native Provider With Network Scale

Debugging in a distributed environment

Debugging your application in a distributed environment can be overwhelming. Imagine how challenging it is to track down and isolate a production issue in an application deployed and running on multiple servers. Thankfully, Rookout’s live remote debugging capabilities can help. You don’t even need to SSH to the remote server or redeploy your application after adding tons of log statements. All you need is to connect your application to the tool, and from there on, you can debug it just like you would locally on your laptop.

Debugging cloud-native applications

It’s common nowadays to containerize your Spring applications and run on top of a container orchestrator like Kubernetes. Debugging non-containerized workloads was never easy, and containerization adds an extra layer of complexity. With a new way of deploying and running your cloud-native workloads, the traditional approach to debugging doesn’t work— third party live debugging tools can help you master this new approach.

  • Kubernetes itself provides several out-of-the-box options to debug an issue with your Pod. This is a list of commands that we can use to troubleshoot an issue with Kubernetes workloads.
kubectl describe
kubectl logs
kubectl exec
kubectl port-forward
kubectl debug
  • Another option worth considering is using the debugging capabilities of tools like Skaffold. Skaffold is an open-source tool developed by Google that helps improve developer experience with Kubernetes deployments. It can automate the build, pushing and deploying boilerplate parts of applications deployed to Kubernetes. Not only that, but using the skaffold debug command, it can detect container runtime technologies (for example, JDWP for Java and debugpy for Python applications) and enable debugging functionality on the fly.
  • Telepresence is another option for debugging Kubernetes services locally. Telepresence accelerates the inner development loop for Kubernetes applications by creating a bidirectional network connection between your local development machine and the remote-managed Kubernetes cluster. You don’t have to spend time configuring remote debugging protocols and exposing ports using the kubectl port-forward command to access remote Kubernetes services locally.
  • Rookout delivers painless debugging for your cloud-native workloads. You don’t have to wait or waste time replicating an issue or adding code to debug an issue in an application running live on the production server. Out-of-the-box debugging options provided by Kubernetes can be overwhelming, and it’s hard to know which kubectl command you should be running to get to the root cause of your issue. Live debugging tools like Rookout are worth investing in because they can immediately gather debug data from applications running in your cluster—without having to compromise on security. Moreover, the debug data can be fed to observability tools like Prometheus and Grafana for analysis.
Read More  How To Select A Network Gateway For Your Private Cloud

Conclusion

Software delivery goes through multiple iterations of testing, but bugs are inevitable, and debugging is one of your best defenses against them. Classic debugging options are still widely used, but tools like Rookout, that provide seamless live debugging capabilities, are the way of the future.

 

 

Guest post originally published on the Rookout blog by Karl Hughes
Source CNCF


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

aster.cloud

Related Topics
  • CNCF
  • Debugging
  • Java Virtual Machine
  • Rookout
You May Also Like
View Post
  • Cloud-Native
  • Multi-Cloud

Oracle Expands Multicloud Capabilities with AWS, Google Cloud, and Microsoft Azure

  • September 11, 2024
Cloud computing concept image double exposure Digitally Enhanced Smart City Concept with Cloud Computing
View Post
  • Cloud-Native
  • Computing
  • Hybrid Cloud
  • Multi-Cloud
  • Public Cloud

Make Your Business Resilient By Integrating These Best Practices Into Your Cloud Architecture

  • July 29, 2024
Huawei Cloud Cairo Region Goes Live
View Post
  • Cloud-Native
  • Computing
  • Platforms

Huawei Cloud Goes Live in Egypt

  • May 24, 2024
View Post
  • Cloud-Native
  • Computing
  • Engineering

10 Cloud Development Gotchas To Watch Out For

  • March 29, 2024
Storage Ceph
View Post
  • Cloud-Native
  • Data

The Growth Of IBM Storage Ceph – The Ideal Foundation For A Modern Data Lakehouse

  • January 30, 2024
Clouds
View Post
  • Cloud-Native
  • Platforms
  • Software Engineering

Microsoft Releases Azure Migrate Assessment Tool For .NET Application

  • January 14, 2024
View Post
  • Cloud-Native
  • Engineering
  • Platforms

Top Highlights From AWS Worldwide Public Sector Partners At Re:Invent 2023

  • December 27, 2023
View Post
  • Cloud-Native
  • Computing

Supercharging IBM’s Cloud-Native AI Supercomputer

  • December 24, 2023

Stay Connected!
LATEST
  • college-of-cardinals-2025 1
    The Definitive Who’s Who of the 2025 Papal Conclave
    • May 7, 2025
  • conclave-poster-black-smoke 2
    The World Is Revalidating Itself
    • May 6, 2025
  • 3
    Conclave: How A New Pope Is Chosen
    • April 25, 2025
  • Getting things done makes her feel amazing 4
    Nurturing Minds in the Digital Revolution
    • April 25, 2025
  • 5
    AI is automating our jobs – but values need to change if we are to be liberated by it
    • April 17, 2025
  • 6
    Canonical Releases Ubuntu 25.04 Plucky Puffin
    • April 17, 2025
  • 7
    United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services
    • April 15, 2025
  • 8
    Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology
    • April 2, 2025
  • 9
    IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management
    • March 27, 2025
  • 10
    Tariffs, Trump, and Other Things That Start With T – They’re Not The Problem, It’s How We Use Them
    • March 25, 2025
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    IBM contributes key open-source projects to Linux Foundation to advance AI community participation
    • March 22, 2025
  • 2
    Co-op mode: New partners driving the future of gaming with AI
    • March 22, 2025
  • 3
    Mitsubishi Motors Canada Launches AI-Powered “Intelligent Companion” to Transform the 2025 Outlander Buying Experience
    • March 10, 2025
  • PiPiPi 4
    The Unexpected Pi-Fect Deals This March 14
    • March 13, 2025
  • Nintendo Switch Deals on Amazon 5
    10 Physical Nintendo Switch Game Deals on MAR10 Day!
    • March 9, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.