Java

Java SDK changes in 3.0

Every change an application built on the 2.x Java SDK meets in 3.0 — dependencies, scoped tokens, the rewritten Task, timeouts, exceptions, uploads, the shared types and the generated OpenAPI client — with what to do for each.

The SDK is nl.bimbase.bimworks:client, as before. It is Java 17 bytecode, like the modules it brings with it, and runs on Java 17 and later (Java). This page lists everything an application built on the 2.x Java SDK sees change in 3.0, and what to do about it. What the instance itself answers differently, for every client, is on From 2 to 3; the new features are on BIM.works 3.0.

Every change has a class:

  • Breaking: 2.x code no longer compiles, fails, or gives a wrong result. Source breaks show when you compile, binary ones when you swap the jar without recompiling.
  • Behaviour: the same code runs, but the result differs.
  • Deprecated: still works; use the replacement.
  • Requirement: what the application has to bring or set up.

Overview#

Change Class What to do
TokensApi.createVersionsToken, createNodesToken and createRecursiveNodeToken have EnumSet<Scope> overloads; a null task list no longer compiles; the task-list form is deprecated Breaking (source), Deprecated pass scopes (below)
Task<T> was rewritten: get() lives in Task and completes the CompletableFuture, so join() and callbacks work; runChecks, runCheck and runIdsCheck throw ExecutionException where they returned null Breaking (binary), Behaviour recompile; handle the exception (below)
executeAsyncTask, the executeFor… methods and the token calls wait for the request timeout (10 minutes) instead of 30 seconds Behaviour set a timeout where 30 seconds mattered (below)
Exception messages carry the server's message, the cause, and [ref …] Behaviour do not match on the message text (below)
BimApi.validate(String) returns false for a query error (it threw); uploading to an existing name throws NodeAlreadyExistsException, which is not a BimWorksException Behaviour adapt the callers
Geometry2dType.SLICE_AT_Z_0 and SLICE_AT_Z_300 are SLICE with a height Breaking use SLICE
Operator.evaluate(Number, Number) is gone; a recompiled call with boxed numbers binds to evaluate(double, double), which compares the other way round Breaking (silent) review every call
TimeUnit is an enum; ConversionBasedUnit, TokenAuth, HomeDirTokenAuth and NodeClient.login(String, String) are gone Breaking (rare) —
Discipline has six values more before UNKNOWN; InputFileType has DWG Behaviour (for ordinals) do not store ordinals
BimQuery (JSON queries) is deprecated Deprecated send BQL text
The jar no longer brings jaxb-runtime 2.3.2, javax.activation and bctls; Jackson, commons-io, commons-compress and HttpClient 5 moved up Requirement add what you used through them (below)
The generated OpenAPI client (client2) returns AuthResult for logins and tokens, Double and Integer for numbers, and lost LlmApi, health and compare; its models stay strict Breaking regenerate (below)

Dependencies#

nl.bimbase.bimworks:client and the modules it brings (nl.sascom.backplane:client, nl.sascom.backplane:common, nl.bimbase.bimworks:common) are compiled for Java 17, as in 2.x. The SDK's own build needs a newer JDK; that requirement does not reach your build.

The jars it brings with it changed (Requirement):

Library 2.x 3.0
org.glassfish.jaxb:jaxb-runtime 2.3.2, with txw2, istack-commons-runtime, FastInfoset, stax-ex and javax.activation 1.1.1 included gone
org.bouncycastle:bctls-jdk18on 1.86 gone (bcprov, bcpkix and bcutil 1.86 stay)
Jackson (core, databind, the data formats, jsr310, jakarta-xmlbind) 2.22.0 2.22.3
jackson-databind-nullable 0.2.7 0.2.10
commons-io / commons-compress / commons-lang3 2.17.0 / 1.26.1 / 3.18.0 2.20.0 / 1.28.0 / 3.20.0
httpclient5 / httpcore5 5.3.1 / 5.2.4 5.6.3 / 5.4.3
lz4-java 1.10.1 1.11.4

Unchanged: Guava, slf4j-api, Eclipse Collections, Javassist, RoaringBitmap, snakeyaml, woodstox and jakarta.xml.bind-api. If your application used a JAXB 2.3 runtime (com.sun.xml.bind, org.glassfish.jaxb.runtime, javax.activation) or BouncyCastle TLS (org.bouncycastle.jsse) without declaring it, declare it now. An application whose own Jackson is older than 2.22.3 wins Maven's nearest-first choice, and the SDK's types need the newer one. Run your dependency convergence check again.

Tokens#

Scope overloads (Breaking for source, Deprecated). createVersionsToken, createNodesToken and createRecursiveNodeToken each have an overload with EnumSet<Scope> scopes in the place of the task list, and the task-list forms are deprecated. nl.bimbase.bimworks.client.Scope lists the scopes (FS_READ for fs:read up to ALL for *; toWire() gives the text). A call that passes null for the task list is now ambiguous and does not compile; Collections.emptySet(), Set.of(...) and new HashSet<>() still pick the deprecated form. Pass EnumSet.of(Scope.FS_READ, Scope.GEOMETRY_READ, Scope.QUERY_RUN); null scopes keep the scopes of the credential that issues the token. To keep the old form without a task list, cast: (Set<String>) null (changelog/v3-0/from-2-to-3#scoped-token).

The instance still accepts a task list, answers it with a deprecation member, and gives the token the issuer's scopes too (changelog/v3-0/from-2-to-3#tokens).

All six token methods wait for the request timeout instead of 30 seconds, and an answer without an auth object throws a BimWorksException where 2.x returned null.

Tasks#

Task<T> was rewritten (Breaking for binaries, Behaviour). In 2.x Task<T> extended CompletableFuture<T> but never completed it, and each of its twelve subclasses had its own get(). So join() blocked for ever, and thenApply, whenComplete and isDone() never fired. In 3.0:

  • get(), get(long, TimeUnit) and join() live in Task, and a subclass only converts the response (convert);
  • the future completes when the answer arrives, and exceptionally with an ExecuteException on a server error; join() and the callbacks work;
  • get() waits at most the request timeout, then fails with a TaskTimeoutException cause; get(long, TimeUnit) honours its argument for every task;
  • get() before executeAsync() throws an ExecutionException ("executeAsync must be called first"); a failure to send completes the future at once;
  • cancel() does not stop the task on the server.

What breaks:

  1. A class compiled against 2.x calls the subclass's own get(), for example RunChecksTask.get(), which no longer exists: NoSuchMethodError. Recompile; the source still compiles.
  2. runChecks(...).get(), runCheck(...).get() and runIdsCheck(...).get() returned null on a server error and printed the stack trace. They throw ExecutionException now; catch it.
  3. A subclass of Task<T> of your own that does not override convert gets the response's object output, a ClassCastException where T is something else.

Timeouts#

Longer waits (Behaviour).

Call 2.x 3.0
BimWorksClient.executeAsyncTask(Request), and through it most fs, gis and ifc calls and modelChecks.getValidationReport 30 s the request's timeout, 10 minutes by default
executeForObject, executeForArray, executeForResponse 30 s the request's timeout
The token calls 30 s the request's timeout
Task.get() of the check tasks the request's timeout (1 hour) the same; get(long, TimeUnit) now honours its argument

Unchanged: uploads (4 hours), BimApi.query (1 minute), login (10 seconds), connecting (5 seconds) and the WebSocket connection (10 seconds). A call that should fail fast sets request.setTimeOut(...) itself. When the thread is interrupted, the SDK sets its interrupt flag again before it throws BimWorksException(INTERRUPTED).

Exceptions#

Messages, causes and a reference (Behaviour).

  • BimWorksException.getMessage() carries the server's user-facing message instead of the bare code name: BimWorksErrorCode:CHECKIN_ERROR(…): <the reason> where 2.x ended in CHECKIN_ERROR. Do not match on the text; compare getErrorCode().
  • Exceptions carry their cause. getReference() returns the server's reference of the failed request, and toString() ends with [ref …]: quote it to support (reference/java#errors).
  • getApplicationVersion() keeps the real error code; it used to turn every error into UNKNOWN_ERROR.
  • Errors that 2.x printed and then ignored now reach you: an IOException during login (2.x returned without a login), in RenderApi (2.x returned a shorter list), in GisApi (2.x returned null when interrupted), in BcfApi, and a missing file in UploadBuilder (2.x went on).
  • An /api answer with an HTTP error status and an error body fails the call at once; 2.x waited for the whole timeout.

Other changes in the client#

BimApi.validate(String) returns false (Behaviour) for a query error, such as SYNTAX_ERROR, where 2.x threw. For the messages, use validateQuery(String): it returns the warnings of a query that parses and throws for one that does not.

NodeAlreadyExistsException (Behaviour). Uploading to a name that exists throws the declared, checked NodeAlreadyExistsException, which extends Exception, not BimWorksException. 2.x meant to do this but threw BimWorksException(FILE_ALREADY_EXISTS). Catch NodeAlreadyExistsException.

BimQuery is deprecated (Deprecated). No SDK method has taken a BimQuery since 2.x. Its disciplines now work (2.x always threw on them), and reading an invalid BimQuery from JSON throws JsonMappingException instead of returning null. Send BQL text: client.bim.query(String, Set<UUID>).

Removed developer classes (Breaking, unlikely). SocketHandler, SpeedTestClient, SpeedTestServer and TestQuerySerialization are no longer in the jar.

BimWorksClientFactory (Behaviour). When the login fails, createAnonymousClient and the createClientWith… methods close the half-built client and throw; 2.x left it open. new BimWorksClientFactory(address, null) throws a NullPointerException at once. setApplication(name, version) and excludePlatformInfo() are new.

Fixes behind the same methods (Behaviour):

Uploads (Behaviour):

  1. The HTTP transports send Authorization: Bearer <base64 auth> with every upload, which the 3.0 instance requires (changelog/v3-0/from-2-to-3#calls), and the connection's endpoint, so that a fleet can route it.
  2. UploadBuilder.setContentType(...) takes effect; 2.x always sent application/ifc. The input file type is no longer sent: the instance takes it from the file name.
  3. An InputStream without a size is sent as size unknown; 2.x told the instance the file was empty.
  4. On NO_STREAM the SDK retries once, itself, for a source it can read again (Path, ByteSource, a URL); an InputStream fails with NO_STREAM. 2.x set forceReprocessing(true) on your builder and could upload an empty retry.
  5. url(URL) streams the file through instead of downloading it to a temporary file first; the size comes from the builder, else Content-Length.
  6. A hash check that a single-task upload token may not run counts as "unknown", and the bytes are sent; 2.x threw.
  7. On a fleet, an upload whose task is lost with its node is followed to the end of its check-in.

Connection (Behaviour):

  • Every request carries an X-BIMworks-Client header, and every socket starts with a hello; the User-Agent is bimworks-java/<version> (jdk/…; <os>) instead of Jetty's. The operating system, architecture and JDK are sent unless you call excludePlatformInfo(). A proxy or firewall that filters on the User-Agent sees a new value.
  • ConnectionType.WEB_SOCKET uses the port in the address; 2.x always used 80 or 443.
  • After a dropped connection the SDK reconnects in the background, with backoff from 250 ms to 5 s, until it is back or closed; 2.x tried once. Calls that were waiting pick up their answer, or fail with TASK_LOST_NODE_CHANGED when the instance restarted or another node took over. addNodeChangedListener and addConnectionRestoredListener are new.
  • Downloads accept zstd next to Brotli.
  • SharedClientResources (opt-in) lets several clients share one executor, scheduler and buffer pool; a client uses fewer threads.

Types from the shared modules#

Types from nl.bimbase.bimworks:common and the Backplane modules appear in the SDK's methods and results.

Backplane login (Breaking, rare). NodeClient.login(String username, String password), TokenAuth and HomeDirTokenAuth are gone; they logged in to the Backplane server, not to BIM.works. Use BimWorksClientFactory.createClientWith….

Geometry2dType (Breaking). SLICE_AT_Z_0 and SLICE_AT_Z_300 are replaced by SLICE, with the height in CityGml2ExportSettings and CityGml3ExportSettings (setLod0SliceHeightMm, setLod1SliceHeightMm; 300 mm by default).

Operator.evaluate (Breaking, silent). Only evaluate(double, double) is left, in natural order and exact. The 2.x evaluate(Number, Number) compared the other way round (GREATER_THAN meant v1 < v2), with a tolerance of 1e-6 and reference equality for EQUALS. Code compiled against 2.x gets a NoSuchMethodError; code recompiled with boxed numbers binds to the double form, and every ordering comparison flips. Review every call.

Units (Breaking, rare). TimeUnit is an enum (SECOND, MINUTE, HOUR, DAY, WEEK, YEAR); in 2.x it was a class whose methods returned nothing, and new TimeUnit() no longer compiles. ConversionBasedUnit and ConversionBasedLengthUnit are gone. AreaUnit.SQUARED_YARD has the id 9 instead of 5, which it shared with SQUARE_MILE. AreaUnit and VolumeUnit have getSiSymbol(); TemperatureUnit has KELVIN and FAHRENHEIT; CustomUnit has more values, added at the end.

Discipline (Behaviour, for ordinals). SPATIAL, GEOTECHNICAL, BRIDGE, ROAD, RAILWAY, PORTS_AND_WATERWAYS, TIMBER_STRUCTURE, VERTICAL_TRANSPORT, TUNNEL and SURVEY come before UNKNOWN, which moves from ordinal 19 to 29. Disciplines are stored and sent by name, so only code that stores ordinals is affected. getParent(), children(), topLevel() and withDescendants() are new.

InputFileType has DWG, added at the end, and a storage policy.

Error codes are added at the end of their enumerations; none was removed or renumbered: DefaultErrorCode 58–65 (VERSION_CONFLICT to GPU_UNAVAILABLE), 35 BimWorksErrorCode values (RESULT_TOO_LARGE, UPLOAD_URL_REFUSED, INVALID_CHECK_DEFINITION and the linked-data codes among them), BimWorksQueryError 10–16 (QUERY_TOO_EXPENSIVE among them), AuthenticationError 23–27 (API_TOKEN_EXPIRED), AuthorizationError 9–12 (NON_AUTHORIZED_SCOPE, SESSION_SIGNED_OUT) and StepParserErrorCode 33–40.

Results (additive). EvaluationResult leaves out empty fields and has actualValue, expected, measured, featureText, requirementText, figures and more subtypes; check results have interaction, overlays and pick; Annotation has anchor, alignment, occlusion, clustering and grouping, next to TemplateAnnotation and RawAnnotation; Qid reads both "vid-oid" and {vid, oid}.

For implementers only (Breaking, very rare). EndPointId.getSpecifiedId() is final: implement computeSpecifiedId(). Timing.dump(ConsoleTable) is concrete, and the abstract method is dump(ConsoleTable, TimingDetail). Interfaces such as NodeTransport and ClientTask gained default methods only. The server-configuration types Zookeeper, ZookeeperAddress and ClusterStorageBackendConfiguration are gone.

The generated OpenAPI client#

nl.bimbase.bimworks:client2 is generated from the instance's OpenAPI document (reference/java#client2). Regenerate it against your instance, or update code that used the 2.x one:

  • Removed (Breaking): LlmApi, InfoApi.health, IfcApi.compare (use compareModels, compareObjects and getCompareResult), and the models that went with them.
  • Changed (Breaking): the logins and the three token calls return AuthResult; ModelApi.download takes a DownloadRequest; uploadModel has more parameters; VersionsApi.version returns a Version and is deprecated. GeoReference coordinates are Double (were Float); Node.level, lastVersionNumber, processing and Version.version are Integer (were BigDecimal); Version.imMetadata is an ImMetadata. CityGML3ExportGeometry.SLICE_0_2D and SLICE_300_2D are SLICE_2D with slice_height_mm. Discipline and InputFileType have the new values.
  • Deprecated: tasks on the token requests; use scopes. responseFormat(AuthResponseFormat.BASE64) gives the bare string a 2.x login answered.
  • Strict models: a generated model refuses a field or an enum value it does not know, so a client2 older than the instance fails on what the instance added.
  • Answers: errors come with their own HTTP status (400, 401, 403, 404, 409, 413, 429, 500, 503, 504) instead of 500, so ApiException.getCode() changes; the login answers are an Auth object unless you ask for BASE64.

New, nothing to change#

Nothing below changes unless you use it; Classic Java SDK describes each.