package com.test.common;
import junit.framework.TestCase;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import org.springframework.orm.hibernate3.SessionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;
public class AbstractBaseTestCase extends TestCase {
protected ClassPathXmlApplicationContext app;
private SessionFactory sessionFactory;
protected void setUp() throws Exception {
app = new ClassPathXmlApplicationContext("classpath*:/applicationContext.xml");
super.setUp();
sessionFactory = (SessionFactory) app.getBean("SesinFtry");
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
}
protected void tearDown() throws Exception {
super.tearDown();
SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
SessionFactoryUtils.closeSession(sessionHolder.getSession());
app.close();
}
}
package com.test.common;
import java.util.List;
import com.chenyu.xmgl.service.XmglXmwhService;
public class CommTest extends AbstractBaseTestCase {
public void testSpring() throws Exception{
XmglService xmglService=(XmglService)app.getBean("xmglService");
List list= xmgService.getDmXmzt();
System.out.println(list.size());
}
}
解决
Unable to validate using XSD 收藏
现象:
org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from URL [jar:file:/home/admin/jboss/server/deploy/common-lib/esb-core-1.4.0.jar!/META-INF/esb-server.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@1175422] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
原因:
缺少依赖jar包 或者 jdk版本过低
处理方法:
1.确认jdk版本
2.下载Xerces-J-bin.2.9.1.tar.gz
wget http://xml.apache.org/dist/xerces-j/Xerces-J-bin.2.9.1.tar.gz
tar zfxv Xerces-J-bin.2.9.1.tar.gz
copy 其中的2个文件 xercesImpl.jar ,xml-apis.jar 至对应lib目录
详细参考网址:http://blog.csdn.net/gentlepine/archive/2009/12/03/4923097.aspx