java 在 netbeans 中运行 Web 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10153816/
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-10-30 23:49:31  来源:igfitidea点击:

run web application in netbeans

javatomcatmavennetbeans

提问by Naor

I am using netbeans and apache tomcat in order to run web application. I keep getting this error:

我正在使用 netbeans 和 apache tomcat 来运行 Web 应用程序。我不断收到此错误:

In-place deployment at C:\WorkingDirectory\Projects\GreenWheelsProject\GreenWheels-Java\green-wheels-project\share-wheels\target\share-wheels
deploy?config=file%3A%2FC%3A%2FDOCUME%7E1%2F0DD4%7E1%2FLOCALS%7E1%2FTemp%2Fcontext600644043101946969.xml&path=/
FAIL - Deployed application at context path / but context failed to start
The module has not been deployed.
See the server log for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
    at org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:179)
    at org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:131)
    at org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:211)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

The server log is:

服务器日志是:

??? 14, 2012 3:55:00 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4660)
    at org.apache.catalina.core.StandardContext.call(StandardContext.java:5226)
    at org.apache.catalina.core.StandardContext.call(StandardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

??? 14, 2012 3:55:00 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)

and the output of the sever is:

服务器的输出是:

??? 14, 2012 3:54:59 PM org.apache.catalina.util.LifecycleBase stop
INFO: The stop() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] after stop() had already been called. The second call will be ignored.
??? 14, 2012 3:54:59 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context []
??? 14, 2012 3:54:59 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor ROOT.xml from C:\Documents and Settings\????\.netbeans.1.1\apache-tomcat-7.0.22.0_base\conf\Catalina\localhost
??? 14, 2012 3:54:59 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\WorkingDirectory\Projects\GreenWheelsProject\GreenWheels-Java\green-wheels-project\share-wheels\target\share-wheels\WEB-INF\lib\javaee-api-6.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
??? 14, 2012 3:55:00 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
??? 14, 2012 3:55:00 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors

This is my POM:

这是我的 POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.success</groupId>
  <artifactId>share-wheels</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>share-wheels Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>share-wheels</finalName>
  </build>
</project>

What is wrong here??..

这里有什么问题???

EDIT:
This problem accures when I add the following to thw pom file:

编辑:
当我将以下内容添加到 thw pom 文件时,会出现此问题:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
</dependency>

Why is this? I need this dependency for HttpServletRequest. How can I fix this?

为什么是这样?我需要 HttpServletRequest 的这种依赖关系。我怎样才能解决这个问题?

采纳答案by agaqeu

I had the same deployment failure that Naor. My Tomcat webapps folder doesn't have the manager module (I removed!) that comes with the default Tomcat dist. So, when NetBeans tries to deploy on the web container (Tomcat) then it fails, 'cause there is no manager module. Restoring the manager module resolves the error message.

我遇到了与 Naor 相同的部署失败。我的 Tomcat webapps 文件夹没有默认 Tomcat dist 附带的管理器模块(我删除了!)。因此,当 NetBeans 尝试在 Web 容器 (Tomcat) 上进行部署时,它会失败,因为没有管理器模块。恢复管理器模块可以解决错误消息。

回答by Thorbj?rn Ravn Andersen

Use <scope>provided</scope>to indicate that you need the artifact to compile, but not to have it in your war.

使用<scope>provided</scope>,以表明你需要的神器编译,而不是有它在你的War。

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

回答by Priyanshu Jha

Right Click..Do Clean And build!!! I have faced this issue while developing Spring web MVC application in netbeans..Generally clean and build worked

右键单击..清理并构建!!!我在 netbeans 中开发 Spring web MVC 应用程序时遇到了这个问题。一般来说,清理和构建工作