Invalid character in hostname java как исправить

I have been setting up a new laptop and my publish to jfrog was failing. Since I have it working on a different laptop I realised the difference was the JDK version in use. Reverting from JDK8 to the Apple version of JDK6 fixed the below issue. I couldn’t seem to find anyone else with this issue with Google so maybe its some bug that only gets hit by my specific setup?

java version «1.8.0_31»
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, m

java.lang.IllegalArgumentException: Invalid characters in hostname
    at java.net.HostPortrange.toLowerCase(HostPortrange.java:189)
    at java.net.HostPortrange.<init>(HostPortrange.java:150)
    at java.net.URLPermission$Authority.<init>(URLPermission.java:481)
    at java.net.URLPermission.parseURI(URLPermission.java:449)
    at java.net.URLPermission.init(URLPermission.java:170)
    at java.net.URLPermission.<init>(URLPermission.java:166)
    at sun.net.www.protocol.http.HttpURLConnection.URLtoSocketPermission(HttpURLConnection.java:1032)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1425)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at org.apache.ivy.util.url.BasicURLHandler.readResponseBody(BasicURLHandler.java:298)
    at org.apache.ivy.util.url.BasicURLHandler.disconnect(BasicURLHandler.java:277)
    at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:266)
    at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
    at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
    at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
    at sbt.ConvertResolver$ChecksumFriendlyURLResolver$class.put(ConvertResolver.scala:80)
    at sbt.ConvertResolver$PluginCapableResolver$1.put(ConvertResolver.scala:106)
    at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
    at sbt.IvyActions$$anonfun$publish$3.apply(IvyActions.scala:263)
    at sbt.IvyActions$$anonfun$publish$3.apply(IvyActions.scala:262)
    at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:772)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
    at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:771)
    at sbt.IvyActions$.publish(IvyActions.scala:262)
    at sbt.IvyActions$$anonfun$publish$1$$anonfun$apply$1.apply$mcV$sp(IvyActions.scala:97)
    at sbt.IvyActions$$anonfun$publish$1$$anonfun$apply$1.apply(IvyActions.scala:97)
    at sbt.IvyActions$$anonfun$publish$1$$anonfun$apply$1.apply(IvyActions.scala:97)
    at sbt.IvyActions$.withChecksums(IvyActions.scala:106)
    at sbt.IvyActions$.sbt$IvyActions$$withChecksums(IvyActions.scala:101)
    at sbt.IvyActions$$anonfun$publish$1.apply(IvyActions.scala:97)
    at sbt.IvyActions$$anonfun$publish$1.apply(IvyActions.scala:91)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:115)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:115)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:103)
    at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:48)
    at sbt.IvySbt$$anon$3.call(Ivy.scala:57)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:98)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:81)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:102)
    at xsbt.boot.Using$.withResource(Using.scala:11)
    at xsbt.boot.Using$.apply(Using.scala:10)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:62)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:52)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:57)
    at sbt.IvySbt.withIvy(Ivy.scala:98)
    at sbt.IvySbt.withIvy(Ivy.scala:94)
    at sbt.IvySbt$Module.withModule(Ivy.scala:115)
    at sbt.IvyActions$.publish(IvyActions.scala:91)
    at sbt.Classpaths$$anonfun$publishTask$1.apply(Defaults.scala:1173)
    at sbt.Classpaths$$anonfun$publishTask$1.apply(Defaults.scala:1172)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
    at sbt.std.Transform$$anon$4.work(System.scala:64)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:244)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] (*:publish) java.lang.IllegalArgumentException: Invalid characters in hostname

Solution to prompt IllegalArgumentException: Invalid characters in hostname when installing JDK

Prompted when installing JDK on windows7_x64 todayIllegalArgumentException:Invalid characters in hostname,


Solution:

1. Open [Control Panel System and Security System] and click [Change Settings]

2. Modify the computer name


3. Install JDK after restarting the computer (it is best to delete the residual files on the previous computer before installation)

Intelligent Recommendation

More Recommendation

Сегодня, когда вы установили JDK на Windows7_x64, пожалуйстаIllegalArgumentException:Invalid characters in hostname,


Решение:

1. Откройте [Панель управления Система и безопасность Система], нажмите [Изменить настройки]

2. Измените имя компьютера


3. Перезагрузите компьютер, а затем установите JDK (лучше удалить остаточный файл на предыдущем компьютере перед установкой)


Интеллектуальная рекомендация

Matalb Read Json File

Matlab читает файл json В MATLAB данные могут быть записаны в файл JSON, но функция чтения JSON не найдена. После проверки его онлайн большинство из них являются личными функциями, и могут возникнуть …

Написать систему управления студентами с JDBC

Сначала подготовим ранее требуемую конфигурацию: классный файл, банку. Добавьте процедуру упаковки JAR: Щелкните правой кнопкой мыши имя проекта -> New-> Папка -> Имя папки Заполните в Lib (и…

удалить меры предосторожности для детей

Java-код Кусок обычного кода: Где gift_list — это идентификатор таблицы Если: Тогда только первая строка будет удалена в это время, потому что после удаления позиция строки будет сдвинута вперед на од…

Flutter (dio +fish_redux)

Flutter + Dio + Fish_Redux , demo, 。 ! Действительно Действительно : github.com/liangwei010… : (spring boot + vue ) , :http://101.132.124.171:8000/about Вы понимаете? ,Dio , Fish_Redux , 。 , 。 …

Hexo github

:https://blog.csdn.net/weixin_44897792/article/details/90796152 , localhost:4000 ; 、 SSH : 2、 , GitHub sshkey : GitHub SSH and GPG keys : : :Are you sure you want to continue connecting (yes/no)? yes …

Вам также может понравиться

I wonder if anyone can help me on this. It’s about android development.

i am using this image link for example.
http://soompi_images.s3.amazonaws.com/4b1d3d685350b3ee612d098fda7e7441_large.jpg

I get the image using inputstream to get the image content.

InputStream is = 
   (InputStream) new URL("http://soompi_images.s3.amazonaws.com/4b1d3d685350b3ee612d098fda7e7441_large.jpg")
    .openStream();

This is to get the image from the image link for my drawable.

However, i am getting Illegal Character at hostname at index 0.

I have tried htmlEncode but it does not work. So i hope someone can help me.

Thanks.

Martijn Courteaux's user avatar

asked Sep 13, 2011 at 17:36

xenlus's user avatar

The Java URL-class cannot parse hostnames with underscores in it, such as *soompi_images*
Pheonixblade9 is a really good work around.

answered Sep 13, 2011 at 17:48

Basic Coder's user avatar

Basic CoderBasic Coder

10.8k6 gold badges42 silver badges74 bronze badges

4

This is what I do:

private Bitmap LoadImage(String URL, BitmapFactory.Options options) //
{
    Bitmap bitmap = null;
    InputStream in = null;
    try //
    {
        in = OpenHttpConnection(URL);
        bitmap = BitmapFactory.decodeStream(in, null, options);
        in.close();
    } //
    catch (Exception ex) //
    {
        Logger.LogError("LoadImage", ex);
        return null;
    }
    return bitmap;
}

private InputStream OpenHttpConnection(String strURL) throws IOException //
{
    InputStream inputStream = null;
    URL url = new URL(strURL);
    URLConnection conn = url.openConnection();

    try //
    {
        HttpURLConnection httpConn = (HttpURLConnection) conn;
        httpConn.setRequestMethod("GET");
        httpConn.connect();

        if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
            inputStream = httpConn.getInputStream();
        }
    } //
    catch (Exception ex) //
    {
        return null;
    }
    return inputStream;
}

Hope this helps!

answered Sep 13, 2011 at 17:43

Codeman's user avatar

CodemanCodeman

12.1k10 gold badges52 silver badges90 bronze badges

10

String url = "http://soompi_images.s3.amazonaws.com/4b1d3d685350b3ee612d098fda7e7441_large.jpg";

url = url.replace("soompi_images.s3.amazonaws.com", "s3.amazonaws.com/soompi_images");

InputStream is = (InputStream) new URL(url).openStream();

answered Apr 25, 2012 at 13:14

Pavel's user avatar

PavelPavel

6427 silver badges13 bronze badges

The real answer is to not use an invalid hostname in your URL. You cannot count on any invalid hostnames working reliably.

The Internet standards (Requests for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters ‘a’ through ‘z’ (in a case-insensitive manner), the digits ‘0’ through ‘9’, and the hyphen (‘-‘). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted.
<

Sources for what is a valid host name:

RFC 1123, RFC 952, Wikipedia

answered Aug 26, 2014 at 20:48

metaforge's user avatar

metaforgemetaforge

90110 silver badges11 bronze badges

This is usually caused by an _ in the host name. An example: PC_DEV2 would be a valid windows host name, but if you try to start ServiceMix on such a machine, you would get:

java.io.IOException: Transport Connector could not be registered in JMX:
 illegal character in hostname at index 8: tcp://PC_DEV2:61616 
   ...
Caused by: java.net.URISyntaxException: Illegal character in hostname at position x

The solution would be to change the host name of the machine that is running ServiceMix (just replace the _ by — which is a valid character)

Понравилась статья? Поделить с друзьями:
  • Как найти объем налитой жидкости формула
  • Как найти угловой коэффициент этой линейной функции
  • Как найти название духов по фото
  • Как правильно составить долговую расписку при дтп
  • Red dead redemption как найти лошадь