プログラマとプロマネのあいだ

プログラマもやるし、プロマネもやるし、たまに似非アーキとか営業っぽいこともやる

HornetQでクラスタプロパティを有効にしたとき、NumberFormatExceptionが出る場合の対処法

HornetQ 2.4.0Final

run.batのCONFIG_DIRの"non-clustered"を"clustered"に変更して、CLUSTER_PROPSの行をコメントインする。

クラスタプロパティを有効にしたrun.bat

@ echo off
setlocal ENABLEDELAYEDEXPANSION
set HORNETQ_HOME=..
IF "a%1"== "a" ( 
set CONFIG_DIR=%HORNETQ_HOME%\config\stand-alone\clustered
) ELSE (
SET CONFIG_DIR=%1
)
set CLASSPATH=%CONFIG_DIR%;%HORNETQ_HOME%\schemas\
REM you can use the following line if you want to run with different ports
set CLUSTER_PROPS="-Djnp.port=1099 -Djnp.rmiPort=1098 -Djnp.host=localhost -Dhornetq.remoting.netty.host=localhost -Dhornetq.remoting.netty.port=5445"
set JVM_ARGS=%CLUSTER_PROPS% -XX:+UseParallelGC  -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M -Dhornetq.config.dir=%CONFIG_DIR% -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.util.logging.config.file=%CONFIG_DIR%\logging.properties -Djava.library.path=.
REM export JVM_ARGS="-Xmx512M -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.util.logging.config.file=%CONFIG_DIR%\logging.properties -Dhornetq.config.dir=$CONFIG_DIR -Djava.library.path=. -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
for /R ..\lib %%A in (*.jar) do (
SET CLASSPATH=!CLASSPATH!;%%A
)
mkdir ..\logs
echo ***********************************************************************************
echo "java %JVM_ARGS% -classpath %CLASSPATH% org.hornetq.integration.bootstrap.HornetQBootstrapServer hornetq-beans.xml"
echo ***********************************************************************************
java %JVM_ARGS% -classpath "%CLASSPATH%" org.hornetq.integration.bootstrap.HornetQBootstrapServer hornetq-beans.xml

そうすると、下記のような結果になる。

run.batを実行した結果

サブディレクトリまたはファイル ..\logs は既に存在します。
***********************************************************************************
"java "-Djnp.port=1099 -Djnp.rmiPort=1098 -Djnp.host=localhost -Dhornetq.remoting.netty.host=localhost -Dhornetq.remoting.netty.port=5445" -XX:+UseParallelGC  -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M -Dhornetq.config.dir=..\config\stand-alone\clustered -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.util.logging.config.file=..\config\stand-alone\clustered\logging.properties -Djava.library.path=. -classpath ..\config\stand-alone\clustered;..\schemas\;C:\app\hornetq-2.4.0.Finala\lib\hornetq-aerogear-integration.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-amqp-protocol.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-bootstrap.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-commons.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-core-client.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-jboss-as-integration.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-jms-client.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-jms-server.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-journal.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-native.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-ra.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-rest.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-server.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-service-sar.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-spring-integration.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-stomp-protocol.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-tools.jar;C:\app\hornetq-2.4.0.Finala\lib\hornetq-twitter-integration.jar;C:\app\hornetq-2.4.0.Finala\lib\jboss-jms-api.jar;C:\app\hornetq-2.4.0.Finala\lib\jboss-mc.jar;C:\app\hornetq-2.4.0.Finala\lib\jnp-client.jar;C:\app\hornetq-2.4.0.Finala\lib\jnpserver.jar;C:\app\hornetq-2.4.0.Finala\lib\netty.jar;C:\app\hornetq-2.4.0.Finala\lib\proton-api.jar;C:\app\hornetq-2.4.0.Finala\lib\proton-j-impl.jar;C:\app\hornetq-2.4.0.Finala\lib\proton-jms.jar org.hornetq.integration.bootstrap.HornetQBootstrapServer hornetq-beans.xml"
***********************************************************************************
22:17:47,318 INFO  [org.hornetq.integration.bootstrap] HQ101000: Starting HornetQ Server
22:17:48,098 WARN  [org.hornetq.core.server] HQ222018: AIO was not located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal
22:17:48,146 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Configured: name=StandaloneServer state=Instantiated: java.lang.RuntimeException: Error configuring property: port for StandaloneServer
        at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:112) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.ConfigureAction.setAttributes(ConfigureAction.java:85) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.ConfigureAction.installActionInternal(ConfigureAction.java:44) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:774) [jboss-mc.jar:]
        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBean(AbstractKernelDeployer.java:319) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deployBeans(AbstractKernelDeployer.java:297) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.deploy(AbstractKernelDeployer.java:130) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer.deploy(BeanXMLDeployer.java:96) [jboss-mc.jar:]
        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:236) [hornetq-bootstrap.jar:]
        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.deploy(HornetQBootstrapServer.java:206) [hornetq-bootstrap.jar:]
        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.bootstrap(HornetQBootstrapServer.java:154) [hornetq-bootstrap.jar:]
        at org.jboss.kernel.plugins.bootstrap.AbstractBootstrap.run(AbstractBootstrap.java:83) [jboss-mc.jar:]
        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.run(HornetQBootstrapServer.java:115) [hornetq-bootstrap.jar:]
        at org.hornetq.integration.bootstrap.HornetQBootstrapServer.main(HornetQBootstrapServer.java:69) [hornetq-bootstrap.jar:]
Caused by: java.lang.NumberFormatException: For input string: "1099 -Djnp.rmiPort=1098 -Djnp.host=localhost -Dhornetq.remoting.netty.host=localhost -Dhornetq.remoting.netty.port=5445"
        at java.lang.NumberFormatException.forInputString(Unknown Source) [rt.jar:1.8.0_131]
        at java.lang.Integer.parseInt(Unknown Source) [rt.jar:1.8.0_131]
        at java.lang.Integer.valueOf(Unknown Source) [rt.jar:1.8.0_131]
        at java.lang.Integer.decode(Unknown Source) [rt.jar:1.8.0_131]
        at com.sun.beans.editors.IntegerEditor.setAsText(Unknown Source) [rt.jar:1.8.0_131]
        at org.jboss.reflect.plugins.ValueConvertor.convertValue(ValueConvertor.java:139) [jboss-mc.jar:]
        at org.jboss.reflect.spi.PrimitiveInfo.convertValue(PrimitiveInfo.java:248) [jboss-mc.jar:]
        at org.jboss.beans.metadata.plugins.StringValueMetaData.getValue(StringValueMetaData.java:131) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.PropertyDispatchWrapper.execute(PropertyDispatchWrapper.java:111) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109) [jboss-mc.jar:]
        at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:107) [jboss-mc.jar:]
        ... 24 more

22:17:48,207 INFO  [org.hornetq.core.server] HQ221000: live server is starting with configuration HornetQ Configuration (clustered=true,backup=false,sharedStore=true,journalDirectory=../data/journal,bindingsDirectory=../data/bindings,largeMessagesDirectory=../data/large-messages,pagingDirectory=../data/paging)
22:17:48,210 INFO  [org.hornetq.core.server] HQ221006: Waiting to obtain live lock
22:17:48,240 INFO  [org.hornetq.core.server] HQ221013: Using NIO Journal
22:17:48,269 WARN  [org.hornetq.core.server] HQ222007: Security risk! HornetQ is running with the default cluster admin user and default password. Please see the HornetQ user guide, cluster chapter, for instructions on how to change this.
22:17:48,362 INFO  [org.hornetq.core.server] HQ221043: Adding protocol support CORE
22:17:48,365 INFO  [org.hornetq.core.server] HQ221043: Adding protocol support AMQP
22:17:48,369 INFO  [org.hornetq.core.server] HQ221043: Adding protocol support STOMP
22:17:48,471 INFO  [org.hornetq.core.server] HQ221034: Waiting to obtain live lock
22:17:48,472 INFO  [org.hornetq.core.server] HQ221035: Live Server Obtained live lock
22:17:53,974 INFO  [org.hornetq.core.server] HQ221003: trying to deploy queue jms.queue.DLQ
...

原因はrun.batのバグ
CLUSTER_PROPSのダブルクォートが不要。

間違い

set CLUSTER_PROPS="-Djnp.port=1099 -Djnp.rmiPort=1098 -Djnp.host=localhost -Dhornetq.remoting.netty.host=localhost -Dhornetq.remoting.netty.port=5445"

正解

set CLUSTER_PROPS=-Djnp.port=1099 -Djnp.rmiPort=1098 -Djnp.host=localhost -Dhornetq.remoting.netty.host=localhost -Dhornetq.remoting.netty.port=5445