不知道这是否有帮助,但是:
部署 EAR 时,EAP 会抛出 NumberFormatException on Module "deployment.HibernateMBeanBug.ear.HibernateMBeanBug-persistence.jar:main" from Service Module Loader
,期望“main”部分是一个数字。在 JConsole 访问时,它会在迭代 MBean 时引发 NullPointerException。
它在这条线上:
doIterate(child, childAddress);
在检测 MBean 时。child = null 和 childAddress=
[
("deployment" => "HibernateMBeanBug.ear"),
("subdeployment" => "HibernateMBeanBug-persistence.jar"),
("subsystem" => "jpa"),
("hibernate-persistence-unit" => "HibernateMBeanBug.ear/HibernateMBeanBug-persistence.jar#AnyPU"),
("entity-cache" => "org.hibernate.cache.spi.UpdateTimestampsCache")
]
然后,当它在下一次迭代中询问“child”的孩子时,它会遇到 NPE。
这两个异常都可以用调试器捕获。NPE 的堆栈跟踪是
Daemon System Thread [RMI TCP Connection(24)-192.168.11.2] (Suspended (exception NullPointerException))
RootResourceIterator<T>.doIterate(Resource, PathAddress) line: 49
RootResourceIterator<T>.doIterate(Resource, PathAddress) line: 55
RootResourceIterator<T>.doIterate(Resource, PathAddress) line: 55
RootResourceIterator<T>.doIterate(Resource, PathAddress) line: 55
RootResourceIterator<T>.doIterate(Resource, PathAddress) line: 55
RootResourceIterator<T>.doIterate(Resource, PathAddress) line: 55
RootResourceIterator<T>.iterate() line: 39
ModelControllerMBeanHelper.queryNames(ObjectName, QueryExp) line: 144
ModelControllerMBeanServerPlugin.queryNames(ObjectName, QueryExp) line: 166
PluggableMBeanServerImpl.queryNames(ObjectName, QueryExp) line: 308
RMIConnectionImpl.doOperation(int, Object[]) line: 1506
RMIConnectionImpl.access$300(RMIConnectionImpl, int, Object[]) line: 97
RMIConnectionImpl$PrivilegedOperation.run() line: 1328
RMIConnectionImpl.doPrivilegedOperation(int, Object[], Subject) line: 1420
RMIConnectionImpl.queryNames(ObjectName, MarshalledObject, Subject) line: 590
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 606
UnicastServerRef2(UnicastServerRef).dispatch(Remote, RemoteCall) line: 322
Transport$1.run() line: 177
Transport$1.run() line: 174
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]
TCPTransport(Transport).serviceCall(RemoteCall) line: 173
TCPTransport.handleMessages(Connection, boolean) line: 556
TCPTransport$ConnectionHandler.run0() line: 811
TCPTransport$ConnectionHandler.run() line: 670
ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1145
ThreadPoolExecutor$Worker.run() line: 615
Thread.run() line: 724
org.hibernate.cache.spi.UpdateTimestampsCache 位于jboss-eap-6.1\modules\system\layers\base\org\hibernate\main\hibernate-core-4.2.0.CR1.jar
,因此只需更新即可解决此问题。
至少这个问题是完全可重现的,所以我会向issues.jboss.org打开一个问题。
更新:测试将 jar 更新到 4.2.6.Final,没有解决问题。
更新2:
如果您添加到您的 persistence.xml 二级缓存:
<property name="hibernate.cache.use_second_level_cache" value="true" />
问题消失了。显然,如果您启用了 query_cache,MBean 迭代逻辑也希望找到实体缓存(二级缓存),如果未定义,则会抛出 NPE。对于值“false”,问题仍然存在,因此必须启用它。
以上只是猜测,我可能会走得更远。但是,出于某种原因,添加二级缓存似乎可以解决问题。