java 启用 jmxremote 的 JBoss 4.2.2 上的 JBossWS 中的 NPE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/129746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:07:50  来源:igfitidea点击:

NPE in JBossWS on JBoss 4.2.2 with jmxremote enabled

javajbossjmxjconsolejbossws

提问by Jeremy

I am trying to set up JBoss 4.2.2 and JConsole for remote monitoring. As per many of the how-to's I have found on the web to do this you need to enable jmxremote by setting the following options in run.conf. (I realize the other two opts disable authentication)

我正在尝试设置 JBoss 4.2.2 和 JConsole 以进行远程监控。根据我在网上找到的许多操作方法,您需要通过在 run.conf 中设置以下选项来启用 jmxremote。(我意识到另外两个选项禁用身份验证)

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=11099"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false" 

Which results in the following exception:

这导致以下异常:

13:06:56,418 INFO [TomcatDeployer] performDeployInternal :: deploy, ctxPath=/services, warUrl=.../tmp/deploy/tmp34585xxxxxxxxx.ear-contents/mDate-Services-exp.war/
13:06:57,706 WARN [AbstractServerConfig] getWebServicePort :: Unable to calculate 'WebServicePort', using default '8080'
13:06:57,711 WARN [AbstractServerConfig] getWebServicePort :: Unable to calculate 'WebServicePort', using default '8080'
13:06:58,070 WARN [AbstractServerConfig] getWebServicePort :: Unable to calculate 'WebServicePort', using default '8080'
13:06:58,071 WARN [AbstractServerConfig] getWebServicePort :: Unable to calculate 'WebServicePort', using default '8080'
13:06:58,138 ERROR [MainDeployer] start :: Could not start deployment: file:/opt/jboss-4.2.2.GA/server/default/tmp/deploy/tmp34585xxxxxxxxx.ear-contents/xxxxx-Services.war
java.lang.NullPointerException
at org.jboss.wsf.stack.jbws.WSDLFilePublisher.getPublishLocation(WSDLFilePublisher.java:303)
at org.jboss.wsf.stack.jbws.WSDLFilePublisher.publishWsdlFiles(WSDLFilePublisher.java:103)
at org.jboss.wsf.stack.jbws.PublishContractDeploymentAspect.create(PublishContractDeploymentAspect.java:52)
at org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl.deploy(DeploymentAspectManagerImpl.java:115)
at org.jboss.wsf.container.jboss42.ArchiveDeployerHook.deploy(ArchiveDeployerHook.java:97) 
...

My application uses JWS which according to this bug:

我的应用程序根据此错误使用 JWS:

https://jira.jboss.org/jira/browse/JBWS-1943

https://jira.jboss.org/jira/browse/JBWS-1943

Suggests this workaround:

建议此解决方法:

JAVA_OPTS="$JAVA_OPTS -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"
JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"

(https://developer.jboss.org/wiki/JBossWS-FAQ#jive_content_id_How_to_use_JDK_JMX_JConsole_with_JBossWS)

( https://developer.jboss.org/wiki/JBossWS-FAQ#jive_content_id_How_to_use_JDK_JMX_JConsole_with_JBossWS)

I've tried that however that then throws the following exception while trying to deploy a sar file in my ear which only contains on class which implements Schedulable for a couple of scheduled jobs my application requires:

我已经尝试过,但是当我尝试在我的耳朵中部署一个 sar 文件时抛出以下异常,该文件仅包含为我的应用程序需要的几个计划作业实现 Schedulable 的类:

Caused by: java.lang.NullPointerException
at EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap.hash(ConcurrentReaderHashMap.java:298)
at EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap.get(ConcurrentReaderHashMap.java:410)
at org.jboss.mx.server.registry.BasicMBeanRegistry.getMBeanMap(BasicMBeanRegistry.java:959)
at org.jboss.mx.server.registry.BasicMBeanRegistry.contains(BasicMBeanRegistry.java:577)

Any suggestions on where to go from here?

关于从这里去哪里的任何建议?

EDIT:

编辑:

I have also tried the following variation:

我还尝试了以下变体:

JAVA_OPTS="$JAVA_OPTS -DmbipropertyFile=../server/default/conf/mbi.properties  -DpropertyFile=../server/default/conf/mdate.properties -Dwicket.configuration=DEVELOPMENT"
JAVA_OPTS="$JAVA_OPTS -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"
JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"

I'm using JDK 1.6.0_01-b06

我正在使用 JDK 1.6.0_01-b06

回答by Chris Vest

I have honestly never tried this remoting approach. But, if both your client machine and the server happen to both be linux boxes or similar *nixes with SSH, then you can ssh -XCAto the server and start JConsole on the serverand have the GUI display on your client machine with X port forwarding. A JConsole running locally to the server JVM you want to monitor shouldnot have any trouble connecting.

老实说,我从未尝试过这种远程处理方法。但是,如果您的客户端机器和服务器碰巧都是 linux 机器或类似的 *nixes 与 SSH,那么您可以ssh -XCA到服务器并在服务器上启动 JConsole 并在您的客户端机器上使用 X 端口转发显示 GUI。在本地运行到您要监控的服务器 JVM 的 JConsole应该不会有任何连接问题。

I personally think that's a nifty trick but I realize that it dosn't reallysolve the problem of getting JConsole to connect remotely through JWS.

我个人认为这是一个绝妙的技巧,但我意识到它并没有真正解决让 JConsole 通过 JWS 远程连接的问题。

回答by Nik

First thing I would do is to delete both /tmp and /work directories under JBoss /default and redeploy the WAR. If that doesn't, I would upgrade the JDK to use a more recent version of 1.6. 1.6.0_01 is pretty old.

我要做的第一件事是删除 JBoss /default 下的 /tmp 和 /work 目录并重新部署 WAR。如果没有,我会升级 JDK 以使用更新的 1.6 版本。1.6.0_01 已经很旧了。

回答by mattkemp

I'm not sure if there's a specific reason you're trying to use WS to access the mbean server, but with JConsole you can directly access a remote JVM. To do this use "service:jmx:rmi:///jndi/rmi://<remote-machine>:<port>/jmxrmi" (where <remote-machine> is whatever machine your trying to connect to and <port> is 11099) as the remote process.

我不确定您尝试使用 WS 访问 mbean 服务器是否有特定原因,但使用 JConsole 您可以直接访问远程 JVM。为此,请使用“service:jmx:rmi:///jndi/rmi://<remote-machine>:<port>/jmxrmi”(其中 <remote-machine> 是您尝试连接的任何机器,<port > 是 11099) 作为远程进程。

I have used this to connect to any 1.6 JVM that exposes an mbean server (JBoss, ActiveMQ, etc).

我已经使用它连接到任何公开 mbean 服务器(JBoss、ActiveMQ 等)的 1.6 JVM。

回答by Alexander Torstling

I don't know if this is related, but JBoss has a tendency to redirect to itself. If you connect to a host, say jboss.localdomain:3873, wanting to connect to a ejb, JBoss might lookup its own hostname and redirect to the address it gets from there. If you have a public hostname, it might find that instead (say jboss.publicdomain.com), and tell the client to reconnect to jboss.publicdomain.com:1099. Depending on your DNS, this might or might not be a reachable address from your client.

我不知道这是否相关,但 JBoss 有重定向到自身的倾向。如果你连接到一个主机,比如 jboss.localdomain:3873,想要连接到一个 ejb,JBoss 可能会查找它自己的主机名并重定向到它从那里得到的地址。如果你有一个公共主机名,它可能会找到它(比如 jboss.publicdomain.com),并告诉客户端重新连接到 jboss.publicdomain.com:1099。根据您的 DNS,这可能是也可能不是您的客户端可访问的地址。

There are various varations of this problem, and as a bonus, sometimes the initial "connection check" works, so the client app deploys, but fails later on connect.

此问题有多种变化,作为奖励,有时初始“连接检查”有效,因此客户端应用程序部署,但稍后连接失败。

回答by anikitin

Had a similar issue, but with JBoss Seam: take a look at JBSEAM-4029. As one of the workarounds it suggests to override the class running into the NPE - in Seam's case the JBossClusterMonitor.

有一个类似的问题,但与 JBoss Seam:看看JBSEAM-4029。作为解决方法之一,它建议覆盖运行到 NPE 的类 - 在 Seam 的情况下,JBossClusterMonitor.

I bet the JWS code is running into exact same issue, i.e. ending up calling MBeanServerFactory.findMBeanServer(null)at some point in time. The stack trace should reveal which exact class does this.

我敢打赌 JWS 代码遇到了完全相同的问题,即最终MBeanServerFactory.findMBeanServer(null)在某个时间点调用。堆栈跟踪应显示执行此操作的确切类。