java - 如何使用 Wildfly 10 连接到远程连接器?

标签 java wildfly jmx remoting visualvm

有人知道如何进一步解决我的问题吗?

我正在努力远程连接到我的 Wildfly 服务器的 jmx。

环境

WildFly 10.0.0 Final

JDK 1.8.0_66

Domain Mode

dedicated remoting socket

dedicated remoting connector

我引入了一个专用的远程连接器,因为我只想通过此端口授予对 jmx 的访问权限,并将我的管理保留在另一个端口上。我定义了安全领域以及其中的一些用户。

工作方式

我尝试了语法“service:jmx:://:”中的几个连接字符串。但没有协议(protocol)有效:

  • 远程
  • http-remoting-jmx
  • 远程处理-jmx
  • 远程+http
  • 远程处理
  • 远程处理-jmx

错误

这出现在我的 WF 服务器的 server.log 中

DEBUG [org.jboss.remoting.remote.connection] (default I/O-5) JBREM000200: Remote connection failed: java.io.IOException: XNIO000804: Received an invalid message length of 1195725856

配置文件配置片段

<subsystem xmlns="urn:jboss:domain:remoting:3.0">
    <endpoint/>
    <connector name="remoting" socket-binding="remoting" security-realm="ApplicationRealm"/>
    <http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>

我想在 Windows 客户端上使用 VisualVM 进行连接,因此我使用了 Wildfly jconsole.bat 并调整了可执行文件以使用 VisualVM。

VisualVM 的环境脚本

@echo off
rem -------------------------------------------------------------------------
rem jconsole script for Windows
rem -------------------------------------------------------------------------
rem
rem A script for running jconsole with the remoting-jmx libraries on the classpath. 

rem $Id$
set JBOSS_HOME="C:\local\wildfly_10.0"
set JAVA_HOME="C:\Programme\Java\jdk1.8.0_66"


@if not "%ECHO%" == ""  echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal

if "x%JAVA_HOME%" =="x" (
    echo JAVA_HOME environment variable has not been set - please set and re-run!
    goto :EOF
)

if "%OS%" == "Windows_NT" (
set "DIRNAME=%~dp0%"
) else (
set DIRNAME=.\
)

pushd %DIRNAME%..
set "RESOLVED_JBOSS_HOME=%CD%"
popd

if "x%JBOSS_HOME%" == "x" (
set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%" 
)

pushd "%JBOSS_HOME%"
set "SANITIZED_JBOSS_HOME=%CD%"
popd

if "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" (
    echo WARNING JBOSS_HOME may be pointing to a different installation - unpredictable results may occur.
)

set DIRNAME=

if "%OS%" == "Windows_NT" (
set "PROGNAME=%~nx0%"
) else (
set "PROGNAME=jdr.bat"
)

rem Setup JBoss specific properties
if "%JAVA_HOME%" == "x" (  
echo JAVA_HOME is not set. Unable to locate the jars needed to run jconsole.
goto END
)

rem Find jboss-modules.jar, or we can't continue
if exist "%JBOSS_HOME%\jboss-modules.jar" (
    set "RUNJAR=%JBOSS_HOME%\jboss-modules.jar"
) else (
echo Could not locate "%JBOSS_HOME%\jboss-modules.jar".
echo Please check that you are in the bin directory when running this script.
goto END
)

rem Set default module root paths
if "x%JBOSS_MODULEPATH%" == "x" (
set  "JBOSS_MODULEPATH=%JBOSS_HOME%\modules"
)

rem Setup The Classpath
set CLASSPATH=


call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\remoting\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\remoting-jmx\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\remoting3\remoting-jmx\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\remoting3\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\logging\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\xnio\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\xnio\nio\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\sasl\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\marshalling\main
call :SearchForJars %JBOSS_MODULEPATH%\system\layers\base\org\jboss\marshalling\river\main


"%JAVA_HOME%\bin\jvisualvm.exe" "-cp:a" "%CLASSPATH%" 

:END
goto :EOF

:SearchForJars
pushd %1
for %%j in (*.jar) do call :ClasspathAdd %1\%%j
popd
goto :EOF

:ClasspathAdd
SET CLASSPATH=%CLASSPATH%;%1


:EOF

最佳答案

对于 Wildfly 10.1:

从 wildfly/bin 目录运行 jconsole.sh。

连接服务:jmx:remote+ http://server:port

以及您添加的管理用户。

可以在日志输出中看到端口

10:20:36,785 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://server:10090/management

关于java - 如何使用 Wildfly 10 连接到远程连接器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37409352/

相关文章:

java - Android 删除 View 崩溃

apache-spark - 如何将 JMXConsole 远程连接到 Spark 流应用程序

java - JMX工具来源

java - 通过java列出weblogic中的所有用户

java - 在创建 bean 时调试

java - 如何将 JTextArea 中的单行存储到 String

JAVA:根据变量的值调用类方法

java - EntityManager 不持久化实体类?

java - Wildfly 20无法在Ubuntu 20上运行 “out-of-the-box”

wildfly - 如何使用 Wildfly 8.1 避免电子邮件错误(550 5.7.1 命令被拒绝)