I am generating an ear file using Ant Script. I see that script perfectly compiles the java class files but when I check the class files in the generated war file they are showing errors as below due to which I am not able to deploy ear to server
public TransportationController()
{
throw new Error("Unresolved compilation problems: \n\tThe import org.springframework cannot be re" +"solved\n\tThe import org.springframework cannot be resolved\n\tThe import org.sp" +"ringframework cannot be resolved\n\tThe import org.springframework cannot be res" +"olved\n\tThe import org.springframework cannot be resolved\n\tThe import org.spr" +"ingframework cannot be resolved\n\tThe import org.springframework cannot be reso" +"lved\n\tThe import com.pepsico.us.sc.updateprocessflagob cannot be resolved\n\tC"
);
}
My Ant script to generate war is as below:
<target name="do.package" depends="common.do.package">
<war webxml="WebContent/WEB-INF/web.xml"
warfile="${output.dir}/sn-ecr-web.war"
manifest="WebContent/META-INF/MANIFEST.MF">
<zipfileset dir="WebContent"/>
<zipfileset dir="${output.dir}" includes="**/*.jar" prefix="WEB-INF/lib"/>
</war>
<delete dir="${output.dir}" includes="**/*.jar"/>
</target>
This means that you have used the Eclipse compiler to compile your own classes, and that some classes didn’t compile (due to missing Spring jars in the compilation classpath). Eclipse generates class files for non-compiling class files, but with methods throwing errors instead of containing the actual code (since it doesn’t compile).
Fix the compilation issues, and regenerate your jars.