build.xml 中缺少类引用
当我给 ant myproject-war 时,出现以下错误。 有人可以帮忙吗?
BUILD FAILED
C:\Documents and Settings\personal\Desktop\project files\myproject\bu
ild.xml:167: taskdef A class needed by class org.apache.jasper.JspC cannot be fo
und: javax/servlet/ServletContext
When I gave ant myproject-war, I got the following error. Can anyone help please?
BUILD FAILED
C:\Documents and Settings\personal\Desktop\project files\myproject\bu
ild.xml:167: taskdef A class needed by class org.apache.jasper.JspC cannot be fo
und: javax/servlet/ServletContext
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
必须将包含 javax.servlet.ServletContext 的 JAR 添加到您的 CLASSPATH 中。
Gotta add a JAR containing javax.servlet.ServletContext to your CLASSPATH.
检查您的清单和类路径。 他们可能不包括必要的罐子。
例如:
classpathref="some_classpath"
可以放在javac
标记中,其中some_classpath
等于另外,您的 jar 的清单应该具有类似以下内容:
Check your manifest and classpath. They might not be including the necessary jar.
For instance:
classpathref="some_classpath"
could go in thejavac
tag, wheresome_classpath
equalsAlso, you jar's manifest should have something like:
在ant中可以定义新的任务(taskdef)。 其中一些任务需要您将 java 库放入 ant 的类路径中。 这可以通过将适当的 jar 复制到 ant 安装的 lib/ext 目录中来实现。
In ant new tasks can be defined (taskdef). Some of these tasks need you to put java-libraries into the classpath of ant. That can be realized by copying the appropriate jar into the lib/ext-directory of the ant-installation.
您需要在类路径中为运行包含 javax.servlet.ServletContext 的 JspC 的目标提供一个 jar。 因此,例如,如果您使用 Tomcat,则 servlet-api.jar 可能就是您正在寻找的 jar。 如果您正在使用 GWT,gwt-user.jar 可能就是 jar。 取决于您的具体情况。
You need a jar in your classpath for the target that's running JspC that contains javax.servlet.ServletContext. So, for example, if you're using Tomcat, servlet-api.jar might be the jar you're looking for. If you're doing GWT, gwt-user.jar might be the jar. Depends on your context.
您正在使用具有核心 API 不支持的依赖项的 Ant 任务。
来自文档:
使用手册找到可选任务并添加所需的依赖到类路径。
You are using Ant tasks with dependencies not supported in the core API.
From the documentation:
Use the manual to locate the optional tasks and add the required dependencies to the classpath.
Ant 不会在类路径中占用空格。
Ant doesn't take spaces in the classpath.