首先记录一下如何解决此章节CD中附带的helloapp无法启动的问题
我用的tomcat版本是:7.0.47;为了便于控制,针对此章节的helloapp,我在tomcat/conf/Catalina/localhost中定义了helloapp6.xml文件,内容是:
<Context path="/helloapp6" docBase="/media/Develop/WEB_Develop/TomCat+JAVADEV_CD/data/sourcecode/chapter06/helloapp" reloadable="true"/>,即实际helloapp文件位于/media/Develop/WEB_Develop/TomCat+JAVADEV_CD/data/sourcecode/chapter06/helloapp目录
然后,启动tomcat,却发现此helloapp6无法启动。查看日志,发现有报错:
通过查资料,找到如下解决方法:
在/media/Develop/WEB_Develop/TomCat+JAVADEV_CD/data/sourcecode/chapter06/helloapp/src目录中建立文件:org/apache/AnnotationProcessor.java,其内容为:package org.apache;import java.lang.reflect.InvocationTargetException;import javax.naming.NamingException;public interface AnnotationProcessor { public void postConstruct(Object instance) throws IllegalAccessException, InvocationTargetException; public void preDestroy(Object instance) throws IllegalAccessException, InvocationTargetException; public void processAnnotations(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException;}
然后编译此文件,得到org/apache/AnnotationProcessor.class文件,在把此文件移位到:/media/Develop/WEB_Develop/TomCat+JAVADEV_CD/data/sourcecode/chapter06/helloapp/WEB-INF/classes/org/apache中即可
然后,重新启动tomcat,则helloapp6就可以正常启动了