
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
tomcat 5.x, jdk1.5
|
|
|
Sometimes while redeploing Appfuse application in tomcat 5.x (with reloadable="true" in context.xml) I'm getting
the following error in catalina.out :
ERROR [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
ContextLoader.initWebApplicationContext(182) | Context initialization
failed
java.lang.InternalError: jzentry == 0,
jzfile = 141476144,
total = 41,
name = /home/serega/tomcat/webapps/pcc/WEB-INF/lib/pcc-dao.jar,
i = 9,
message = invalid LOC header (bad signature)
at java.util.zip.ZipFile$3.nextElement(ZipFile.java:430)
at java.util.zip.ZipFile$3.nextElement(ZipFile.java:416)
at java.util.jar.JarFile$1.nextElement(JarFile.java:214)
at java.util.jar.JarFile$1.nextElement(JarFile.java:213)
at
org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingJarResources(PathMatchingResourcePatternResolver.java:322)
It can be cured only by restarting tomcat and happens 2 or 3 times a day
on regular basis.
Futher investigations showed that errors happen then spring context files are loaded (it can be seen from stack trace :)).
Workaround
-----------------------
Workaround for this problem is to load context xml files from WEB-INF directory instead of jars.
It can be accomplished with following changes in web.xml and build.xml :
- comment out second config location line in the web-settings.xml
to force Spring use only /WEB-INF files :
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-*.xml
<!-- classpath*:META-INF/applicationContext-*.xml-->
</param-value>
</context-param>
- add the following lines into the package-web ant task before war task:
<copy tofile="${webapp.dist}/applicationContext-service.xml"
overwrite="true">
<fileset dir="src/service" includes="**/*-service.xml"/>
</copy>
<copy tofile="${webapp.dist}/applicationContext-hibernate.xml"
overwrite="true">
<fileset dir="src/dao" includes="**/*-hibernate.xml"/>
<filterset refid="variables.to.replace"/>
</copy>
- and add 2 lines inside the package-web's war task :
<webinf dir="${webapp.dist}"
includes="applicationContext-service.xml"/>
<webinf dir="${webapp.dist}"
includes="applicationContext-hibernate.xml"/>
Below is my modified package-web task :
<target name="package-web" depends="compile-web,jsp-2"
description="Package WAR">
<propertyfile comment="Build Information"
file="${build.dir}/web/classes/build.properties">
<entry key="build.date" type="date" pattern="EEEE MMM dd,
yyyy" value="now"/>
<entry key="build.time" type="date" pattern="hh:mm:ss a zz"
value="now"/>
<entry key="build.username" value="${user.name}"/>
<entry key="build.computer" value="${env.COMPUTERNAME}"/>
<entry key="build.dao.type" value="${dao.type}"/>
<entry key="webapp.version" value="${webapp.version}"/>
</propertyfile>
<!-- If Tomcat 5, uncomment the <dispatcher> elements in
filter-mappings -->
<if>
<or>
<isset property="tomcat5"/>
<isset property="tomcat5.5"/>
</or>
<then>
<replaceregexp flags="g"
file="${webapp.target}/WEB-INF/web.xml"
match='<!--dispatcher>'
replace='<dispatcher>'/>
<replaceregexp flags="g"
file="${webapp.target}/WEB-INF/web.xml"
match='</dispatcher-->'
replace='</dispatcher>'/>
</then>
</if>
<echo>Preparing tomcat-context.xml for inclusion in war</echo>
<!-- Copy tomcat-context.xml file to context.xml -->
<if>
<and>
<isset property="tomcat5"/>
<not><isset property="tomcat5.5"/></not>
</and>
<then>
<copy tofile="${webapp.dist}/context.xml"
file="metadata/conf/tomcat-context.xml"
overwrite="true">
<filterset refid="db.variables"/>
</copy>
</then>
<elseif>
<isset property="tomcat5.5"/>
<then>
<copy tofile="${webapp.dist}/context.xml"
file="metadata/conf/tomcat-context-5.5.xml"
overwrite="true">
<filterset refid="db.variables"/>
</copy>
</then>
</elseif>
</if>
<!-- added -->
<copy tofile="${webapp.dist}/applicationContext-service.xml"
overwrite="true">
<fileset dir="src/service" includes="**/*-service.xml"/>
</copy>
<copy tofile="${webapp.dist}/applicationContext-hibernate.xml"
overwrite="true">
<fileset dir="src/dao" includes="**/*-hibernate.xml"/>
<filterset refid="variables.to.replace"/>
</copy>
<!-- Copy .properties files in src tree to build/web/classes -->
<copy todir="${build.dir}/web/classes">
<fileset dir="src/web">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
<echo>before war task</echo>
<war destfile="${webapp.dist}/${webapp.war}"
webxml="${webapp.target}/WEB-INF/web.xml" compress="true">
<fileset dir="${webapp.target}"
excludes="**/web.xml,**/*-resources.xml"/>
<metainf dir="${webapp.dist}" includes="context.xml"/>
<classes dir="${build.dir}/web/classes">
<exclude name="**/database.properties"/>
</classes>
<lib file="${dist.dir}/${webapp.name}-dao.jar"/>
<lib file="${dist.dir}/${webapp.name}-service.jar"/>
<webinf dir="web/WEB-INF"
includes="*-resources.xml"/>
<!-- added -->
<webinf dir="${webapp.dist}"
includes="applicationContext-service.xml"/>
<webinf dir="${webapp.dist}"
includes="applicationContext-hibernate.xml"/>
<webinf dir="${struts.dir}" includes="*.xml"/>
<lib file="${clickstream.jar}"/>
<lib dir="${struts.dir}" includes="*.jar"/>
<lib dir="${jstl.dir}/lib">
<include name="jstl.jar"/>
<include name="standard.jar"/>
</lib>
<lib dir="${javamail.dir}" includes="*.jar"/>
<lib file="${log4j.jar}"/>
<lib file="${strutsmenu.jar}"/>
<lib dir="${displaytag.dir}" includes="*.jar"/>
<lib file="${hibernate.jar}"/>
<lib dir="${hibernate.dir}/lib" includes="*.jar"
excludes="jta.jar"/>
<lib dir="${spring.dir}" includes="*.jar"
excludes="*mock.jar"/>
<lib file="${sitemesh.jar}"/>
<lib dir="${velocity.dir}" includes="*.jar"/>
<lib file="${urlrewrite.jar}"/>
</war>
</target>
|
|
Description
|
Sometimes while redeploing Appfuse application in tomcat 5.x (with reloadable="true" in context.xml) I'm getting
the following error in catalina.out :
ERROR [ContainerBackgroundProcessor[StandardEngine[Catalina]]]
ContextLoader.initWebApplicationContext(182) | Context initialization
failed
java.lang.InternalError: jzentry == 0,
jzfile = 141476144,
total = 41,
name = /home/serega/tomcat/webapps/pcc/WEB-INF/lib/pcc-dao.jar,
i = 9,
message = invalid LOC header (bad signature)
at java.util.zip.ZipFile$3.nextElement(ZipFile.java:430)
at java.util.zip.ZipFile$3.nextElement(ZipFile.java:416)
at java.util.jar.JarFile$1.nextElement(JarFile.java:214)
at java.util.jar.JarFile$1.nextElement(JarFile.java:213)
at
org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingJarResources(PathMatchingResourcePatternResolver.java:322)
It can be cured only by restarting tomcat and happens 2 or 3 times a day
on regular basis.
Futher investigations showed that errors happen then spring context files are loaded (it can be seen from stack trace :)).
Workaround
-----------------------
Workaround for this problem is to load context xml files from WEB-INF directory instead of jars.
It can be accomplished with following changes in web.xml and build.xml :
- comment out second config location line in the web-settings.xml
to force Spring use only /WEB-INF files :
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-*.xml
<!-- classpath*:META-INF/applicationContext-*.xml-->
</param-value>
</context-param>
- add the following lines into the package-web ant task before war task:
<copy tofile="${webapp.dist}/applicationContext-service.xml"
overwrite="true">
<fileset dir="src/service" includes="**/*-service.xml"/>
</copy>
<copy tofile="${webapp.dist}/applicationContext-hibernate.xml"
overwrite="true">
<fileset dir="src/dao" includes="**/*-hibernate.xml"/>
<filterset refid="variables.to.replace"/>
</copy>
- and add 2 lines inside the package-web's war task :
<webinf dir="${webapp.dist}"
includes="applicationContext-service.xml"/>
<webinf dir="${webapp.dist}"
includes="applicationContext-hibernate.xml"/>
Below is my modified package-web task :
<target name="package-web" depends="compile-web,jsp-2"
description="Package WAR">
<propertyfile comment="Build Information"
file="${build.dir}/web/classes/build.properties">
<entry key="build.date" type="date" pattern="EEEE MMM dd,
yyyy" value="now"/>
<entry key="build.time" type="date" pattern="hh:mm:ss a zz"
value="now"/>
<entry key="build.username" value="${user.name}"/>
<entry key="build.computer" value="${env.COMPUTERNAME}"/>
<entry key="build.dao.type" value="${dao.type}"/>
<entry key="webapp.version" value="${webapp.version}"/>
</propertyfile>
<!-- If Tomcat 5, uncomment the <dispatcher> elements in
filter-mappings -->
<if>
<or>
<isset property="tomcat5"/>
<isset property="tomcat5.5"/>
</or>
<then>
<replaceregexp flags="g"
file="${webapp.target}/WEB-INF/web.xml"
match='<!--dispatcher>'
replace='<dispatcher>'/>
<replaceregexp flags="g"
file="${webapp.target}/WEB-INF/web.xml"
match='</dispatcher-->'
replace='</dispatcher>'/>
</then>
</if>
<echo>Preparing tomcat-context.xml for inclusion in war</echo>
<!-- Copy tomcat-context.xml file to context.xml -->
<if>
<and>
<isset property="tomcat5"/>
<not><isset property="tomcat5.5"/></not>
</and>
<then>
<copy tofile="${webapp.dist}/context.xml"
file="metadata/conf/tomcat-context.xml"
overwrite="true">
<filterset refid="db.variables"/>
</copy>
</then>
<elseif>
<isset property="tomcat5.5"/>
<then>
<copy tofile="${webapp.dist}/context.xml"
file="metadata/conf/tomcat-context-5.5.xml"
overwrite="true">
<filterset refid="db.variables"/>
</copy>
</then>
</elseif>
</if>
<!-- added -->
<copy tofile="${webapp.dist}/applicationContext-service.xml"
overwrite="true">
<fileset dir="src/service" includes="**/*-service.xml"/>
</copy>
<copy tofile="${webapp.dist}/applicationContext-hibernate.xml"
overwrite="true">
<fileset dir="src/dao" includes="**/*-hibernate.xml"/>
<filterset refid="variables.to.replace"/>
</copy>
<!-- Copy .properties files in src tree to build/web/classes -->
<copy todir="${build.dir}/web/classes">
<fileset dir="src/web">
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
<echo>before war task</echo>
<war destfile="${webapp.dist}/${webapp.war}"
webxml="${webapp.target}/WEB-INF/web.xml" compress="true">
<fileset dir="${webapp.target}"
excludes="**/web.xml,**/*-resources.xml"/>
<metainf dir="${webapp.dist}" includes="context.xml"/>
<classes dir="${build.dir}/web/classes">
<exclude name="**/database.properties"/>
</classes>
<lib file="${dist.dir}/${webapp.name}-dao.jar"/>
<lib file="${dist.dir}/${webapp.name}-service.jar"/>
<webinf dir="web/WEB-INF"
includes="*-resources.xml"/>
<!-- added -->
<webinf dir="${webapp.dist}"
includes="applicationContext-service.xml"/>
<webinf dir="${webapp.dist}"
includes="applicationContext-hibernate.xml"/>
<webinf dir="${struts.dir}" includes="*.xml"/>
<lib file="${clickstream.jar}"/>
<lib dir="${struts.dir}" includes="*.jar"/>
<lib dir="${jstl.dir}/lib">
<include name="jstl.jar"/>
<include name="standard.jar"/>
</lib>
<lib dir="${javamail.dir}" includes="*.jar"/>
<lib file="${log4j.jar}"/>
<lib file="${strutsmenu.jar}"/>
<lib dir="${displaytag.dir}" includes="*.jar"/>
<lib file="${hibernate.jar}"/>
<lib dir="${hibernate.dir}/lib" includes="*.jar"
excludes="jta.jar"/>
<lib dir="${spring.dir}" includes="*.jar"
excludes="*mock.jar"/>
<lib file="${sitemesh.jar}"/>
<lib dir="${velocity.dir}" includes="*.jar"/>
<lib file="${urlrewrite.jar}"/>
</war>
</target> |
Show » |
Sort Order:
|
<webinf dir="${build.dir}/dao/gen/META-INF" includes="*.xml"/>
<webinf dir="${build.dir}/service/classes/META-INF" includes="*.xml"/>