gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 09:07:11 41 4
gpt4 key购买 nike

我正在用 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)

[...]

此外,RuntimeMBeanServer 已在管理服务器控制台中启用

enter image description here

最佳答案

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

假设说明:adminUrl 稍后可以通过“:”符号分割成多个部分。在这种情况下,它会尝试将 7001\n 解析为 int,并且在 java.lang.Integer#parseInt(java.lang.String) 等方法中会失败

关于java - NumberFormatException 的含义是什么以及如何解决它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59714815/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com