7

我是一个初学者,刚开始使用 JSP 并且一开始就卡住了。请帮帮我。我已经下载catalina.batsetclasspath.bat在适当的位置/tomcat/bin/ ,但仍然收到授权错误。我看过一个类似的帖子并tomcat-users.xml用这一行编辑了我的<user username="root" password="1234" roles="manager-script"/>

但仍然无法成功运行它。

See the server log for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:232)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:284)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:539)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: java.lang.IllegalStateException: Access to Tomcat server has not been authorized. Set the correct username and password with the "manager-script" role in the Tomcat customizer in the Server Manager.
    at org.netbeans.modules.tomcat5.TomcatManagerImpl.list(TomcatManagerImpl.java:398)
    at org.netbeans.modules.tomcat5.TomcatManager.modules(TomcatManager.java:639)
    at org.netbeans.modules.tomcat5.TomcatManager.getAvailableModules(TomcatManager.java:450)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.getAvailableTMIDsMap(TargetServer.java:417)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.checkUndeployForSharedReferences(TargetServer.java:372)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.checkUndeployForSharedReferences(TargetServer.java:321)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.checkUndeployForSharedReferences(TargetServer.java:318)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.processLastTargetModules(TargetServer.java:439)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.init(TargetServer.java:174)
    at org.netbeans.modules.j2ee.deployment.impl.TargetServer.deploy(TargetServer.java:579)
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:197)
    ... 16 more
Caused by: org.netbeans.modules.tomcat5.AuthorizationException
    at org.netbeans.modules.tomcat5.TomcatManagerImpl.list(TomcatManagerImpl.java:399)
    ... 26 more
BUILD FAILED (total time: 11 seconds)

对此的任何帮助对我来说都是救星,我对此非常天真。提前谢谢:)

4

4 回答 4

21

我更改了 /conf/tomcat-users.xml 的服务器错误

第1步:

更改 tomcat-users.xml

<tomcat-users>
    <role rolename="tomcat"/>
    <role rolename="role1"/>
    <role rolename="manager-gui"/>
    <user password="tomcat" roles="tomcat,manager-gui" username="tomcat"/>
    <user password="tomcat" roles="tomcat,role1" username="both"/>
    <user password="tomcat" roles="role1" username="role1"/>
    <user password="pass" roles="manager-script,admin" username="me"/>
</tomcat-users>

我添加了两个角色 manager-script 和 admin。

您可以在配置管理器中找到对角色的更多参考

第2步:

添加角色后,您需要将这些凭据添加到 Netbeans 服务器配置。

  1. 转到窗口-> 服务
  2. 选择服务器。

选择您的 tomcat 实例并右键单击以查看属性。

现在选择连接选项卡。输入“用户名”作为我,输入“密码”作为通行证。

于 2013-06-17T20:09:28.327 回答
7

检查 IDE 中工具 > 选项下的代理设置。

选择无代理为我解决了这个问题。

于 2014-01-08T14:06:06.030 回答
1

将xml文件更改为:

<tomcat-users>
<role rolename="tomcat"/>
    <role rolename="role1"/>
    <role rolename="manager-gui"/>
    <user password="tomcat" roles="tomcat,manager-gui" username="tomcat"/>
    <user password="tomcat" roles="tomcat,role1" username="both"/>
    <user password="tomcat" roles="role1" username="role1"/>
    <user password="pass" roles="manager-script,admin" username="me"/>
</tomcat-users>
于 2013-07-23T18:55:59.943 回答
-1

如果您正在运行 Windows 转到:

C:\Users\Apostolis\AppData\Roaming\NetBeans\8.0\apache-tomcat-8.0.3.0_base\conf

并相应地更改tomcat用户,例如

<tomcat-users>
<user username="ide" password="Vh4fsrwh" roles="manager-script,admin"/>
</tomcat-users>

在 Netbeans 之后,当被询问时输入用户名并传递例如 ide,Vh4fsrwh

于 2014-08-27T11:16:45.273 回答