Weblogic部署CAS3.5问题解决方案
- - ITeye博客webLogic版本:10.3.6.0. cas服务端版本:3.5.2.1. 部署一套SSO环境,选用CAS最新版做为服务端,在开发阶段选用Tomcat6做为应用容器未出现任何问题,业务功能整合完毕后准备将CAS服务端移植到weblogic环境下,然后问题出现了. 在整个部署过程中,主要遇到两个问题. 
Caused By: java.io.FileNotFoundException: class path resource [log4j.xml] cannot be resolved to absolute file path because it does not reside in the file system: zip:/home/weblogic/Oracle/Middleware/user_projects/domains/yourdomain/servers/AdminServer/tmp/_WL_user/authServer2/gksqn0/war/WEB-INF/lib/_wl_cls_gen.jar!/log4j.xml
Caused By: javax.servlet.ServletException: weblogic.servlet.jsp.CompilationException: Failed to compile JSP /WEB-INF/view/jsp/default/ui/casLoginView.jsp casLoginView.jsp:1:1: The validator class: "org.apache.taglibs.standard.tlv.JstlCoreTLV" has failed with the following exception: "java.lang.ClassCastException: weblogic.xml.jaxp.RegistrySAXParserFactory cannot be cast to javax.xml.parsers.SAXParserFactory". <jsp:directive.include file="includes/top.jsp" /> ^-----------------------------------------------^
/**
 * 自定义LOG4J启动类
 * cas打成WAR包部署到weblogic上因找不到log4j.xml文件而出错
 * @author zz
 */
public class Log4jInit extends HttpServlet {
 public void init() throws ServletException {
  String file = getInitParameter("log4j");
  System.out.println("...........log4j start");
  if(null != file) {
   Properties ps=new Properties();
    try {
    ps.load(getServletContext().getResourceAsStream(file));
    } catch (IOException e) {
    e.printStackTrace();
    }
    PropertyConfigurator.configure(ps);
  }
 }
}
 然后配置到web.xml中,并设置优先加载。
<servlet> <servlet-name>log4jLoader</servlet-name> <servlet-class>com.zz.util.Log4jInit</servlet-class> <init-param> <param-name>log4j</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet>这里我将默认的log4j.xml转换成了log4j.properties文件。
<!-- 
<bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
  <property name="targetClass" value="org.springframework.util.Log4jConfigurer"/>
  <property name="targetMethod" value="initLogging"/>
  <property name="arguments">
    <list>
      <value>${log4j.config.location:classpath:log4j.xml}</value>
      <value>${log4j.refresh.interval:60000}</value>
    </list>
  </property>
</bean>
-->
 至此,针对找不到log4j配置文件的问题得以解决,为了方便以后的部署工作,我采用的是第二种解决方案,也就是WAR包形式进行部署。