NumberFormatException 是什么意思,我该如何解决它?

What is the meaning of NumberFormatException and how I can resolve it?

我正在 Python/WLST 中编写代码以自动连接、启动和停止 weblogic 中的托管服务器。我在启动 Python 时遇到以下错误。

异常是什么意思,我该如何解决?

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

172.31.138.15:7001

Connecting to t3://172.31.138.15:7001 with userid weblogic ...

WLST detected that the RuntimeMBeanServer is not enabled. This might happen if the RuntimeMBeanServer is disabled via the JMXMBean. Please ensure that this MBeanServer is enabled. Online WLST cannot function without this MBeanServer. This Exception occurred at Mon Jan 13 08:52:50 CET 2020. java.lang.NumberFormatException: For input string: "7001 "

The domain is unreacheable

代码:

-bash

#! /bin/sh

echo $(find /u01/ -name config.xml |grep -v bak| xargs grep -A4 AdminServer | grep listen-address | cut -d'>' -f 2 | cut -d'<' -f 1)

-Python/WLST

import sys
import os
from java.lang import System
import getopt
import time

values = os.popen(str('sh /home/oracle/scripts/wls/adminurl.sh'))
url = str("".join(map(str, values)))
port = ":7001"

adminurl = url.rstrip() + port + "\n"

def connectToDomain():
    try:
        if ServerName != "" or username == "" and password == "" and adminUrl == "":
            print (adminurl)
            connect(userConfigFile='/home/oracle/scripts/wls/userconfig.secure', userKeyFile='/home/oracle/scripts/wls/userkey.secure', url=adminurl, timeout=60000)

[...]

此外,在 Adminserver 控制台中启用了 RuntimeMBeanServer

可能是由 adminurl = url.rstrip() + port + "\n" 引起的。试试不带 \n.

假设说明:adminUrl 后面可以用“:”符号分割成几个部分。在那种情况下,它会尝试将 7001\n 解析为 int,并且,在某些方法中会失败,例如 java.lang.Integer#parseInt(java.lang.String)