我正在使用Ant 1.9.3和Tomcat 8.0版.我正在使用Ant deploy
目标使用manager
凭据在Apache Tomcat中部署Web应用程序.该deploy
目标失败,出现以下异常:
java.lang.NoClassDefFoundError: org/apache/tomcat/util/codec/binary/Base64 at org.apache.catalina.ant.AbstractCatalinaTask.execute(AbstractCatalina Task.java:204) at org.apache.catalina.ant.DeployTask.execute(DeployTask.java:196) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav a:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe cutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.apache.tools.ant.Main.runBuild(Main.java:851) at org.apache.tools.ant.Main.startAnt(Main.java:235) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.codec.binary .Base64 at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:423) at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ... 19 more
当我试图找到类Base64
的包org\apache\tomcat\util\codec\binary\
这是tomcat-util.jar
,这是在我在Ant构建文件中的回声验证类路径.
我无法解决这个问题.
以防有人遇到我遇到的同样问题:
我正在关注Tomcat网站上的教程,NoClassDefFoundError
当我试图运行时遇到了同样的问题ant install
.
本教程提到您必须将$CATALINA_HOME/lib/catalina-ant.jar
1(包含Ant自定义任务的实现代码)复制到lib
Ant安装目录.
但是,它没有提到你需要做同样的事情tomcat-util.jar
.一旦我复制tomcat-util.jar
到我的Ant目录,事情开始工作(源).
1$CATALINA_HOME
是Tomcat安装的目录,例如/usr/share/tomcat8