我正在嘗試部署由一個Web Servlet和JSP組成的簡單Web應用程序。我沒有使用任何框架,如Spring或任何,只是一個helloWorld網絡應用程序。使用Ant將簡單的Web應用程序部署到Tomcat中
我使用Ant來進行部署。但是,當我跑我的部署目標它給了我:
java.lang.NoClassDefFoundError: org/apache/tomcat/util/buf/B2CConverter
我使用Tomcat 7和我已經包含了Tomcat的lib目錄下的所有庫Tomcat的juli.jar到我webcontent/web-inf/lib
爲好。
我的Ant文件的目標如下:
<!-- Configure the directory into which the web application is built -->
<property name="build" value="${basedir}/build" />
<property name="lib.dir" value="${basedir}/WebContent/WEB-INF/lib" />
<property name="src.dir" value="${basedir}/src" />
<!-- Configure the context path for this application -->
<property name="path" value="/myapp" />
<!-- Configure properties to access the Manager application -->
<property name="url" value="http://localhost:8080/manager/text" />
<property name="username" value="gbids" />
<property name="password" value="tomcat" />
<!-- Configure the custom Ant tasks for the Manager application -->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask" />
<taskdef name="list" classname="org.apache.catalina.ant.ListTask" />
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask" />
<taskdef name="findleaks" classname="org.apache.catalina.ant.FindLeaksTask" />
<taskdef name="resources" classname="org.apache.catalina.ant.ResourcesTask" />
<taskdef name="start" classname="org.apache.catalina.ant.StartTask" />
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask" />
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask" />
<!-- Class path -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
<include name="**/*.zip" />
</fileset>
</path>
<!-- Executable Targets -->
<target name="compile" description="Compile web application">
<javac srcdir="${src.dir}" destdir="${build}/classes" nowarn="on">
<classpath refid="project.classpath" />
</javac>
</target>
<target name="makeWar" depends="compile">
<delete file="${build}${path}.war"/>
<war destfile="${build}${path}.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent" />
<lib dir="WebContent/WEB-INF/lib" />
<classes dir="build/classes" />
</war>
</target>
<target name="deploy" description="Install web application" depends="makeWar" >
<deploy url="${url}" username="${username}" password="${password}" path="${path}" war="${build}${path}.war" />
</target>
我也有文件按照我的的tomcat-users.xml中:
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<user username="manager" password="tomcat" roles="manager-gui"/>
<user username="admin" password="tomcat" roles="admin-gui"/>
<user username="gbids" password="tomcat" roles="manager-script"/>
任何人都可以請幫助我解決這個問題。
謝謝
請發佈異常的完整堆棧跟蹤。 –
它沒有給我一個堆棧跟蹤。只是在螞蟻控制檯的例外。 deploy: BUILD FAILED C:\ Users \ Buddhi \ workspace-indigo \ AntTestDeploy \ build.xml:52:java.lang。NoClassDefFoundError:org/apache/tomcat/util/buf/B2CConverter 總時間:1秒 – gbids