Open Reitz86 opened 5 years ago
Can you ask this in the Micronaut tracker at https://github.com/micronaut-projects/micronaut-core/issues?
It looks like a class has not been registered for reflection:
If you look at the source-code, you will finde something like this: https://github.com/eclipse/paho.mqtt.java/blob/6d7aafddb3a70d7c1eab69e1f9619af8f7ece47c/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/logging/LoggerFactory.java
logger = getLogger(loggerClassName, ResourceBundle.getBundle(messageCatalogName), loggerID, null) ;
// }
if (null == logger) {
throw new MissingResourceException("Error locating the logging class", CLASS_NAME, loggerID);
}
getLogger
try {
logClass = Class.forName(loggerClassName);
} catch (NoClassDefFoundError ncdfe) {
return null;
} catch (ClassNotFoundException cnfe) {
return null;
}
Kind of looks like the exception will be caught, null returned and the null check later throws a MissingResourceException.
The Problem is, that you do not see, which CLASS_NAME it is.
Best guess would be:
private static final String CLASS_NAME = MqttAsyncClient.class.getName();
private Logger log = LoggerFactory.getLogger(LoggerFactory.MQTT_CLIENT_MSG_CAT, CLASS_NAME);
For further information on reflection please read: https://github.com/oracle/graal/blob/master/substratevm/REFLECTION.md
or use the agent: https://github.com/oracle/graal/blob/9a580f75cb618ee64eb36d92720b7488cb75dd4d/substratevm/CONFIGURE.md
Thanks, I'll look into it. @thomaswue: since it works using the standard vm, I guess the error is more likely in my code or in combination with the ahead of time compilation. Thanks for helping, though.
Can you share a way to reproduce? In case of no wrong configuration of native image, we should indeed at least produce a fallback image.
FWIW, I experimented with Eclipse Paho + Graal just recently. org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.4
still required few steps to make it work with Graal:
-H:IncludeResourceBundles=org.eclipse.paho.client.mqttv3.internal.nls.logcat,org.eclipse.paho.client.mqttv3.internal.nls.messages
to native-image.properties
-H:ReflectionConfigurationResources=reflection-config.json
with reflection info for org.eclipse.paho.client.mqttv3.logging.JSR47Logger
, org.eclipse.paho.client.mqttv3.internal.MessageCatalog
, org.eclipse.paho.client.mqttv3.internal.ResourceBundleCatalog
, and java.util.ResourceBundle
.MqttClient
with persistence = null
, since the default persistence class couldn't access user home for some reason (null pointer on MqttDefaultFilePersistence
line 259).After these steps at least basic functionality works.
FWIW, I experimented with Eclipse Paho + Graal just recently.
org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.4
still required few steps to make it work with Graal:
- Fixed [native-image] Failed to build the native image when using java.prefs.Preferences #2086 by using client-maven-plugin:0.1.27. This linked with the missing native library, which was missing when calling native-image directly from command line.
- Fixed access to i18n msg strings by adding
-H:IncludeResourceBundles=org.eclipse.paho.client.mqttv3.internal.nls.logcat,org.eclipse.paho.client.mqttv3.internal.nls.messages
tonative-image.properties
- Set up
-H:ReflectionConfigurationResources=reflection-config.json
with reflection info fororg.eclipse.paho.client.mqttv3.logging.JSR47Logger
,org.eclipse.paho.client.mqttv3.internal.MessageCatalog
,org.eclipse.paho.client.mqttv3.internal.ResourceBundleCatalog
, andjava.util.ResourceBundle
.- Instantiated
MqttClient
withpersistence = null
, since the default persistence class couldn't access user home for some reason (null pointer onMqttDefaultFilePersistence
line 259).After these steps at least basic functionality works.
colud you send a complete configuration? I tried to follow this configuration but it didn't work
I'm also running into this issue. No amount of config changes has worked for me. Running the agent failed as well because the configuration it generated was basically empty.
I'm also running into this issue. No amount of config changes has worked for me. Running the agent failed as well because the configuration it generated was basically empty.
It works for me
Hello, just started playing around with micronaut, graalvm and native-image. Just tried to use the eclipse paho mqtt client. Works when using regular java -jar but the native image crashes. Pretty sure its just my ignorance of the inner workings of native-image but maybe you could give me a nudge in the right direction.
Error log of the native-image execution: