Javax.xml.transform.TransformerFactoryConfigurationError:Provider ORG.APACHE.XALAN.PROCESSOR.TRANSF

Source: Internet
Author: User

Today, when you use the JUNIT4 integration spring to perform unit tests using annotations, the runtime throws a Javax.xml.transform.TransformerFactoryConfigurationError:Provider Org.apache.xalan.processor.TransformerFactoryImpl not found exception. Environment

JUNIT4, Spring 3.0, JDK 1.5.0 update x64, MyEclipse 9.1 (test with anotation) test class original Code

Package Com.cmcc.ha.epm.dao;

Import Org.junit.Before;
Import Org.junit.Test;
Import Org.junit.runner.RunWith;
Import org.springframework.beans.factory.annotation.Autowired;
Import org.springframework.test.context.ContextConfiguration;
Import Org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

Import Com.cmcc.ha.epm.dataprocess.DataAccessFactoryImpl;

/**
 * @author Huayan
 * @author He Mingwang
 * @version 1.0
/@ContextConfiguration (locations = {" Classpath:applicationContext.xml "})
@RunWith (springjunit4classrunner.class) Public
class datafactorytest {

    @Autowired
    private Dataaccessfactoryimpl dataaccessfactory;

    public void Setdataaccessfactory (Dataaccessfactoryimpl dataaccessfactory) {
        this.dataaccessfactory = dataaccessfactory;
    }

    @Before public
    void init () {
        //Here for some initialization code
    }

    @Test public
    void Testmymethod () {
        // Here is the code for calling the method you want to test


Detailed exception Information

[2011-11-29 17:00:08] ERROR testcontextmanager.preparetestinstance (336) | Caught exception while allowing Testexecutionlistener [ ORG.SPRINGFRAMEWORK.TEST.CONTEXT.SUPPORT.DEPENDENCYINJECTIONTESTEXECUTIONLISTENER@27F8922] to prepare test instance [com.cmcc.hn.epm.dao.datafactorytest@3041876] java.lang.IllegalStateException:Failed to load ApplicationContext at Org.springframework.test.context.TestContext.getApplicationContext (testcontext.java:308) at Org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies ( DEPENDENCYINJECTIONTESTEXECUTIONLISTENER.JAVA:109) at Org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance ( DEPENDENCYINJECTIONTESTEXECUTIONLISTENER.JAVA:75) at Org.springframework.test.context.TestContextManager.prepareTestInstance (testcontextmanager.java:333) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest (springjunit4classrunner.java:220) at Org.springframeWork.test.context.junit4.springjunit4classrunner$1.runreflectivecall (springjunit4classrunner.java:301) at Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15) at
	Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock (springjunit4classrunner.java:303) At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (springjunit4classrunner.java:240) at Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:44) at Org.junit.runners.ParentRunner.runChildren (parentrunner.java:180) at org.junit.runners.parentrunner.access$000 ( parentrunner.java:41) at Org.junit.runners.parentrunner$1.evaluate (parentrunner.java:173) at Org.junit.internal.runners.statements.RunBefores.evaluate (runbefores.java:28) at Org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate ( runbeforetestclasscallbacks.java:61) at Org.junit.internal.runners.statements.RunAfters.evaluate (Runafters.java
: 31)	At Org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate ( RUNAFTERTESTCLASSCALLBACKS.JAVA:70) at Org.junit.runners.ParentRunner.run (parentrunner.java:220) at Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (springjunit4classrunner.java:180) at Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:49) at Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197) caused by: Org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.springframework.web.servlet.mvc.annotation.AnnotatioNmethodhandleradapter#0 ': Instantiation of Bean failed; Nested exception is org.springframework.beans.BeanInstantiationException:Could not instantiate Bean class [ Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]: constructor threw exception; Nested exception is Javax.xml.transform.TransformerFactoryConfigurationError:Provider Org.apache.xalan.processor.TransformerFactoryImpl not found at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean ( abstractautowirecapablebeanfactory.java:955) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance ( abstractautowirecapablebeanfactory.java:901) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:485) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:456) at Org.springfraMework.beans.factory.support.abstractbeanfactory$1.getobject (abstractbeanfactory.java:291) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:222) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:288) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:190) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:563) at Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:872) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:423) at Org.springframework.test.context.support.AbstractGenericContextLoader.loadContext ( abstractgenericcontextloader.java:84) at Org.springframework.test.context.support.AbstractGenericConteXtloader.loadcontext (abstractgenericcontextloader.java:1) at Org.springframework.test.context.TestContext.loadApplicationContext (testcontext.java:280) at Org.springframework.test.context.TestContext.getApplicationContext (testcontext.java:304) ... caused by:org.springframework.beans.BeanInstantiationException:Could not instantiate Bean class [ Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]: constructor threw exception; Nested exception is Javax.xml.transform.TransformerFactoryConfigurationError:Provider Org.apache.xalan.processor.TransformerFactoryImpl not found at Org.springframework.beans.BeanUtils.instantiateClass (beanutils.java:141) at Org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate ( SIMPLEINSTANTIATIONSTRATEGY.JAVA:72) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean ( abstractautowirecapablebeanfactory.java:948) ... More caused by:javax.xml.transform.tRansformerfactoryconfigurationerror:provider Org.apache.xalan.processor.TransformerFactoryImpl not found at Javax.xml.transform.TransformerFactory.newInstance (Unknown Source) at Org.springframework.http.converter.xml.abstractxmlhttpmessageconverter.<init> ( abstractxmlhttpmessageconverter.java:47) at Org.springframework.http.converter.xml.SourceHttpMessageConverter. <init> (sourcehttpmessageconverter.java:45) at Org.springframework.http.converter.FormHttpMessageConverter. <init> (formhttpmessageconverter.java:106) at Org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.<init> (
	annotationmethodhandleradapter.java:178) at Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native method) At Sun.reflect.NativeConstructorAccessorImpl.newInstance (nativeconstructoraccessorimpl.java:39) at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (delegatingconstructoraccessorimpl.java:27) at Java.lang.reflect.Constructor.newInstance (Constructor.java:501) at Org.springframework.beans.BeanUtils.instantiateClass (beanutils.java:126) ... More

Solution

Google searches for the keyword "Provider org.apache.xalan.processor.TransformerFactoryImpl not Found", and results are all about Web applications deployed in The exception that occurred while running under Tomcat 5.5, none of the search results was a problem with JUnit integrated spring testing and was eventually CSDN by a post in the Forum (http://topic.csdn.net/t/20030728/19/ 2082133.html), add a VM parameter when you run the test class:

-djavax.xml.transform.transformerfactory=com.sun.org.apache.xalan.internal.xsltc.trax.transformerfactoryimpl

After adding this VM parameter, then executes, runs normally, the test result is also correct, OK.

Attachment: Add VM parameters to Myeclise: Run--> Run configurations ...--> Arguments--> vm Arguments


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.