当前位置: 首页 > 知识库问答 >
问题:

java.lang.IllegalArgumentException:不允许使用空白

蒙光华
2023-03-14

我正在尝试在网页上嵌入一个小程序。我已经将代码导出为IntelliJ中的压缩applet。现在,当我尝试运行它时,我得到以下堆栈跟踪:

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

我相信该错误是由于试图使用applet类中的getImage()方法获取图像而导致的。这是代码:

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

下面是我在HTML中使用的标记以供参考:

如果您想亲自查看错误,只需访问http://nrubin29.github.io/freefall-applets/

谢谢!

共有1个答案

司徒俊雄
2023-03-14

如果您使用的是Java8,那么这个行为似乎存在一个开放的bug:

https://bugs.openjdk.java.net/browse/jdk-8042622?page=com.atlassian.jira.plugin.system.issueTabPanels:ChangeHistory-TabPanel

本质上,bug是Java中的一个核心bug,您所能做的任何事情都无法修复它。所以您必须等待Java8u40(如果修复程序实际达到目标版本)。

 类似资料:
  • 问题内容: 我正在尝试在表格中添加序列号。这是我的方法: 为什么此方法给我一个错误,而我的结果集已设置为可更新。我正在使用derby数据库。 问题答案: 根据Derby文档,带有的查询不可更新: 只有简单的单表SELECT游标才可以更新。可更新ResultSet的SELECT语句与可更新游标的SELECT语句具有相同的语法。生成可更新的游标: 该语句不能包含子句。 基础查询必须是SelectExp

  • 我正在测试一个用Java和spring boot写的应用程序,我有一个问题。我的测试模拟一个HTTP请求,该请求只有在数据放置在头中时才有效。这是我的简单测试的代码: 不幸的是这次测试失败了。用于测试的Java代码如下: 在实际操作中,似乎找不到应该从请求头中取出的字符串!因此,测试只评估else分支,实际上在stacktrace中也告诉我,测试希望状态已创建,但状态302已给出。既然应用程序(没

  • 问题内容: 如JDK文档中所指定,Hashtable不允许空键或值。HashMap允许一个null键和任意数量的null值。为什么是这样? 问题答案: Hashtable是较老的类,通常不鼓励使用Hashtable。也许他们看到了对null键的需求,更重要的是对null值的需求,并将其添加到HashMap实现中。 HashMap是较新的,并且具有更高级的功能,这些基本上只是对Hashtable功能

  • 问题内容: 我打算使用Ajax将跨域请求发送到soap Web服务。Web服务的URL是:http://example1.asmx?op = GetVOD 我的代码: 在IIS 7服务器端,我已经将这些行添加到文件web.config中 当我在Chrome上运行客户端代码时,出现405错误: 有谁知道如何解决这个问题? 预先感谢 问题答案: 听起来像Web DAV正在阻碍。这是删除它的配置: ht