警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property ‘source‘ to ‘org.eclipse.jst.j2ee.server:ServletPro‘ did not find a matching property.
原因:这是因为我们在eclipse下,通过tomcat部署web工程时,tomcat的配置文件server.xml中会自动生成一个关于该web工程的配置信息,类似于下面的东西:
而server.xml的 Context元素不支持名称为source的属性,所以会发出警告
解决方案一:
关闭tomcat,双击eclipse下tomcat服务器,在出来的Tomcat server at localhost页面中找到server options选项,选中其中的选项"Publish modual contexts to separat XML file",保存后重启tomcat,这样重新发布web项目时,就不会将Context添加到server.xml文件中,而是在$CATALINA_BASE/conf/[enginename]/[hostname]/下生成一个[webappname].xml的文件,如下:
ServletPro.xml中的内容如下:
但其实这样启动tomcat后还是会警告,因为tomcat启动时会读取$CATALINA_BASE/conf/[enginename]/[hostname]/下的所有.xml文件(这一点可以参看我的另一篇博客:tomcat启动以及运行时部署应用),结果依旧发现Context元素不支持source属性,因此依旧警告
解决方案二:
This is not an error. This is a warning. The difference is pretty huge. This particular warning basically means that the <Context> element in Tomcat‘s server.xml contains an unknown attribute source and that Tomcat doesn‘t know what to do with this attribute and therefore will ignore it.
Eclipse WTP adds a custom attribute source to the project related <Context> element in the server.xml of Tomcat which identifies the source of the context (the actual project in the workspace which is deployed to the particular server). This way Eclipse can correlate the deployed webapplication with an project in the workspace. Since Tomcat version 6.0.16, any unspecified XML tags and attributes in the server.xml will produce a warning during Tomcat‘s startup, even though there is no DTD nor XSD for server.xml.
Just ignore it. Your web project is fine. It should run fine. This issue is completely unrelated to JSF.
大意其实和上面的差不多,也是Context不支持source属性,这个source属性是Eclipse WTP自定义的一个属性,用来绑定发布的web项目和在workspace中的工程,你可以忽略这个警告,因为它对我们的web项目毫无影响。
tomcat警告:Setting property 'source' to 'org.eclipse.jst.j2ee.server:ServletPro' did not find a matching property