Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Howard Hyde

+ Follow
since Dec 01, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Howard Hyde

I have more installments to this in the pipeline, but I need to know that there is interest. Please post a reply or give me some points if you are finding this worthwhile.
2 years ago
Next installment, again intended for YOU to benefit from AND to critique.

Spring Boot Tutorials
Comments on Spring Boot in general
Spring Boot, rather than being separate and distinct from Spring Framework, Spring MVC etc, may be thought of as an approach to developing Spring Framework apps, a framework for a framework; a minimalist approach optimized to require the least information from the developer in order to realize the maximum functionality. It accomplishes this by being “opinionated” in the use and implementation of default configuration and functionality. If the xyz property in 99% of cases gets set to the value ‘abc’, then why require the developer to provide a value for that property?  The framework will set xyz = ‘abc’ unless otherwise specified/overridden by the developer.
If you are an experienced Spring Framework developer, then you will likely find Spring Boot to be an extremely convenient labor reducer and productivity tool. On the other hand, if you’ve never done any Spring at all before, then you will also find Spring Boot to be an extremely convenient labor reducer and productivity tool, but in the longer run you will need to know more about what it is actually doing for you under the covers. Superficial knowledge of how to push the buttons, cookbook-fashion, will be inadequate when things go wrong, when you need to debug complex programs. An experienced Spring Framework developer will have a much easier time because he or she understand the lower levels.

We will defer a deeper discussion of Dependency Injection and Inversion of Control, key concepts and features of Spring applications, until after we have gotten our feet wet.

The Tutorials
Below are the recommended tutorials for Spring Boot. The first one gives you options of building with Gradle, Maven or the Spring Tool Suite (STS) IDE, which is based on Eclipse. I recommend that unless you know you are going to be working with Gradle, you may skip that part for now and go with Maven; but definitely do that before you build with STS; and definitely build with STS after that because that’s likely to be your most common development environment and tool going forward for all but the most trivial Spring Boot applications.
If you’ve not worked with Java annotations much before, you may freak at all the @SpringBootApplication, @Bean, @Autowired, @Component and suchlike that you encounter in Spring and Spring Boot applications. For your convenience, here are a couple of basic tutorials on annotations.

Here are the main recommended introductory tutorials on Spring Boot.
And the following, which is linked from the previous, shows you how to set up any starter project in STS.

Speaking of “Starters”...
Comments on “Building an Application with Spring Boot”
The tutorial mentions, casually, almost in passing, that your pom.xml needs the entry:

Make no mistake: That’s huge! With that one little entry comes enough materiel to provision an expeditionary army. The official description for that artifact is, “Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container”.  So all of those resources are now available and included for you; a complete set of web development tools and technologies, for the price of typing fewer than 150 bytes. You don’t have to download, install and configure a webserver, you just get one free of charge or effort, embedded and full-featured.
How does it do all of that? Well, the key word there is “starter”.  Starters are dependencies that contain or reference other dependencies, which are included in the package for you without you having to spell them all out in your app’s pom.  So for example, spring-boot-starter-web has a pom.xml of its own with the following dependency entries:

And since you see the word “starter” in some of those entries, you understand that the pom for each of those lists more dependencies of their own which aggregate to provide all of the functionality needed for that topic.
So a single starter entry may save you the trouble of including dozens or even hundreds of dependency entries in your pom.
One ramification of this is that if someone asks you, do you know Spring MVC? – and you say, No, I only know Spring Boot, if your Spring Boot app has the spring-boot-starter-web entry in its pom and you are utilizing the functionality provided by the included JARs, then Yes, you ARE a Spring MVC developer. Put another way, once you dip your toe into the Spring ecosystem, any and all aspects of it are your domain.

One Very Special Starter
…is <spring-boot-starter-parent>.
This is the starter that brings in all of the dependencies/libraries that you need to spring up a Boot application, or boot up a Spring application, depending on your preference of puns.

Not all elements that you included in your pom.xml, or in your Java app, are hard-coded literals; some or many may be resolved at runtime by properties in the system or in a .properties file.  As you read tutorials on Maven and Spring, you’re eventually going to notice elements preceeded by a dollar sign and wrapped in curly braces, like our fictitious heading ${maven-property}.
According to,
Properties are the last required piece to understand POM basics. Maven properties are value placeholder[s], like properties in Ant. Their values are accessible anywhere within a POM by using the notation ${X}, where X is the property.
They come in five different styles:
1. env.X: Prefixing a variable with "env." will return the shell's environment variable. For example, ${env.PATH} contains the PATH environment variable.
Note: While environment variables themselves are case-insensitive on Windows, lookup of properties is case-sensitive. In other words, while the Windows shell returns the same value for %PATH% and %Path%, Maven distinguishes between ${env.PATH} and ${env.Path}. As of Maven 2.1.0, the names of environment variables are normalized to all upper-case for the sake of reliability.
2. project.x: A dot (.) notated path in the POM will contain the corresponding element's value. For example: <project><version>1.0</version></project> is accessible via ${project.version}.
3. settings.x: A dot (.) notated path in the settings.xml will contain the corresponding element's value. For example: <settings><offline>false</offline></settings> is accessible via ${settings.offline}.
4. Java System Properties: All properties accessible via java.lang.System.getProperties() are available as POM properties, such as ${java.home}.
5. x: Set within a <properties /> element in the POM. The value of <properties><someVar>value</someVar></properties> may be used as ${someVar}.

For a more detailed exploration of Maven properties, see this article:

COPYRIGHT 2019 by Howard Hyde. All Rights Reserved.
2 years ago
I am working on an updated edition of my 2012 book “Java Web Database Application Development” ( which will use SpringBoot, JPA/Hibernate and Thymeleaf. My open-source project at features a complete sample application built this way.
With the moderator's permission I would like to preview some content here to see if the CodeRanch hands find this valuable and/or have any constructive criticism to offer.

I start out with a Chapter Zero for people with no prior Spring Boot experience. And since before working with Spring Boot one has to know the rudiments of Maven, Ant or Gradle, I start with a review of Maven.
So my actual topic for this post is Maven, if you are interested.

My proposed content is:
[COPYRIGHT 2019 by Howard Hyde. All rights reserved]

Essential Tutorials (in this order)
There are many good technical tutorials available, in fact so many that it can be difficult to nail down the ones that are most essential for one’s mission.  The ones listed below are the ones that I recommend for our present purposes, more or less in the given order.
By the way, take all the time you need.  The tutorial may state that you can learn this in 15 minutes, and if you can do it in just 5, that’s great, but if instead you really need 5 hours to get into the material hands-on and with variations, take the 5 hours without apology. I frequently think of the analogy of the musician who, even though he or she “knows” the scales, still practices them, polishes them, refines them daily, even 20 years into a professional career.

Maven Build Tool Tutorials

IF YOU DON’T KNOW MAVEN, DON’T SKIP THIS STEP! It is essential to have a basic understanding of Maven for all of your work with Spring Boot and Spring Tool Suite (STS). Maven is the build tool of choice for Spring apps (Gradle is an alternative if you or your manager prefers).

Comments on these tutorials and on Maven generally
IMHO the two tutorials listed here are tied for first place as the clearest and most concise explanations of what Maven is, what it does and how it does it that I have found. I recommend you go through both of them; they overlap on several points, but take different approaches.  Just as two eyes facilitate 3-dimensional vision, the enrichment of a second presentation of the same topic can be a force-multiplier of your understanding. Again, I wish I had seen these the first time I heard of Maven; it would have saved me a bundle in headache medication.

You won’t use every feature even of these simple getting-started tutorials right away; but they will give you a strong foundation upon which to build your skills.

If you’ve never used a build tool like Ant, Gradle or Maven before, you may be wondering, when do I execute javac (Java Compile) at the command line? The answer is, you don’t. The build tool does that for you, in this case Maven via the mvn compile and/or mvn package commands; and it handles all of the internal class and external library/JAR dependencies based on the information you provide it in your pom.xml file.

Point to highlight: “INFO: You might like to consider using the Maven wrapper to insulate your developers against having the correct version of Maven, or having to install it at all. Projects downloaded from Spring Initializr have the wrapper included. It shows up as a script mvnw in the top level of your project which you run in place of mvn.”
That’s an important point, failing which otherwise once you get into developing in Spring Tool Suite (STS) using that IDE’s project model, you may be confused as to “but where is Maven?”

Note on Dependency Management and Repositories: As a hacker coding in your parents’ garage, you are free to download, import and run libraries/JARs from their original public repositories. From your cubicle behind a corporate firewall, however, you may be limited as to what libraries you are permitted to download and/or what versions thereof, into an internal corporate repository. Your company may have policies and processes for certifying external libraries for security and compatibility purposes. The versions of individual libraries/JARS  that are Auto-configured by Spring Boot may or may not be available to you, requiring you to override the version property with a specific number that is available; and then that version of that component may be incompatible with other components, the versions of which are available to you. Headache!

Again, take your time and don’t hesitate to take the side trips for enrichment by clicking on external links, like for example the one on Semantic Versioning:

What could possibly go wrong?

Just don’t, don’t, don’t, don’t – don’t panic! The first and second [ERROR] messages are your guides to how to fix the problem, in this case, “reached end of file while parsing”.
I left the closing curly brace off the end of my listing, so I have an invalid, un-compilable class definition. You may have a different Java syntax error to fix.  In my case, a single character, a file save, and…

What could go right?

Pop Quiz: Do you know what an artifactId is?
If your answer to that question is not “Of course!” then review the tutorials above and/or read this mini-refresher:
The essential definition of your project comes in this form:

• GroupId: Group or organization creating/publishing the project, expresses as a reversed domain name
• ArtifactId: This will becom the name of your JAR (or WAR) file, comprising your complete application.

Burn those concepts into your brain; you are going to see them again and again. They apply to your project and to the external dependencies and resources that you include in your project.

Other Maven resources:
Skip these for now if you think you’ve got enough information to do your work; come back to them for enrichment or if you find yourself struggling with Maven-related issues down the road.

2 years ago
I don’t know JSF, but I am expert in Oracle and am working on an updated edition of my 2012 book “Java Web Database Application Development” ( which will use SpringBoot, JPA/Hibernate and Thymeleaf. My open-source project at features a complete sample application built this way.
Let me know if any of this is of any value to you.
2 years ago
I don’t know that I can solve your problem, but the first thing I would do is ensure that all of my data model entity class attributes which represent database table columns are annotated @Column and have standard public getter and setter methods of the correct types on them.
My first impulse would be to minimize coding of SQL on the Java side at all, especially the more complex the joins, filter conditions and order by clauses become. Instead:
• Create a view on your database that encapsulates all of the SQL you need to write, and work out any relational/SQL problems such as the one you describe there, independent of Java, JPA or Hibernate.
• Call the view from Hibernate as simply as you would a single table with no joins, filters or ordering required, other than bind variables for filter condition/WHERE clause values that are not hard-coded into the view, such as a primary key ID.
I wonder if my Java colleagues would agree with or have comments on the following outline of the three paradigms of working with relational databases:
• JPA/Hibernate Repositories, annotated and autowired, with implicit methods that you don’t even have to write.
This is the latest paradigm, simplest to code.
Cons: You have limited control over HOW it does what it does; debugging is opaque and difficult; performance may be compromised; some senior managers may prohibit you from using this.
• JDBCTemplates: More explicit SQL coding
Pros: Better control; easier to debug; may perform better
Cons: More code to write
• Classic JDBC: DataSource, Connection, Statement, PreparedStatement, CallableStatement, ResultSet
Skip this if you think you’re never going to work in such a “retro” paradigm.
Pros: Tried and true;  maximum control and performance
Cons: Maximum tedium coding low-level details.
OK, I think I got it.  I don't send the response back from Service B until after the method has completed all of its work, which can take several seconds to several minutes.
If I immediately answer (and skip the processing), it works consistently.
Need to spin off the actual work to a separate thread.
I have two Java Spring Boot web service apps on the same server calling each other via REST. Service A calls Service B and the latter successfully acts upon the notfication.
THE PROBLEM is that Service A never receives the acknowlegement from Service B, so it thinks it has failed, and in accordance with its looping recovery logic, it tries again…and again…and again.  Service B ends up doing 3 times the work for no added benefit.

The relevant code (stripped down and falsified to protect the guilty) is as follows:

Service A:

Service B REST Controller:

The actual exception caught by Service A after calling RestTemplate.postForObject() is

Please advise.
Thanks Jeanne, I read your books, which were indispensable for passing both the OCA and OCP exams.
I moved my .java files from under \WebContent\WEB-INF\classes to \src\ and now I am seeing the expected errors listed in the Problems view.  I'll work with that and get back to you, although it may be sometime tomorrow.
3 years ago
Learning Eclipse Java EE IDE for Web Developers. Version: Oxygen.1a Release (4.7.1a)
I have imported valid servlets and other classes into a web app project. When I deliberately put some bogus text into a .java class file under WEB-INF\classes\pojo, I am expecting to find the compiler error somewhere, say in the Problems view? But nothing happens. I check in Windows explorer and the old .class file is still there. So I delete it. I remove the bad text and restore the .java file to a valid state. Nothing happens. I try checking Project->Build Automatically and saving the file. Nothing happens. I try UN-checking Build Automatically and creating a working set consisting of that one java file alone, then building that. Nothing happens.
How is compiling web app classes supposed to work? I have searched but haven't found the helpful help file yet.
3 years ago