Adding module causes classloading issues
Michael Hall
mik3hall at gmail.com
Tue Nov 28 01:03:18 UTC 2017
> On Nov 27, 2017, at 6:40 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
>
> On 11/27/2017 3:16 PM, Michael Hall wrote:
>> JMX attach keeps telling me that RMI is not a accepted protocol.
>> I wondered if possibly this was a modular issue, I checked my main app jar…
>> jdeps halfpipe.jar
>> ...
>> halfpipe.jar -> java.corba
>> …
>>
>> which seems to say I need java.corba which I didn’t have.
>> If I add that with jlink I get…
>>
>> java.lang.NoClassDefFoundError: javax/transaction/UserTransaction
>>
>> from the quartz scheduler. This class should come from the included jta.jar, and usually does without the java.corba module.
>
> java --list-modules
> // Will show java.corba in your jlinked image
>
> java --describe-module java.corba
> // Will show 'requires java.transaction'
> // Since this is an implementation dependency, it's not listed in https://docs.oracle.com/javase/9/docs/api/java.corba-summary.html
>
> java --show-module-resolution -jar halfpipe.jar
> // Will show java.transaction being resolved in support of java.corba
>
Thanks for the above, searches hadn’t hit them yet.
> Because java.transaction is resolved, the miniature javax.transaction package that it exports will "win", and the full-strength javax.transaction package in jta.jar on the classpath will "lose".
>
> The story of java.transaction is unfortunate and complicated (see http://openjdk.java.net/jeps/8189188) but you can augment it with the stuff in jta.jar:
>
> java --patch-module java.transaction=jta.jar -jar halfpipe.jar
> // See http://openjdk.java.net/jeps/261#Patching-module-content <http://openjdk.java.net/jeps/261#Patching-module-content>
The application usually runs as an OS X application. So I don’t use -jar. I do have a shell script launch for testing…
#!/bin/bash
APP_ROOT=HalfPipe7.app
JAVA=${APP_ROOT}/Contents/Java
export R_HOME=/Library/Frameworks/R.framework/Resources
java --patch-module java.transaction=${JAVA}/jta.jar -XX:+CITime -Xms32M -Xmx256M -Xdock:name=HalfPipe -Dcom.apple.mrj.application.apple.menu.about.name=HalfPipe -Dapple.laf.useScreenMenuBar=true -Djava.library.path=$APP_ROOT/Contents/MacOS -Djava.security.manager -Djava.security.policy=$APP_ROOT/Contents/JavaApp/all.policy -Dapp.lib=$APP_ROOT/Contents/JavaApp -Dconsole=pane -cp .:..:hp_jshell.jar:${JAVA}/halfpipe.jar:${JAVA}/log4j-1.2.16.jar:${JAVA}/quartz-2.2.2.jar:${JAVA}/quartz-jobs-2.2.2.jar:${JAVA}/httpcore-4.1.jar:${JAVA}/httpclient-4.1.jar:${JAVA}/commons-logging-1.1.1.jar:${JAVA}/slf4j-api-1.7.7.jar:${JAVA}/slf4j-log4j12-1.7.7.jar:${JAVA}/antlr-2.7.7.jar:${JAVA}/AppleScriptEngine.jar:${JAVA}/Classes:${JAVA}/groovy-all-2.4.5.jar:${JAVA}/JRI.jar:${JAVA}/JRIEngine.jar:${JAVA}/JRS.jar:${JAVA}/REngine.jar:${JAVA}/RserveEngine.jar:${JAVA}/jta.jar:${JAVA}/macnio2.jar:${JAVA}/stringtemplate-3.2.1.jar:${JAVA}/weka.jar:${JAVA}/js.jar us.hall.hp.common.LoaderLaunchStub
Note—patch-module at start if I am doing that correctly, gets…
WARNING: Unknown module: java.transaction specified to --patch-module
This is the installed jvm, not the embedded application one (I could point it at that if useful), but it should have all modules included?
More information about the jigsaw-dev
mailing list