简体   繁体   English

NumberFormatException 的含义是什么以及如何解决它?

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

I'm writing code in Python/WLST to automatize connection, staringt and stopping of managed severs in weblogic.我正在用 Python/WLST 编写代码来自动化 weblogic 中托管服务器的连接、启动和停止。 I've get the error below when I start Python.启动 Python 时出现以下错误。

What is the meaning of the exception and how i can resolve it?异常的含义是什么以及我如何解决它?

Initializing WebLogic Scripting Tool (WLST) ...正在初始化 WebLogic 脚本工具 (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell欢迎使用 WebLogic Server 管理脚本外壳

Type help() for help on available commands键入 help() 以获取有关可用命令的帮助

172.31.138.15:7001 172.31.138.15:7001

Connecting to t3://172.31.138.15:7001 with userid weblogic ...使用用户 ID weblogic 连接到 t3://172.31.138.15:7001 ...

WLST detected that the RuntimeMBeanServer is not enabled. WLST 检测到 RuntimeMBeanServer 未启用。 This might happen if the RuntimeMBeanServer is disabled via the JMXMBean.如果通过 JMXMBean 禁用了 RuntimeMBeanServer,则可能会发生这种情况。 Please ensure that this MBeanServer is enabled.请确保启用此 MBeanServer。 Online WLST cannot function without this MBeanServer.如果没有此 MBeanServer,联机 WLST 将无法运行。 This Exception occurred at Mon Jan 13 08:52:50 CET 2020. java.lang.NumberFormatException: For input string: "7001 "此异常发生在 2020 年 1 月 13 日星期一 08:52:50 CET。java.lang.NumberFormatException:对于输入字符串:“7001”

The domain is unreacheable域无法访问

The code:编码:

-bash -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 -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)

[...]

Moreover, RuntimeMBeanServer is enabled in Adminserver console此外,在 Adminserver 控制台中启用了 RuntimeMBeanServer

在此处输入图片说明

Might be caused by adminurl = url.rstrip() + port + "\\n" .可能是由adminurl = url.rstrip() + port + "\\n" Try without \\n.尝试不使用 \\n。

Explanation of assumption: adminUrl can later be split into several parts by ":" symbol.假设说明:adminUrl 稍后可以通过“:”符号分成几个部分。 In that case, it would try to parse 7001\\n as int, and, well, would fail in some method like java.lang.Integer#parseInt(java.lang.String)在这种情况下,它会尝试将 7001\\n 解析为 int,并且在某些方法中会失败,例如 java.lang.Integer#parseInt(java.lang.String)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM