Category Archives: java

GraphQL for Java Developers: What You Actually Need to Know

GraphQL has been on the Java back-end radar for a while, mostly as something the front-end team kept bringing up. In 2022 that shifted. Spring for GraphQL 1.0 became generally available in May. The official Spring team now provides first-party … Continue reading

Posted in java | Tagged , , , | Comments Off on GraphQL for Java Developers: What You Actually Need to Know

Apache Kafka vs RabbitMQ for Messaging in Java (and Where ActiveMQ Fits In)

If you’re standing in front of a whiteboard in Java land and someone has just drawn a box labelled “message queue,” you’re probably going to argue about Apache Kafka and RabbitMQ for the next forty minutes. They’ve become the default … Continue reading

Posted in java | Tagged , , , , , | Comments Off on Apache Kafka vs RabbitMQ for Messaging in Java (and Where ActiveMQ Fits In)

Java Web Servers Compared: Tomcat, JBoss EAP, WildFly, and Spring Boot

If you’ve been writing Java for the web at any point in the last two decades, you’ve had to pick a web server or application server at least once. The choices haven’t changed much in name — Tomcat, JBoss, WildFly, … Continue reading

Posted in java | Tagged , , , , , | Comments Off on Java Web Servers Compared: Tomcat, JBoss EAP, WildFly, and Spring Boot

Starting a Spring Boot API Microservice From Scratch With Spring Initializr

The fastest way to get a new Java microservice off the ground is also the most boring one, and that’s a compliment. You go to start.spring.io, click a few checkboxes, download a zip, and you have a runnable Hypertext Transfer … Continue reading

Posted in java | Tagged , , , | Comments Off on Starting a Spring Boot API Microservice From Scratch With Spring Initializr

Setting log4j log level programmatically

Sometimes you don’t want to ship a log4j.properties file — you want to spin up logging in code. Useful inside unit tests, one-off debug runs, or anywhere you want to flip log levels at runtime. Here’s a self-contained setupLog4j() that … Continue reading

Posted in java | Comments Off on Setting log4j log level programmatically

Print java stack trace from anywhere

Need to know which code calls a specific location? Dump the stack trace: 1234import org.apache.commons.lang3.exception.ExceptionUtils; // …somewhere in your method: LOG.trace(ExceptionUtils.getStackTrace(new Throwable())); You’re constructing a Throwable just to capture the current stack — you’re not throwing it. ExceptionUtils.getStackTrace turns the … Continue reading

Posted in java | Comments Off on Print java stack trace from anywhere

Knowing your exception class name

You’re staring at a generic catch (Exception e) and you don’t know which actual exception is being thrown. The trick is to log the runtime class so you can replace the generic catch with a specific one: 12345} catch (Exception … Continue reading

Posted in java | Tagged | Comments Off on Knowing your exception class name

Apache Lucene: The Search Engine Hiding Inside Half the Internet

If you’ve ever used Elasticsearch, Solr, or even some features in big platforms like Twitter or LinkedIn, chances are you’ve been touching Apache Lucene without knowing it. It’s the quiet workhorse — a Java library that does one thing extraordinarily … Continue reading

Posted in java | Tagged , , | Comments Off on Apache Lucene: The Search Engine Hiding Inside Half the Internet

Ant Junit debugging

Sometime we want to debug why ant build failed when executing a certain JUnit Make sure your ant junit task look like the following 1234<junit printsummary="withOutAndErr" haltonfailure="yes"> : : </junit> and not like 1234<junit printsummary="yes" haltonfailure="yes"> : : </junit>

Posted in java | Comments Off on Ant Junit debugging

Java Flight Recorder: a profiler that’s already in your JVM

If you’re running anything on the JVM (Java Virtual Machine) in production and you’ve never opened a Flight Recorder file, you’re leaving a free profiler on the table. Java Flight Recorder (JFR) is a low-overhead event recorder built into the … Continue reading

Posted in java | Comments Off on Java Flight Recorder: a profiler that’s already in your JVM