What the agent does
Until Java 8 the JDK shipped JAXB in the javax.xml.bind package. Java 9 put it in a module that was off by default, and Java 11 deleted it. A jar compiled on Java 8 that touches the package now fails at run time with java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter, or .../JAXBException when the code does real XML binding. Building the same source on a newer JDK fails earlier with package javax.xml.bind does not exist. The usual answer is to add a JAXB dependency. The agent first asks whether the code needs JAXB at all, because a large share of these imports are for one helper class.
liqpay/sdk-java, the Java client for a payments API, is that case. The whole project has one JAXB import, in src/main/java/com/liqpay/LiqPayUtil.java, and one use: base64_encode(byte[]) returns DatatypeConverter.printBase64Binary(bytes). Java 8 added java.util.Base64, and Base64.getEncoder().encodeToString(bytes) produces the same padded, unwrapped text. The agent replaces the call and the import. No dependency is added to pom.xml, so consumers of the SDK gain nothing new on their classpath, and the result still compiles with the <source>1.8</source> and <target>1.8</target> the compiler plugin is set to.
The repository already holds the proof that the two encoders agree. LiqPayUtilTest asserts that base64_encode(sha1("some string")) equals i0XkvRxqy4i+v2QH0WIF9WfmKj4= and that base64_encode("some string") equals c29tZSBzdHJpbmc=. The agent runs mvn test on JDK 8 before the change to record a baseline, then on JDK 11 and 17 after it. It follows the helper's callers, since this method signs requests: LiqPay.java uses it for the data field and for the signature built from sha1, and LiqPayRequest.java uses it for the proxy authorization value. A wrong character there shows up as rejected payments, so the fixed expected strings in the tests matter.
It reports two things it does not change. base64_encode(String) calls data.getBytes() with no charset, so the bytes depend on the platform default, which can differ between a Java 8 server and a current one for non-ASCII text. And .travis.yml builds on oraclejdk8 only, which is how the missing package went unnoticed. In a codebase that does bind XML, with JAXBContext, Marshaller or @XmlRootElement, the agent takes the other path: jakarta.xml.bind:jakarta.xml.bind-api and org.glassfish.jaxb:jaxb-runtime at 2.3.x, which keep the javax.xml.bind package name so no source changes.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This project fails on Java 11 or later with \"java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter\" (or javax/xml/bind/JAXBException), or fails to compile with \"package javax.xml.bind does not exist\". List every import and use of javax.xml.bind, javax.activation, javax.xml.ws, javax.jws and javax.annotation in main and test sources, grouped by class used. For uses the JDK itself replaces, change the code and add no dependency: DatatypeConverter.printBase64Binary and parseBase64Binary become java.util.Base64, printHexBinary and parseHexBinary become a small local helper or HexFormat if the minimum Java version allows it. Only if real XML binding remains (JAXBContext, Marshaller, Unmarshaller, Xml annotations), add jakarta.xml.bind:jakarta.xml.bind-api and org.glassfish.jaxb:jaxb-runtime at the newest 2.3.x versions, which keep the javax.xml.bind package, and explain why you did not move to 3.x or later. Keep the project's current source and target level. Before changing anything, run the test suite on JDK 8 if you can install it and record the result. After the change run it on JDK 11 and JDK 17. If a replaced call has no test that pins its exact output, add one with fixed expected strings, including input that needs padding. List every caller of each changed method and say what the value is used for. Report, without changing, any String.getBytes() or new String(bytes) with no charset on those paths, and any CI configuration that builds on one JDK only. Open a pull request with the table of uses, the commands and their output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request whose description opens with the table of JAXB uses and the decision for each: replaced with a JDK class, or kept and backed by a dependency. For the SDK above it has one row and the diff is one import and one line in LiqPayUtil.java, with pom.xml untouched. The description lists the three call sites in LiqPay.java, the one in LiqPayRequest.java, and what each encoded value is sent as.
Below that are the mvn test commands and their output for each JDK. A reviewer looks at two things. First, that the tests with fixed Base64 strings ran and passed on every JDK, since they are the evidence that signatures do not change. Second, the report section: the charset note is a real behaviour difference between platforms that this pull request leaves alone, and the reviewer decides whether to open a follow-up. Where the agent did add the two JAXB artifacts, the reviewer checks the scope of jaxb-runtime and that no second JAXB implementation is already on the classpath through another dependency.
Run it on every Grafana alert on NoClassDefFoundError
The error tends to appear in production logs the day a base image moves from Java 8 to a newer runtime, in whichever code path first touches the missing class. If Grafana watches those logs, a contact point of type webhook can call a Rush webhook trigger directly, because it can send a custom Authorization header. Create an automation with the prompt above in the Project that has the repository, add a webhook trigger, store the secret the console shows once, and set the contact point's URL and its Authorization: Bearer value to match. The alert's JSON arrives after the prompt as the event text.
Grafana sends the notification again while the alert keeps firing, and once more when it resolves. Keep the automation's max runs per hour at 1, and add a sentence to the saved prompt telling the agent to answer in one line and change nothing when the event's status is resolved or when an open pull request for this error already exists.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
The question a reviewer has is whether the bytes on the wire stay the same, and the answer needs more than one JDK. The agent installs JDK 8, 11 and 17 side by side in its sandbox, runs Maven against each, and the session's transcript keeps every command and its output. A developer who has only a current JDK locally cannot produce the Java 8 baseline without the same setup work, and tends to skip it.
Maven on a fresh machine downloads plugins and dependencies before it compiles anything, and old plugin versions such as the maven-compiler-plugin 3.2 in this pom.xml sometimes behave differently on new JDKs. Those failures look like the bug being fixed and are not. In the sandbox the agent can tell them apart by running the unchanged project on each JDK first, and the pull request says which failures existed before its change.
Frequently asked questions
Which dependency fixes NoClassDefFoundError: javax/xml/bind/JAXBException?
For code that keeps the javax.xml.bind imports, add jakarta.xml.bind:jakarta.xml.bind-api 2.3.x and an implementation, usually org.glassfish.jaxb:jaxb-runtime 2.3.x. Versions 3 and later use the jakarta.xml.bind package instead, so they fix nothing unless you also rewrite the imports.
I only use DatatypeConverter. Do I need JAXB?
No. java.util.Base64 replaces printBase64Binary and parseBase64Binary on Java 8 and later, and the hex methods are a few lines or java.util.HexFormat from Java 17. Removing the import is better than adding two artifacts to every consumer's classpath for one static call.
Does --add-modules java.xml.bind still work?
Only on Java 9 and 10, where the module existed and was switched off by default. Java 11 removed the module, so the flag makes the JVM fail to start there. The agent removes the flag from scripts and build files when it finds it.
The class is missing inside a library I depend on. What then?
The stack trace names the library's class that references JAXB. The agent identifies the artifact and version, checks whether a newer release declares its own JAXB dependency, and upgrades it if your tests pass. Otherwise it adds the 2.3.x API and runtime to your build so the library finds them, and notes which dependency needed it.
More jobs like this: Fix a bug from an alert
- Fix "Test environment jest-environment-jsdom cannot be found" After Upgrading to Jest 28 or 29 (Jest)
- Fix "ImportError: cannot import name 'escape' from 'jinja2'" in a Flask 1.x App (Jinja2)
- Fix Jira Bug Tickets With Pull Requests in an ASP.NET Core App (ASP.NET Core)
- Fix Jira Bug Tickets With Pull Requests in a Django App (Django)
- Fix Jira Bug Tickets With Pull Requests in a Laravel App (Laravel)
- Fix Jira Bug Tickets With Pull Requests in a Next.js App (Next.js)