使用hazelcast 3.6:
运行此异常后java.lang.IllegalArgumentException:无法创建ObjectName 在 com.hazelcast.jmx.HazelcastMBean.setObjectName(HazelcastMBean.java:116) 在 com.hazelcast.jmx.ConnectionManagerMBean。(ConnectionManagerMBean.java:39) 在 com.hazelcast.jmx.InstanceMBean.createMBeans(InstanceMBean.java:74) 在com.hazelcast.jmx.InstanceMBean。(InstanceMBean.java:67)at com.hazelcast.jmx.ManagementService。(ManagementService.java:67) 在 com.hazelcast.instance.HazelcastInstanceImpl。(HazelcastInstanceImpl.java:136) 在 com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:160) 在 com.hazelcast.instance.HazelcastInstanceFactory.getOrCreateHazelcastInstance(HazelcastInstanceFactory.java:98) 在 com.hazelcast.cache.impl.HazelcastServerCachingProvider.getOrCreateInstance(HazelcastServerCachingProvider.java:98) 在 com.hazelcast.cache.impl.HazelcastServerCachingProvider.createHazelcastCacheManager(HazelcastServerCachingProvider.java:64) 在 com.hazelcast.cache.impl.HazelcastServerCachingProvider.createHazelcastCacheManager(HazelcastServerCachingProvider.java:42) 在 com.hazelcast.cache.impl.AbstractHazelcastCachingProvider.getCacheManager(AbstractHazelcastCachingProvider.java:94) 在 com.hazelcast.cache.HazelcastCachingProvider.getCacheManager(HazelcastCachingProvider.java:131)
我在File:HazelcastServerCachingProvider.java(从第78行开始)看了这部分导致错误的代码:
String location = properties.getProperty(HazelcastCachingProvider.HAZELCAST_CONFIG_LOCATION);
// If config location is specified, get instance through it.
if (location != null) {
URI uri = new URI(location);
String scheme = uri.getScheme();
if (scheme == null) {
// It is a place holder
uri = new URI(System.getProperty(uri.getRawSchemeSpecificPart()));
}
ClassLoader theClassLoader = classLoader == null ? getDefaultClassLoader() : classLoader;
final URL configURL;
if ("classpath".equals(scheme)) {
configURL = theClassLoader.getResource(uri.getRawSchemeSpecificPart());
} else if ("file".equals(scheme) || "http".equals(scheme) || "https".equals(scheme)) {
configURL = uri.toURL();
} else {
throw new URISyntaxException(location, "Unsupported protocol in configuration location URL");
}
try {
Config config = new XmlConfigBuilder(configURL).build();
config.setClassLoader(theClassLoader);
**HERE BAD INSTANCENAME IS GENERATED**
config.setInstanceName(configURL.toString());
return HazelcastInstanceFactory.getOrCreateHazelcastInstance(config);
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
在传递的hazelcast_config_location中使用文件或http(s)协议时,我们将无法创建mbean,因为hazelCastInstanceName不应包含字符':',这很可能是configURI名称的一部分。
这是一个Bug还是我忽略了什么?
感谢您的回复
答案 0 :(得分:2)
javax ObjectName
类不支持字符:
并抛出MalformedObjectNameException
。 Hazelcast处理此异常并抛出IllegalArgumentException
来自它的消息。
https://docs.oracle.com/javase/7/docs/api/javax/management/ObjectName.html
编辑:quote
函数应该在你的情况下处理它,但是,hz中有一个错误显然。请参阅:https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/java/com/hazelcast/internal/jmx/ConnectionManagerMBean.java#L38