近期在工作中遇到几个问题,使用Spring、Struts和Ibatis进行开发,也用到在后台通过sh文件调用java程序的实现,在发布到服务器的时候遇到如下问题:
1、在发布到测试环境的时候,通过sh文件调用Java程序报如下错误信息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actIntfXmlBeanAction' defined in class path resource [spring-action.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy2] to required type [com.tydic.common.busi.service.ActIntfXmlBeanService] for property 'actIntfXmlBeanService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy2] to required type [com.tydic.common.busi.service.ActIntfXmlBeanService] for property 'actIntfXmlBeanService': no matching editors or conversion strategy found
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy2] to required type [com.tydic.common.busi.service.ActIntfXmlBeanService] for property 'actIntfXmlBeanService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy2] to required type [com.tydic.common.busi.service.ActIntfXmlBeanService] for property 'actIntfXmlBeanService': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy2] to required type [com.tydic.common.busi.service.ActIntfXmlBeanService] for property 'actIntfXmlBeanService': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:224)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:139)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:772)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:606)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:74)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
at org.springframework.beans.factory.support.AbstractBeanFactory.applyPropertyValues(AbstractBeanFactory.java:840)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1026)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:809)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:642)
at com.tydic.appAuto.IFTransfer.IFTransferTest.doLoop(IFTransferTest.java:24)
at com.tydic.appAuto.IFTransfer.IFTransferTest.run(IFTransferTest.java:81)
上述问题通过网上搜索答案可通过如下方式解决,在spring的配置文件添加如下配置:
<property name="proxyTargetClass">
<value>true</value>
</property>
2、在后台调用Java的时候读取配置文件出现如下错误:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 3 in XML document from file [/crm_app/weblog
ic/applications/gx_pms/sh/PMS/WEB-INF/configs/spring-action.xml] is invalid; nested exception is org.xml.sax.SAXParseExc
eption: cvc-elt.1:找不到元素“beans”的声明。
Caused by: org.xml.sax.SAXParseException: cvc-elt.1:找不到元素“beans”的声明。
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
上述问题可通过在path(java调用)中添加如下参数:-Dibm.stream.nio=true
3、去掉日志中显示的如下警告信息:
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
将jar文件中的log4j.properties中配置相应的信息,不显示debug信息的话可以注释掉相应的显debug类别。
4、还出现一个问题,就是如果放一个备份jar文件的话,可能会读取到这个旧的jar文件,但是在开发环境没出现,具体环境的不同不知道是什么问题,所以最好不要放无关的备份jar包文件。