Showing posts with label Learning. Show all posts
Showing posts with label Learning. Show all posts

Monday, November 24, 2025

Two Things I Ran Across Trying to Learn about Spring Boot

For some of the projects I've been working on I've wanted to set up an easy web interface based in Java. After looking at a bunch of options to learn, I chose Spring Boot which seemed like the most straight forward and possibly useful choice.

I ran into some issues getting started, so I thought I'd write them down in case it helps anyone else. I'm sure that mostly I'm confused and not reading the documentation carefully, but writing is a good way to learn.

For context, I'm working from what looked like a good tutorial on Spring Boot (https://spring.io/guides/gs/spring-boot) and started working through it. The tutorial points you at the helpful Spring Initalizr (https://start.spring.io/) which helpfully (helpfully?) generates everything you need to get started on a Spring Boot project.

Gradlew Version (Which looks like Unsupported class file major version)

The first big thing I ran across was an error from Gradle saying:

BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 69 Unsupported class file major version 69

This was surprising but not super unexpected, for most of the projects I regularly worked in Java in I locked to a version and tended to build most things from scratch (Also updates to the Java version were way less frequent). So I almost never ended up with classes compiled in different versions of Java in the same place. I poked this for a while, but it seemed wrong to get this in a clean install of a Spring Boot application, where I hadn't even edited anything yet.

I don't use Gradle for anything (that's why I'm learning right now) and certainly haven't updated my tech stack for a while, so I figured a good updating of everything would probably help. I fired up Homebrew and let it upgrade everything. This took a few hours — did I mention that I hadn't updated everything in while, but it was fun in the way installing software off of diskettes in the 90s was fun.

This certainly fixed a lot of things and ensured that I had the newest version of Gradle (9.2.0) and Java (25) in the path. Problem solved, I ran

./gradlew bootRun

aaand got the same error.

This was particularly frustrating because a lot of the Stackoverflow and forum posts, tend to — slightly snarkilly — point to the Gradle compatibility matrix (https://docs.gradle.org/current/userguide/compatibility.html) which is slightly frustrating when you are clearly using not only a correct paring of Gradle and Java, but the latest paring of Gradle and Java.

After quite a bit of poking and reading things online, I eventually landed on something being weird with the Gradle Wrapper. I remain a little confused by the Gradle Wrapper, especially when you get the wrapper with a project you're starting on. The idea that it allows you to lock your Gradle version and settings makes sense, but a lot of the details feel fuzzy in the documentation I've read so far and I'm not sure what the difference is between the wrapper and just running Gradle with a specific version. Possibly it's more convenient.

Anyway, it took me a while, but I eventually realized that while I was running Gradle 9.2.0 the Gradle Wrapper in my project from Spring Initalizr was running 8.14.3.

After some more reading I eventually figured out that I had to upgrade the wrapper, with the command:

gradle wrapper --gradle-version 9.2.0

My Googling was sub-par, but I think the document I should have been looking at is this one: https://docs.gradle.org/current/userguide/upgrading_major_version_9.html. Although since I hadn't upgraded my version of Gradle (I just started the project), I felt a bit unsatisfied.

(On further reading (https://docs.gradle.org/current/userguide/command_line_interface.html#sec:environment_options) it seems that what that does create a new wrapper using the specified version, which I guess makes sense.)

Anyway that was the key to getting Spring Boot up and running.

Spring Boot Does Something Weird With Packages

With Spring Boot running, it started Tomcat correctly, but when I poked it using curl all I got was a 404. This was again a little frustrating because I was using the fresh zip file from Spring Initializr and the code from the tutorial.

The application was clearly running, as the code the tutorial includes to show all the beans was working and when I started the app, it gave me a long list of Beans, but when I sent a web request, I got nothing back.

The annotation Spring (Boot?Web?... still learning I guess) uses for establishing endpoints seems to be pretty clear @GetMapping("/") where whatever you put in for a path should be where your Controller gets served, but changing out the path didn't work.

Again my Googleing was a bit weak and I couldn't find anything that directly related to what I was seeing — which is why I thought it would be worth while to write it up here, even if my problems are mostly due to my lack of knowledge.

It seemed to me that the @GetMapping("/") assignment wasn't taking and especially since I'd had some issues with getting things from the Spring Initalizr I wondered if there was something funky in the naming of some of our files or paths.

As I was looking around, I noticed a note in the Spring HELP.md file:

The original package name 'com.example.spring-boot' is invalid and this project uses 'com.example.spring_boot' instead.

Which given my guess about why I was getting the 404 error, gave me a good place to look.

So I went and looked at the two files I'd added from the tutorial src/main/java/com/example/spring_boot/Application.java and src/main/java/com/example/spring_boot/HelloController.java. And as it turns out I did have the package names wrong, just ... not in the way Java would usually find them wrong...

In HelloController I discovered had the package name right, package com.example.spring_boot;, however I had the package name wrong in Application.java, where it was package com.example.springboot;. For the record I think this came from copying files out of the tutorial slightly incorrectly (it uses springboot without a space, which doesn't align with the Spring Initalizr settings they point to, but I didn't catch that).

Now the issue here, at least to my old-timey java mind is that. Application.java was working, the code added in the tutorial ran — it printed the list of beans, and later the message I replaced that list with — but that should have failed based on the package name.

Or I guess that being said, given that spring is very good about finding and plumbing things together, maybe the error shouldn't have happened at all? Or it could possibly have put a warning somewhere I noticed it. Once I got everybody on the same package name (spring_boot) then

Summing Up

As I noticed, I really only wrote this up because some of the things I found online didn't really answer the questions I had. Since I had to do a little learning to solve them, I figured I'd write it up for myself, and maybe it will help someone else at some point.

So,

  • Make sure you have Gradle and Java updated to the right — and compatible — versions.
    • Run gradle wrapper --gradle-version 9.2.0 to fix the gradle wrapper.
  • Make sure that you have the correct — and matching — package in your .java files
    • The tutorial as written and hooked up to Spring Initalizr don't quite align if you're not paying attention.

Friday, March 01, 2024

Project 21 - Code Doodle - Swarm Doodle (Introduction)

It’s been a while since I’ve built anything interesting in the Artificial Intelligence field and with all of the neural network / transformer / LLM nonsense going on right now, I wanted to go back to one of the parts of AI I love, swarm systems.

If you haven’t heard the term before, boids are a generic model for the way organisms swarm together. Think fish in a school or birds in a flock. Each animal has a pretty simple set of things its trying to do but sometimes the overall effect can be breath taking; think of a huge murmuration of starlings at twilight. Boids -- think they fly like a boid -- are a way to model how bunch of simple agents can create a very complex behaviour, and how small tweaks to an agents behaviour can change the way a whole system performs (think starlings compared to geese). They're a very old addition to the world of artificial intelligence, and they've also been extreamly important to the world of film making.

Walter Baxter / A murmuration of starlings at Gretna / 

That being said, it’s been a very long time since since I’ve messed around with swarms (or boids) and I’m quite rusty and -- as I think is a theme here -- my vector math always seems to be just a touch insufficient. So, I’m going to write a short series as I go about putting my swarm system together.

I’m not going to go into all of the details right now, but I’m going to roughly follow Craig Reynolds Boid model. A lot of the details aren’t in the original paper and the content in the Wikipedia article is slightly out of line with my memory, so I’m going to bushwack from what I have to a hopefully working swarm system (rather than do more reading right now).

For this doodle, I’m taking my pre-existing moving agent code -- which I always wrote with an eye to doing a swarm system and expanding on it. To start I have little circles that try to balance being between the mouse and the middle of the screen. To build boids we’re going to have to expand that a little and add in a few more things to do.

I’m trying to stay close to Reynolds model for now, although there’s lots of fun to play with later on. I’m going to set up three “urges” for the boids, a separation urge -- “I’d like to not crash”, a heading (or alignment) urge -- “I want to go where everyone else is going” and a cohesion urge -- “I don’t want to be the only one out where I can get eaten”.

I’ve been working on this for a while -- and then not working on it for a while, so I’m starting to write with the intention of kicking myself into finishing the project. I’m about halfway done putting everything together -- which you'll notice when you look at the code in the repository, and I think I’ll write this up in four or five posts over the next few weeks. Once I get the basics done, I’m looking forward to all the other things I can play with.

Friday, January 20, 2023

Project 22 - Setting up my own about page

In light of certain online spaces failing, I've been thinking about better controlling my presence on the web.  I've had an about.me set up for a long while, but it seems like it's time to make sure that I have a point on the web which I own.


So if you were wondering who I am (and where else you can find me), I now keep a list of all that stuff at tj.kendon.ca.


I've owned my own domain at kendon.ca for a long time, so that makes it an easy start for building my own identity page. It's been pretty good for e-mails, but I haven't really done much else with it. I already had hosting set up, so I just had to put a page together there.


My webdev skills have grown fairly rusty -- and weren't that fancy to begin with. So this project gives me a place to play with some things and learn some new stuff. I've already spent a while playing with Hugo, which lead me to realize that CSS has changed a bit from what I knew before. I have a lot to learn, but I'm excited at the thought of getting to improve my page regularly.


For now, I've set up a pretty basic HTML page with an updated version of my CSS from my grad school page. I've organized into the two spheres I think about my life in, work and making stuff and there are links to my web presence.


I think my next two goals for the project are to set up SSL and smooth out the CSS.  I'm not totally thrilled with the style right now, so I may also rethink what it is I want that page to look like.



Sunday, November 10, 2019

Project 20 - That Code Click - Introduction

I like it when things click. When I’m programming I love that moment where things go together perfectly, and I love that moment in my own brain when a topic suddenly snaps into focus. I also like when I’m working with students and I see that moment for them.


This next project is my attempt to share that feeling and to help people learn about all of the stuff in computing that I think is really cool. It’s a chance to look at how things work, how things fit together, how things were designed and how those elegant moments in problem solving come to be.

I hope this is a chance for me to stretch my writing, teaching and communication skills. Additionally there are a lot of other technical skills I should pick up such as video production and things like that. It’ll also be a nice chance to chase down those topics I’m interested in, but never really have the time to manage while I’m teaching (and then forget about when I’m not teaching).

For the short term I’m going to simply create a few written articles and upload them here while I start building out the idea. In the longer term I’d like to see a blog and then maybe a fully dedicated website to host those articles and other supporting material.

For this first iteration of the project, I’m planning to write one article on “Counting in Binary on Your Fingers” a fun trick I always enjoy using to introduce binary numbers. I’d like to get that finished some time before November 29, including text and my own photos to illustrate. I'll also put together a list of future topics I'm thinking of. If you happen to have a great computing "click" you'd like to suggest, let me know.

Friday, July 25, 2014

Blog: Favourite YouTube Videos (Volume 60)

In this volume of my favourite YouTube videos, we get to enjoy music in boxes and music about boxes and learn together.

Two Things I Ran Across Trying to Learn about Spring Boot

For some of the projects I've been working on I've wanted to set up an easy web interface based in Java. After looking ...