简体   繁体   中英

Ant Build Issue: nested exception is java.lang.NoClassDefFoundError: org/apache/tiles/request/servlet/ServletApplicationContext

Ant Build Script

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<project basedir="." name="myapp">
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>

    <property name="src.dir"    location="src"/>
    <property name="web.dir" location="war"/>
    <property name="build.dir" location="${web.dir}/WEB-INF/classes"/>
    <property name="lib.dir" location="${web.dir}/WEB-INF/lib"/>
    <property name="dist.dir" location="dist"/>
    <property name="conf.dir" location="conf"/>
    <property name="resources.dir" location="resources"/>
    <property name="war.file" value="${dist.dir}/${ant.project.name}.war"/>
    <property name="ear.file" value="${dist.dir}/${ant.project.name}.ear"/>
    <property name="version" value="3.2"/>

    <path id="compile.app.classpath">
        <fileset dir="${web.dir}/WEB-INF/lib">
            <include name="*.jar"/>
        </fileset>
        <pathelement path="${build.dir}"/>
    </path>

    <target name="clean">
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}"/>
    </target>

    <target name="init" depends="clean">
        <tstamp/>
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${dist.dir}"/>
    </target>

    <target name="compile-app" depends="init">
        <javac 
            debug="true" 
            debuglevel="${debuglevel}"
            srcdir="${src.dir}"
            destdir="${build.dir}" 
            includeantruntime="false" 
            source="${source}" 
            target="${target}"
            deprecation="on"
            classpathref="compile.app.classpath"
            excludes="test/**"/>
        <copy todir="${build.dir}">
            <fileset dir="${resources.dir}">
                <include name="**/*.xml"/>
            </fileset>
        </copy>
    </target>

    <target name="build-war" depends="compile-app" description="Create WAR file for binary distribution">
        <war destfile="${war.file}" webxml="${web.dir}/WEB-INF/web.xml">
            <webinf dir="${web.dir}/WEB-INF"/>
            <fileset dir="${dist.dir}"/>
            <lib dir="${lib.dir}">
                <exclude name="junit*.jar"/>
                <exclude name="hamcrest*.jar"/>
            </lib>
        </war>
    </target>
</project>

Directory Structure:

src
|
resources
|--log4j2.xml
war
|--META-INF
|--resources
|  |--css
|  |--img
|  |--js
|--WEB-INF
|  |--classes
|  |--lib (jar's)
|  |--views (jsp's)
|  |  |--layouts
|  |  |--templates
|  |--root-context.xml
|  |--security-context.xml
|  |--servlet-context.xml
|  |--web.xml
|  |--layout.xml (Tiles layout definitions)
|  |--template.xml (Tiles Templates)

Weblogic Deployment Error:

Servlet: "appServlet" failed to preload on startup in Web application: "myapp.war". 
org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'tilesConfigurer' defined in ServletContext resource [/WEB-INF/servlet-context.xml]: 
Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: 
org/apache/tiles/request/servlet/ServletApplicationContext at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578

Context: Trying to create an ANT build script that will package the application into a WAR file.

I have searched for a good while on what the problem maybe, but I cannot find anything that fits this situation.

I found the problem. I went through and double checked the libraries I was using, and missed the tiles-request-servlet-1.0.6.jar when adding it to the project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM