简体   繁体   中英

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. I've get the error below when I start Python.

What is the meaning of the exception and how i can resolve it?

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

The code:

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

[...]

Moreover, RuntimeMBeanServer is enabled in Adminserver console

在此处输入图片说明

Might be caused by adminurl = url.rstrip() + port + "\\n" . Try without \\n.

Explanation of assumption: adminUrl can later be split into several parts by ":" symbol. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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