Ситуация
Я работаю над групповым веб-проектом, в котором используется среда Spring. Нам нужно использовать собственный сценарий ANT, чтобы построить проект для непрерывной интеграции. В настоящее время я пытаюсь скомпилировать проект с использованием пользовательской цели ANT, но продолжаю сталкиваться с ошибкой.
Ошибка
Резюме:
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
Full:
15-Feb-2011 9:47:36 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4148)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:943)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1397)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1500)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:252)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Соответствующие части сценария сборки
Это скрипт сборки, который мы сейчас используем. Мы называем цель "dist". Посторонние цели (test, doc, smoke-test, tomcat-start, tomcat-stop и т. Д.) Были опущены.
<!-- ******************************************************************* -->
<!-- * Project Home Directories * -->
<!-- ******************************************************************* -->
<!-- * We should include most dependancy jars in the repository. * -->
<!-- ******************************************************************* -->
<!-- Override this with "ant -Dconf.home=./conf.example deploy" -->
<property name="conf.home" value="${basedir}/conf/local" />
<!-- Load the build environment properties -->
<property file="${conf.home}/build.properties"/>
<!-- ******************************************************************* -->
<!-- * Classpath Parameters * -->
<!-- ******************************************************************* -->
<!-- * The different classpaths that are used in the build process. * -->
<!-- ******************************************************************* -->
<path id="log4j.classpath">
<fileset dir="${log4j.home}" id="log4j.files" includes="log4j-1.2.8.jar"/>
</path>
<path id="dist.classpath">
<pathelement location="${dist.home}"/>
</path>
<path id="bin.classpath">
<pathelement location="${bin.home}"/>
</path>
<path id="json-simple.classpath">
<fileset dir="${json-simple.home}" id="json-simple.files" includes="json_simple-1.1.jar"/>
</path>
<path id="cas.classpath">
<fileset dir="${cas.home}">
<include name="cas.jar"/>
<include name="casclient.jar"/>
</fileset>
</path>
<path id="jdbc.classpath">
<fileset dir="${jdbc.home}" id="jdbc.files">
<include name="mysql-connector*.jar"/>
</fileset>
</path>
<path id="tomcat.classpath">
<fileset dir="${tomcat.home}" id="tomcat.files">
<include name="catalina-ant.jar"/>
<include name="servlet-api.jar"/>
</fileset>
</path>
<path id="ant-contrib.classpath">
<fileset dir="${ant-contrib.home}" id="ant-contrib.files">
<include name="ant-contrib-0.6.jar"/>
</fileset>
</path>
<path id="sysUtil.classpath">
<fileset dir="${sysUtil.home}" id="sysUtil.files">
<include name="ca.usask.cs.sysUtil.jar"/>
</fileset>
</path>
<!-- TODO FIXME added by Dylan. Clean as necessary! -->
<path id="junit.classpath">
<fileset dir="${junit.home}" id="junit.files">
<include name="junit-4.8.2.jar"/>
</fileset>
</path>
<path id="lib.classpath">
<pathelement location="${lib.home}"/>
</path>
<path id="test.classpath">
<pathelement location="${test.home}"/>
</path>
<path id="selenium.rc.classpath">
<fileset dir="${selenium.rc.home}" id="selenium.rc.files">
<include name="selenium-java-client-driver.jar"/>
</fileset>
</path>
<path id="spring.classpath">
<fileset dir="${spring.home}" id="spring.files">
<include name="spring*.jar"/>
</fileset>
</path>
<!-- ******************************************************************* -->
<!-- * Task Definitions * -->
<!-- ******************************************************************* -->
<!-- * This area identifies the external ant tasks that we want to be * -->
<!-- * able to use. Of particular interest are the tomcat tasks, * -->
<!-- * which can be used for automatic deployment, as well as the * -->
<!-- * ant-contrib tasks which contain additional useful ant routines. * -->
<!-- ******************************************************************* -->
<taskdef name="tomcat-stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="tomcat.classpath"/>
</taskdef>
<taskdef name="tomcat-start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="tomcat.classpath"/>
</taskdef>
<taskdef name="tomcat-deploy" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="tomcat.classpath"/>
</taskdef>
<taskdef name="tomcat-undeploy" classname="org.apache.catalina.ant.UndeployTask">
<classpath refid="tomcat.classpath"/>
</taskdef>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath refid="ant-contrib.classpath"/>
</taskdef>
<!-- ******************************************************************* -->
<!-- * Targets * -->
<!-- ******************************************************************* -->
<!-- * The meat of the ant build file, each target is an action that * -->
<!-- * you want to be able to perform. * -->
<!-- ******************************************************************* -->
<target name="clean"
description="Removes the built classes." >
<delete dir="${dist.home}" />
<delete dir="${admin.home}" />
</target>
<target name="build"
depends="clean"
description="Builds class tree from sources." >
<mkdir dir="${bin.home}"/>
<javac source="1.6" debug="true" deprecation="true"
destdir="${bin.home}" fork="true" srcdir="${src.home}"
includeantruntime="false">
<classpath refid="tomcat.classpath"/>
<classpath refid="cas.classpath"/>
<classpath refid="log4j.classpath"/>
<classpath refid="json-simple.classpath" />
<classpath refid="sysUtil.classpath"/>
<classpath refid="jdbc.classpath"/>
<classpath refid="spring.classpath"/>
</javac>
</target>
<target name="dist"
depends="build"
description="Creates war archive to deploy application" >
<!-- Copy configuration files into classes dir (so they're in the classpath) -->
<copy overwrite="yes" todir="${dist.home}/WEB-INF/classes">
<fileset dir="${conf.home}" includes="application.properties" />
<fileset dir="${conf.home}" includes="log4j.properties" />
</copy>
<!-- Copy context.xml to META-INF -->
<copy overwrite="yes" file="${conf.home}/context.xml" tofile="${dist.home}/META-INF/context.xml" />
<!-- Copy web.xml to WEB-INF -->
<copy overwrite="yes" file="${conf.home}/web.xml" tofile="${dist.home}/WEB-INF/web.xml" />
<!-- Copy *some of the* libraries into lib dir -->
<copy overwrite="yes" todir="${dist.home}/WEB-INF/lib">
<fileset dir="${cas.home}" includes="**/*" />
<fileset dir="${log4j.home}" includes="**/*" />
<fileset dir="${json-simple.home}" includes="**/*" />
<fileset dir="${sysUtil.home}" includes="**/*" />
<fileset dir="${jdbc.home}" includes="**/*" />
<fileset dir="${spring.home}" includes="**/*.jar" />
<fileset dir="${lib.home}" includes="**/*.jar" />
</copy>
<!-- Copy web stuff into deploy root -->
<copy overwrite="yes" todir="${dist.home}">
<fileset dir="${basedir}/web" includes="**/*" />
</copy>
<jar destfile="${basedir}/${dist.name}.war" compress="true">
<fileset dir="${dist.home}" />
</jar>
</target>
Дополнительная информация
- Мы используем Spring 3.0.2
- Мы используем Tomcat 6.0
- Мы работаем на Mandriva 2010 и Ubuntu 10
- Проект работает в Netbeans и является веб-проектом в свободной форме
- Tomcat запускается с помощью "/bin/catalina.sh run", чтобы мы могли легко увидеть любой вывод и все, чтобы мы были уверены, что он запущен, и чтобы мы могли убедиться, что файл войны работает правильно развертывается.
РЕДАКТИРОВАТЬ: Содержимое / WEB_INF / lib
Следующие файлы присутствуют:
- Обще-ДБХП-1.4.jar
- Обще-каротаж 1.1.jar
- MySQL-разъем-Java-3.0.11-устойчиво-bin.jar * * один тысячу пятьдесят-семь
- log4j-1.2.8.jar
- Обще-ДБХП-1,4-javadoc.jar
- Обще-pool.jar
- Обще-ДБХП-1,4-sources.jar
- CGLIB-2.2.jar
Присутствуют следующие папки с содержимым в скобках (поскольку я не знаю, как создавать подсписки, хаха)
- ant-contrib-0.6 (ant-contrib-0.6.jar, antprof.jar)
- cas (casclient.jar, cas.jar)
- json-simple-1.1 (json_simple-1.1.jar)
- junit (junit-4.8.2.jar)
- log4j-1.2.8 (log4j-1.2.8.jar)
- selenium-rc (selenium-java-client-driver.jar, selenium-server.jar)
- spring (spring-aop-3.0.2.RELEASE.jar, spring-context-support-3.0.2.RELEASE.jar, spring-jdbc-3.0.2.RELEASE.jar, spring -test-3.0.2.RELEASE.jar,
spring-asm-3.0.2.RELEASE.jar, spring-core-3.0.2.RELEASE.jar, spring-jms-3.0.2.RELEASE.jar, spring-tx-3.0.2.RELEASE.jar,
spring-aspect-3.0.2.RELEASE.jar, spring-expression-3.0.2.RELEASE.jar, spring-orm-3.0.2.RELEASE.jar, spring-web-3.0.2.RELEASE.jar,
spring-beans-3.0.2.RELEASE.jar, spring-instrument-3.0.2.RELEASE.jar, spring-oxm-3.0.2.RELEASE.jar, spring-webmvc-3.0.2.RELEASE.jar,
spring-context-3.0.2.RELEASE.jar, spring-instrument-tomcat-3.0.2.RELEASE.jar, spring-struts-3.0.2.RELEASE.jar, spring-webmvc-portlet-3.0.2.RELEASE. банка) * +1099 *
- sysUtil ()
- tomcat-5 (catalina-ant.jar, servlet-api.jar)
Так, кто-нибудь может помочь мне (нам) с этой ошибкой? Мы боролись с этим часами.
(TL; DR: Spring 3.0.5! Tomcat 6! Сборка через ANT дает «java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener"; что делать?)