OSM uses the Saxon xquery processor which does provide an extensibility mechanism allowing Java to be invoked. You will need to ensure the classes you are depending upon are accessible on the classpath. The way to do this with OSM is to put the classes in a jar file and out the jar in your cartridge's resource folder.