Java “URI 具有权限组件”是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2366270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 06:36:12  来源:igfitidea点击:

What does 'URI has an authority component' mean?

javanetbeansglassfish

提问by Kirby

I am attempting to build a Java web project on NetBeans 6.8, but I get get the following error:

我正在尝试在 NetBeans 6.8 上构建 Java Web 项目,但出现以下错误:

The module has not been deployed.

该模块尚未部署。

It points to my build-impl.xmlfile, line 577:

它指向我的build-impl.xml文件,第 577 行:

<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>

The GlassFish v3 error log says:

GlassFish v3 错误日志说:

SEVERE: Exception in command execution : java.lang.IllegalArgumentException: URI has an authority component
java.lang.IllegalArgumentException: URI has an authority component
  at java.io.File.<init>(File.java:368)`..., etc.

What does "URI has an authority component"mean?

什么“URI有一个授权组成”是什么意思?

采纳答案by Kirby

The solution was simply that the URI was malformed (because the location of my project was over a "\\" UNC path). This issue was fixed when I used a local workspace.

解决方案很简单,URI 格式不正确(因为我的项目位置位于“\\”UNC 路径上)。当我使用本地工作区时,此问题已得到解决。

回答by Brian Knoblauch

Flip over to the GlassFish output tab, it'll give you better info. Netbeans gives you that generic error, but Glassfish gives you the details. When I get this it's usually a typo in one of my JSP or XML files...

翻转到 GlassFish 输出选项卡,它将为您提供更好的信息。Netbeans 为您提供了一般错误,但 Glassfish 为您提供了详细信息。当我得到这个时,它通常是我的 JSP 或 XML 文件之一中的错字......

回答by shereifhawary

I had the same problem (NetBeans 6.9.1) and the fix is so simple :)

我遇到了同样的问题(NetBeans 6.9.1),修复很简单:)

I realized NetBeans didn't create a META-INF folder and thus no context.xmlwas found, so I create the META-INF folder under the main project folder and create file context.xmlwith the following content.

我意识到 NetBeans 没有创建 META-INF 文件夹,因此没有context.xml找到,所以我在主项目文件夹下创建 META-INF 文件夹并创建context.xml包含以下内容的文件。

<?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/home"/>

And it runs :)

它运行:)

回答by MostafaEweda

I found out that the URL of the application conflicted with a module in the Sun GlassFish. So, in the file sun-web.xmlI renamed the <context-root>/servlets-samples</context-root>.

我发现应用程序的 URL 与 Sun GlassFish 中的模块冲突。因此,在文件中,sun-web.xml我重命名了 <context-root>/servlets-samples</context-root>。

It is now working.

它现在正在工作。

回答by Zakir Sajib

I also faced similar problem while working on Affable Bean e-commerce site development. I received an error:

我在从事 Affable Bean 电子商务网站开发时也遇到过类似的问题。我收到一个错误:

Module has not been deployed.

模块尚未部署。

I checked the sun-resources.xmlfile and found the following statements which resulted in the error.

我检查了sun-resources.xml文件,发现以下语句导致错误。

<resources>
    <jdbc-resource enabled="true"
                   jndi-name="jdbc/affablebean"
                   object-type="user"
                   pool-name="AffableBeanPool">
    </jdbc-resource>

    <jdbc-connection-pool allow-non-component-callers="false"
                          associate-with-thread="false"
                          connection-creation-retry-attempts="0"
                          connection-creation-retry-interval-in-seconds="10"
                          connection-leak-reclaim="false"
                          connection-leak-timeout-in-seconds="0"
                          connection-validation-method="auto-commit"
                          datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
                          fail-all-connections="false"
                          idle-timeout-in-seconds="300"
                          is-connection-validation-required="false"
                          is-isolation-level-guaranteed="true"
                          lazy-connection-association="false"
                          lazy-connection-enlistment="false"
                          match-connections="false"
                          max-connection-usage-count="0"
                          max-pool-size="32"
                          max-wait-time-in-millis="60000"
                          name="AffableBeanPool"
                          non-transactional-connections="false"
                          pool-resize-quantity="2"
                          res-type="javax.sql.ConnectionPoolDataSource"
                          statement-timeout-in-seconds="-1"
                          steady-pool-size="8"
                          validate-atmost-once-period-in-seconds="0"
                          wrap-jdbc-objects="false">

        <description>Connects to the affablebean database</description>
        <property name="URL" value="jdbc:mysql://localhost:3306/affablebean"/>
        <property name="User" value="root"/>
        <property name="Password" value="nbuser"/>
    </jdbc-connection-pool>
</resources>

Then I changed the statements to the following which is simple and works. I was able to run the file successfully.

然后我将语句更改为以下简单且有效的语句。我能够成功运行该文件。

<resources>
    <jdbc-resource enabled="true" jndi-name="jdbc/affablebean" object-type="user" pool-name="AffablebeanPool">
        <description/>
    </jdbc-resource>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="AffablebeanPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.ConnectionPoolDataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="URL" value="jdbc:mysql://localhost:3306/AffableBean"/>
        <property name="User" value="root"/>
        <property name="Password" value="nbuser"/>
    </jdbc-connection-pool>
</resources>

回答by Mike GH

After trying a skeleton project called "jsf-blank", which did not demonstrate this problem with xhtml files; I concluded that there was an unknown problem in my project. My solution may not have been too elegant, but it saved time. I backed up the code and other files I'd already developed, deleted the project, and started over - recreated the project. So far, I've added back most of the files and it looks pretty good.

尝试了一个叫“jsf-blank”的骨架项目后,用xhtml文件没有演示这个问题;我得出结论,我的项目中存在未知问题。我的解决方案可能不太优雅,但它节省了时间。我备份了我已经开发的代码和其他文件,删除了项目,然后重新开始 - 重新创建了项目。到目前为止,我已经添加了大部分文件,看起来还不错。

回答by S Meaden

An authority is a portion of a URI. Your error suggests that it was not expecting one. The authority section is shown below, it is what is known as the website part of the url.

权限是 URI 的一部分。您的错误表明它并不期待一个。权限部分如下所示,它是 url 的网站部分。

From RFC3986 on URIs:

从 RFC3986 关于URI

The following is an example URI and its component parts:

以下是一个示例 URI 及其组成部分:

     foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment
      |   _____________________|__
     / \ /                        \
     urn:example:animal:ferret:nose

So there are two formats, one with an authority and one not. Regarding slashes:

所以有两种格式,一种有权限,一种没有。关于斜线:

"When authority is not present, the path cannot begin with two slash
characters ("//")."

“当权限不存在时,路径不能以两个斜杠
字符(“//”)开头。”

Source: http://www.rfc-base.org/txt/rfc-3986.txt(search for text 'authority is not present, the path cannot begin with two slash')

来源:http: //www.rfc-base.org/txt/rfc-3986.txt(搜索文本'权限不存在,路径不能以两个斜杠'开头