상세 컨텐츠

본문 제목

java.lang.IllegalArgumentException: white space not allowed 관련 java 버그??

JAVA

by AlrepondTech 2020. 9. 18. 01:16

본문

반응형

 

 

 

 

=================================

=================================

=================================

 

 

 

 

 

출처: http://stackoverflow.com/questions/24027671/java-lang-illegalargumentexception-white-space-not-allowed

java.lang.IllegalArgumentException: white space not allowed

I am attempting to embed an applet on a webpage. I have exported the code as a compressed applet in IntelliJ. Now, when I try to run it, I get the following stack trace

 

java.lang.IllegalArgumentException: white space not allowed
    at java.net.URLPermission.normalizeHeaders(URLPermission.java:401)
    at java.net.URLPermission.init(URLPermission.java:189)
    at java.net.URLPermission.<init>(URLPermission.java:166)
    at sun.net.www.protocol.http.HttpURLConnection.URLtoSocketPermission(HttpURLConnection.java:1031)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1424)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at com.sun.deploy.net.HttpUtils.followRedirects(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doGetRequestEX(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.checkUpdateAvailable(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.isUpdateAvailable(Unknown Source)
    at com.sun.deploy.cache.DeployCacheHandler.get(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1048)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:987)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:985)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessController.doPrivileged(AccessController.java:713)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:984)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
    at sun.net.www.protocol.http.HttpURLConnection.followRedirect0(HttpURLConnection.java:2648)
    at sun.net.www.protocol.http.HttpURLConnection.access$300(HttpURLConnection.java:90)
    at sun.net.www.protocol.http.HttpURLConnection$12.run(HttpURLConnection.java:2565)
    at sun.net.www.protocol.http.HttpURLConnection$12.run(HttpURLConnection.java:2563)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessController.doPrivileged(AccessController.java:713)
    at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:2562)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1768)
    at sun.net.www.protocol.http.HttpURLConnection.access$200(HttpURLConnection.java:90)
    at sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1431)
    at sun.net.www.protocol.http.HttpURLConnection$9.run(HttpURLConnection.java:1429)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessController.doPrivileged(AccessController.java:713)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1428)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at sun.plugin.PluginURLJarFileCallBack.downloadJAR(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack.access$000(Unknown Source)
    at sun.plugin.PluginURLJarFileCallBack$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin.PluginURLJarFileCallBack.retrieve(Unknown Source)
    at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:205)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:71)
    at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:99)
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(Unknown Source)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFileInternal(Unknown Source)
    at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$1000(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath$JarLoader.<init>(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
    at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:744)
Ignored exception: java.lang.IllegalArgumentException: white space not allowed

I believe the error was caused by trying to get an image with the getImage() method in the Appletclass. This is the code:

try {
    image = new ImageIcon(main.getImage(main.getCodeBase(), imageName + ".png"));
} catch (Exception e) {
    e.printStackTrace();
}

For reference, here's the tag I'm using in the HTML:

<applet archive = "https://github.com/nrubin29/FreeFall-Applets/blob/master/Noah/Noah.war?raw=true"
code = "FreeFallMain" > < /applet>

If you want to see the error for yourself, just go to http://nrubin29.github.io/FreeFall-Applets/

Thanks!

----------------------------------------------------------------------------------------------------------------------------------------------------------------

Can you not use whitespaces? –  David Yee Jun 4 at 1:41
Where are the whitespaces? I don't know what you mean. –  nrubin29 Jun 4 at 1:42 
In your getImage argument, do you have whitespaces in the file path and if so, can you change the file names?

----------------------------------------------------------------------------------------------------------------------------------------------------------------

What about the string returned by your main.getCodeBase() function? And are you sure it is that exception that is causing the problem and not another?

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

If you're using Java 8, it looks like there's an open bug around this exact behavior:

bugs.openjdk.java.net/browse/JDK-8042622?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel

In essence, the bug is that it's a core bug in Java, and nothing you can do can fix it. So you'll 
have to wait for Java 8u40 (if the fix actually hits their target release).

 

 

 

=================================

=================================

=================================

 

 

 

it looks like one of those calls (or your main call) is causing a URL to be loaded (looks like it's a jar file), then there's a redirect, and there's a space or tab in one of the response HTTP headers names. What happens if you host the applet jar/war on a local webserver rather than Github?

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I had a similar issue (with the upgrade from java 1.7.0_67 to java 1.8.0_25) opening a page that redirects to a pdf document with code like this:

 

InputStream in = new URL(myUrl).openConnection().getInputStream();

I have found a possible (hopefully temporary) workaround for those who can't wait next january (or april?) for java 8u40:

try {
    InputStream in = new URL(myUrl).openConnection().getInputStream();
} catch (IllegalArgumentException iae) {
    in = 
    sun.net.www.protocol.http.HttpURLConnection.openConnectionCheckRedirects(new URL(myUrl).openConnection());
}

You can obviously add log and check if the open connection is istanceof HttpURLConnection.

I'm open to suggestions if you think what I've done is very wrong (consider I've stripped the non-essential parts).

 

 

=================================

=================================

=================================

 

 

 

 

반응형


관련글 더보기

댓글 영역