ANT脚本无法在web应用程序的lib文件夹中找到jstl-1.2.jar

时间:2015-09-20 10:46:51

标签: java eclipse ant

我正在尝试通过ANT脚本运行我的Web应用程序但是当我尝试运行它时出现以下错误:

[java] java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
         [java]     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
         [java]     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
         [java]     at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:344)
         [java]     at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:153)
         [java]     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
         [java]     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
         [java]     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
         [java]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
         [java]     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
         [java]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
         [java]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
         [java]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
         [java]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
         [java]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
         [java]     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
         [java]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
         [java]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
         [java]     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
         [java]     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
         [java]     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
         [java]     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
         [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         [java]     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
         [java]     at java.lang.Thread.run(Unknown Source)
         [java] Sep 20, 2015 4:02:20 PM org.apache.catalina.core.StandardWrapperValve invoke
         [java] SEVERE: Servlet.service() for servlet [FacesServlet] in context with path [/Jcart] threw exception [javax/servlet/jsp/jstl/core/Config] with root cause
         [java] java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
         [java]     at com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:344)
         [java]     at com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:153)
         [java]     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
         [java]     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
         [java]     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
         [java]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
         [java]     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
         [java]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
         [java]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
         [java]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
         [java]     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
         [java]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
         [java]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
         [java]     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
         [java]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
         [java]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
         [java]     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
         [java]     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
         [java]     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
         [java]     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
         [java]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         [java]     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
         [java]     at java.lang.Thread.run(Unknown Source)

我知道这个错误是由于在web应用程序的lib文件夹中缺少jstl-1.2 jar而引起的。我已经把它放在那里了。

即使应用程序在Eclipse上运行得很好,但是当我在Eclipse中通过ANT脚本运行它时,它会抛出异常,如上所述。

我不知道为什么ANT脚本没有找到jstl-1.2.jar。

这是我的ANT脚本:

<?xml version="1.0" encoding="UTF-8"?>
<project name="execute"  basedir="." default="execute">

<description>Deploying the war into server..</description>

<property name="tomcat.home" value="D:\Tomcat\Tomcat-7.0.62" />
<property name="build" value="classes"/>
      <path id="includejars">

    <!--Path of jar files required for compilation of the project -->
          <fileset dir="D:\EclipseWorkspaces\FA4SessionExam\Jcart\WebContent\WEB-INF\lib">
             <include name="*.jar"/>
          </fileset>

        <!--Path of JAR file required for  Web-Listener class -->

     <fileset dir="D:\Tomcat\Tomcat-7.0.62\lib">
                 <include name="servlet-api.jar"/>
              </fileset>
       </path>

    <!--Script to compile the java classes -->
       <target name="compile" description="Compile main source tree java files">
       <mkdir dir="${build}"/>
          <javac destdir="${build}"  debug="true" includeantruntime="false"
             deprecation="false" optimize="false" failonerror="true">
             <src path="src"/>
             <classpath refid="includejars"/>
          </javac>
        <echo>Compiled...</echo>
       </target >

    <!--Script to create a war file -->

    <target name= "createwar" depends="compile" description= "Creates the WAR file">
            <war destfile="D:\Tomcat\Tomcat-7.0.62\webapps\Jcart.war" webxml="WebContent/WEB-INF/web.xml">
            <fileset dir="WebContent"/>
            <lib dir="WebContent/WEB-INF/lib"/>
            <classes dir="build/classes"/>
            <classes dir="src" />
            </war>

        <echo>WAR file is created for the given project!!!</echo>
    </target >

    <!--Script to start and stop the server -->

      <target name="tomcat-restart" depends="createwar">
            <antcall target="tomcat-stop" /> 
            <antcall target="tomcat-start" />
      </target>

      <target name="tomcat-start">
            <java classname="org.apache.catalina.startup.Bootstrap" fork="true">
                <classpath path="${tomcat.home}/bin/bootstrap.jar:${tomcat.home}/bin/tomcat-juli.jar" />
                <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
                <!--If you are getting any OutOfMemoryError, remove the comments 
                and enable jvm argument of the following line-->
                <!--jvmarg value="-XX:MaxPermSize=256m"/-->
            </java>
            <echo>server started..</echo>
      </target>

      <target name="tomcat-stop">
            <java classname="org.apache.catalina.startup.Bootstrap" fork="true">
                <classpath path="${tomcat.home}/bin/bootstrap.jar:${tomcat.home}/bin/tomcat-juli.jar" />
                <jvmarg value="-Dcatalina.home=${tomcat.home}"/>
                <arg line="stop"/>
            </java>
            <echo>server stopped..</echo>
     </target>

    <!--Script to execute the jsp page-->


    <property name="file" value="http://localhost:8765/Jcart" />
        <target name="execute" depends="tomcat-restart">
                <echo>Executing</echo>
                <exec executable="C:/Program Files/Internet Explorer/iexplore.exe" spawn="true">
                    <arg value="${file}/faces/pages/login.jsp" />
                </exec>
        </target>
</project>

0 个答案:

没有答案