I have a Spring MVC project(contains Controller & jsp files)
and DAO project(Contains DB operation related files)
& both the project are configured using annotations. MVC project depends on DAO project. Now, I am writing JUnit test for MVC and DAO projects. Hence I have created a separate 'Test project' in which I have added MVC project as dependency(Java Build Path -> Projects tab -> Add -> MVC Project & ok)
and included all needed jar files (JUnit & spring-test.jar). I am using RAD IDE, Spring 3, JUnit4 & Websphere application server (version 7)
.
My project structure:
MVCProject (Depends on DAOProject --> Web App project)
|
WebContent
|
WEB-INF
|
spring-context.xml
DAOProject (Java project)
|
src
TestProject(Depends on MVCProject --> Java project)
|
src
|
com.xyz.dao.test
|
DAOImplTest.java
|
config
|
test-spring-context.xml
I copied contents of spring-context.xml file into test-spring-context.xml. Below is my JUnit test project code,
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:config/test-spring-context.xml"})
public class DAOImplTest {
@Autowired
private DAO dao;
String id = null;
/**
* Test method for {@link com.xyz.core.dao.DAOImpl#getById(java.lang.String)}.
*/
@Test
public void testGetById() {
id = "Test12345";
try {
dao.getById(id);
} catch (Exception e) {
e.printStackTrace();
}
}
}
I am getting following error when try to run test case (The XMLInputFactory does not recognize the property "reuse-instance"
).
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'imageHandler' defined in file [D:\Workspace\MVCProjectName\WebContent\WEB-INF\classes\com\xyz\web\webservice\ImageHandlerImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.xyz.webservice.ImageHandlerImpl]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The XMLInputFactory does not recognize the property "reuse-instance".
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
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:194)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:435)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:409)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:541)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:147)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:297)
... 64 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.xyz.webservice.ImageHandlerImpl]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: The XMLInputFactory does not recognize the property "reuse-instance".
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
... 77 more
Caused by: java.lang.IllegalArgumentException: The XMLInputFactory does not recognize the property "reuse-instance".
at com.ibm.xml.xlxp.api.stax.msg.StAXMessageProvider.throwIllegalArgumentException(StAXMessageProvider.java:42)
at com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl.setProperty(XMLInputFactoryImpl.java:1870)
at org.apache.axiom.util.stax.dialect.SJSXPDialect.makeThreadSafe(SJSXPDialect.java:65)
at org.apache.axiom.om.util.StAXUtils$8.run(StAXUtils.java:544)
at java.security.AccessController.doPrivileged(AccessController.java:229)
at org.apache.axiom.om.util.StAXUtils.newXMLInputFactory(StAXUtils.java:517)
at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory_perClassLoader(StAXUtils.java:588)
at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:171)
at org.apache.axiom.om.util.StAXUtils.getXMLInputFactory(StAXUtils.java:136)
at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:223)
at org.apache.axiom.om.util.StAXUtils.createXMLStreamReader(StAXUtils.java:217)
at org.apache.axis2.util.XMLUtils.toOM(XMLUtils.java:555)
at org.apache.axis2.deployment.DescriptionBuilder.buildOM(DescriptionBuilder.java:93)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:76)
at org.apache.axis2.deployment.DeploymentEngine.populateAxisConfiguration(DeploymentEngine.java:640)
at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:105)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:60)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:174)
at org.apache.axis2.jaxws.ClientConfigurationFactory.getClientConfigurationContext(ClientConfigurationFactory.java:51)
at org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl.createServiceDescription(DescriptionFactoryImpl.java:74)
at org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescription(DescriptionFactory.java:67)
at org.apache.axis2.jaxws.spi.ServiceDelegate.<init>(ServiceDelegate.java:84)
at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:45)
at javax.xml.ws.Service.<init>(Service.java:57)
at com.xyz.handler.broker.ImageHandlerService.<init>(ImageHandlerService.java:39)
at com.xyz.handler.broker.ImageHandlerProxy$Descriptor.<init>(ImageHandlerProxy.java:21)
at com.xyz.handler.broker.ImageHandlerProxy.<init>(ImageHandlerProxy.java:69)
at com.xyz.webservice.ImageHandlerImpl.<init>(ImageHandlerImpl.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 79 more
Kindly help me resolving this issue.
Thanks in Advance.
Folks,
I am able to resolve the issue.
This problem occurs when my
RAD JRE System library set to jdk7
and so it is resolved by setting RAD'JRE System library' to 'JavaSE-1.6'
(Properties --> Libraries tab --> JRE System library --> Click edit & set JavaSE-1.6).The reason might be jar conflict between sun jdk7, IBM(xml.jar) and apache axiom versions (Not sure but as far as I googled ended up with this assumption).
Hope it helps someone facing similar issue.
Happy learning.