JDK-8153833 : NoClassDefFoundError leads to message "A JNI error has occurred"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.rmi
  • Affected Version: 9
  • Priority: P5
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2016-04-08
  • Updated: 2016-10-04
  • Resolved: 2016-09-27
Related Reports
Relates :  
Description
Please refer to the new test below. This failure looks to be OS independent. Reproduced on both Windows X64 and Linux X64, with different promotion and latest nightly builds.

New test - http://cr.openjdk.java.net/~xiaofeya/8078812/webrev.01/

When running test method testUnnamedApp(), it failed with following error:
test ModuleTest.testAllInModule(): success
Command line: [/java/re/jdk/9/nightly-dev/latest/binaries/linux-x64/bin/java -mp mods -Djava.rmi.server.codebase=file:/net/SCANAS415.us/export/corelibs/users/felix/9-dev/jdk/JTwork/scratch/./mods/mserver/ -cp classes testpkg.DummyApp 37860 ]

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: serverpkg/Hello
	at java.lang.Class.getDeclaredMethods0(java.base@9-ea/Native Method)
	at java.lang.Class.privateGetDeclaredMethods(java.base@9-ea/Class.java:2937)
	at java.lang.Class.privateGetMethodRecursive(java.base@9-ea/Class.java:3282)
	at java.lang.Class.getMethod0(java.base@9-ea/Class.java:3252)
	at java.lang.Class.getMethod(java.base@9-ea/Class.java:1961)
	at sun.launcher.LauncherHelper.validateMainClass(java.base@9-ea/LauncherHelper.java:648)
	at sun.launcher.LauncherHelper.checkAndLoadMain(java.base@9-ea/LauncherHelper.java:499)
Caused by: java.lang.ClassNotFoundException: serverpkg.Hello
	at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@9-ea/BuiltinClassLoader.java:366)
	at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@9-ea/ClassLoaders.java:184)
	at java.lang.ClassLoader.loadClass(java.base@9-ea/ClassLoader.java:419)
	... 7 more

test ModuleTest.testUnnamedApp(): failure
java.lang.AssertionError: expected [0] but found [1]
	at org.testng.Assert.fail(Assert.java:94)
	at org.testng.Assert.failNotEquals(Assert.java:494)
	at org.testng.Assert.assertEquals(Assert.java:123)
	at org.testng.Assert.assertEquals(Assert.java:370)
	at org.testng.Assert.assertEquals(Assert.java:380)
	at ModuleTest.testUnnamedApp(ModuleTest.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:531)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:220)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:184)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:531)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:110)
	at java.lang.Thread.run(java.base@9-ea/Thread.java:804)
config ModuleTest.shutdownRMIRegistry(): success

Comments
The "JNI Error" message still occurs. However, this has nothing to do with RMI; it has to do with how the launcher handles errors during initialization of the start-class. I've filed JDK-8167063 to cover this.
04-10-2016

Close it as this is an invalid usage
27-09-2016

Let me debug with the latest build
03-06-2016

The NoClassDefFoundError occurred because the way the class was compiled depended upon a class that wasn't visible (i.e., it wasn't on the classpath or in a module on the module path). See http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-April/007527.html The remaining issue is why this error says: Error: A JNI error has occurred, please check your installation and try again This seems like a strange error to result from NoClassDefFoundError. Felix, can you investigate this? Otherwise, this doesn't seem to have anything to do with modularity and RMI, so this should probably be moved to another component/subcomponent.
02-06-2016

Any comment on this issue?
13-04-2016