尝试使用我编写的jetty服务器部署战争时,我收到以下错误堆栈。
INFO : jetty.StartJetty - starting jetty using war file ..\serialisation-preview-service\target\serialisation-preview-service-1.3.0-SNAPSHOT.war
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/username/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/username/.m2/repository/org/slf4j/slf4j-log4j12/1.6.2/slf4j-log4j12-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
INFO : org.eclipse.jetty.util.log - jetty-7.2.2.v20101205
INFO : org.eclipse.jetty.util.log - Extract jar:file:/U:/Code/Serialisation_Fresh/serialisation-preview-service/target/serialisation-preview-service-1.3.0-SNAPSHOT.war!/ to C:\Users\username\AppData\Local\Temp\jetty-0.0.0.0-8080-serialisation-preview-service-1.3.0-SNAPSHOT.war-_-any-\webapp
INFO : / - Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri May 22 09:02:37 BST 2015]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@d75e99: defining beans []; root of factory hierarchy
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1958 ms
WARN : org.eclipse.jetty.util.log - FAILED jsp: java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
INFO : / - Initializing Spring FrameworkServlet 'appServlet'
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'appServlet': initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'appServlet-servlet': startup date [Fri May 22 09:02:39 BST 2015]; parent: Root WebApplicationContext
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/servlet-context.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [preview-service-context.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [dao-context.xml]
INFO : org.springframework.beans.factory.config.PropertyPlaceholderConfigurer - Loading properties file from class path resource [placeit.properties]
INFO : org.springframework.beans.factory.config.PropertyOverrideConfigurer - Loading properties file from class path resource [preview-server-overrideDEV.properties]
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@d61b48: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,myController,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,previewServerPropertyOverride,org.springframework.beans.factory.config.PropertyOverrideConfigurer#0,labelService,placeit.SerialDataCSVGenerator#0,placeit.DataMatrixGenerator#0,org.springframework.expression.spel.standard.SpelExpressionParser#0,printers,ftp.FtpEmulator#0,placeitPreviewProcess,placeitLabelProcess,placeitHapaProcess,hgdlCompiler,util.DateServiceImpl#0,org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor,org.springframework.scheduling.support.PeriodicTrigger#0,poller,JobFileCreator,rendezvous,PreviewService,org.springframework.integration.transformer.HeaderEnricher#0,org.springframework.integration.transformer.MessageTransformingHandler#0,writeFiles,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,writeFiles2,limitJobs,org.springframework.integration.router.RecipientListRouter#0,writeJobRouter,org.springframework.integration.config.ServiceActivatorFactoryBean#0,createJobFile,createJobFileSA,org.springframework.integration.transformer.HeaderEnricher#1,org.springframework.integration.transformer.MessageTransformingHandler#1,writeJobFile,org.springframework.integration.config.ConsumerEndpointFactoryBean#1,writeJobFile2,org.springframework.integration.file.config.FileWritingMessageHandlerFactoryBean#0,writeJobFile2.adapter,org.springframework.integration.transformer.HeaderEnricher#2,org.springframework.integration.transformer.MessageTransformingHandler#2,writeFmtFile,org.springframework.integration.config.ConsumerEndpointFactoryBean#2,writeFmtFile2,org.springframework.integration.file.config.FileWritingMessageHandlerFactoryBean#1,writeFmtFile2.adapter,org.springframework.integration.config.ServiceActivatorFactoryBean#1,waitForReply,org.springframework.integration.config.ConsumerEndpointFactoryBean#3,generatedPreviewFile,org.springframework.integration.file.config.FileListFilterFactoryBean#0,org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0,generatedPreviewFile.adapter,org.springframework.integration.config.TransformerFactoryBean#0,org.springframework.integration.config.ConsumerEndpointFactoryBean#4,org.springframework.integration.config.ServiceActivatorFactoryBean#2,deliverReply,org.springframework.integration.config.ConsumerEndpointFactoryBean#5,aggregationDaoImpl,notificationDaoImpl,parametersDaoImpl,serialisationDaoImpl,templatePreviewDaoImpl,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,entityManagerFactory,org.springframework.jdbc.core.JdbcTemplate#0,org.springframework.jdbc.core.simple.SimpleJdbcTemplate#0,dataSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0,nullChannel,errorChannel,_org.springframework.integration.errorLogger,taskScheduler]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@d75e99
INFO : org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Initializing ExecutorService 'taskScheduler'
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@d61b48: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,myController,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,previewServerPropertyOverride,org.springframework.beans.factory.config.PropertyOverrideConfigurer#0,labelService,placeit.SerialDataCSVGenerator#0,placeit.DataMatrixGenerator#0,org.springframework.expression.spel.standard.SpelExpressionParser#0,printers,ftp.FtpEmulator#0,placeitPreviewProcess,placeitLabelProcess,placeitHapaProcess,hgdlCompiler,util.DateServiceImpl#0,org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor,org.springframework.scheduling.support.PeriodicTrigger#0,poller,JobFileCreator,rendezvous,PreviewService,org.springframework.integration.transformer.HeaderEnricher#0,org.springframework.integration.transformer.MessageTransformingHandler#0,writeFiles,org.springframework.integration.config.ConsumerEndpointFactoryBean#0,writeFiles2,limitJobs,org.springframework.integration.router.RecipientListRouter#0,writeJobRouter,org.springframework.integration.config.ServiceActivatorFactoryBean#0,createJobFile,createJobFileSA,org.springframework.integration.transformer.HeaderEnricher#1,org.springframework.integration.transformer.MessageTransformingHandler#1,writeJobFile,org.springframework.integration.config.ConsumerEndpointFactoryBean#1,writeJobFile2,org.springframework.integration.file.config.FileWritingMessageHandlerFactoryBean#0,writeJobFile2.adapter,org.springframework.integration.transformer.HeaderEnricher#2,org.springframework.integration.transformer.MessageTransformingHandler#2,writeFmtFile,org.springframework.integration.config.ConsumerEndpointFactoryBean#2,writeFmtFile2,org.springframework.integration.file.config.FileWritingMessageHandlerFactoryBean#1,writeFmtFile2.adapter,org.springframework.integration.config.ServiceActivatorFactoryBean#1,waitForReply,org.springframework.integration.config.ConsumerEndpointFactoryBean#3,generatedPreviewFile,org.springframework.integration.file.config.FileListFilterFactoryBean#0,org.springframework.integration.file.config.FileReadingMessageSourceFactoryBean#0,generatedPreviewFile.adapter,org.springframework.integration.config.TransformerFactoryBean#0,org.springframework.integration.config.ConsumerEndpointFactoryBean#4,org.springframework.integration.config.ServiceActivatorFactoryBean#2,deliverReply,org.springframework.integration.config.ConsumerEndpointFactoryBean#5,aggregationDaoImpl,notificationDaoImpl,parametersDaoImpl,serialisationDaoImpl,templatePreviewDaoImpl,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,entityManagerFactory,org.springframework.jdbc.core.JdbcTemplate#0,org.springframework.jdbc.core.simple.SimpleJdbcTemplate#0,dataSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0,nullChannel,errorChannel,_org.springframework.integration.errorLogger,taskScheduler]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@d75e99
INFO : org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler - Shutting down ExecutorService 'taskScheduler'
ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.TemplatePreviewDao controllers.PreviewHttpController.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'templatePreviewDaoImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [dao-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [dao-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [dao-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:609)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:623)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:491)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:432)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:432)
at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:260)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:762)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:244)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1181)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:584)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:496)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:226)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:93)
at org.eclipse.jetty.server.Server.doStart(Server.java:243)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
at jetty.StartJetty.main(StartJetty.java:56)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private dao.TemplatePreviewDao controllers.PreviewHttpController.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'templatePreviewDaoImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [dao-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [dao-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:504)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'templatePreviewDaoImpl': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [dao-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [dao-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:343)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:476)
... 34 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [dao-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [dao-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:531)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:497)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:658)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:631)
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.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:340)
... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [dao-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 61 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'password' of bean class [org.springframework.jndi.JndiObjectFactoryBean]: Bean property 'password' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1031)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:902)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
... 69 more
这是它与EntityManager定义抱怨的TemplatePreview类:
@Repository
public class TemplatePreviewDaoImpl implements TemplatePreviewDao {
@PersistenceContext private EntityManager entityManager;
// ...
}
这是我的一个带有bean声明的项目上下文文件:
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven mode="proxy" transaction-manager="transactionManager"/>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceXmlLocation" value="classpath:/META-INF/persistenceOracle.xml"/>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
</property>
</bean>
<bean class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
<bean class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" >
<property name="jndiName" value="java:comp/env/DS_SERIALISATION"/>
</bean>
包含dataSource信息的属性文件的内容:
dataSource.url=jdbc:oracle:thin:@correct_url
dataSource.username=************
dataSource.password=************
dataSource.driverClassName=oracle.jdbc.OracleDriver
entityManagerFactory.persistenceXmlLocation=classpath:/META-INF/persistenceOracle.xml
rendezvous.timeout=-1
这里提到的persistenceOracle xml文件也是可访问的,所以我不认为这是一个问题。我不知道为什么Spring无法自动连接依赖项或者为什么我的dataSource出现问题。对此有任何帮助将非常感激。
修改的
我的覆盖文件存在于一个单独的项目中,但我无法确定我的战争项目是否知道它。包含属性文件的项目没有src文件夹或任何其他内容,因此我无法将其添加到war项目的类路径中。
我在运行配置中将DEV作为VM参数传递,在查找正确的属性文件时会附加它。
答案 0 :(得分:2)
我的想法是你的dataSource只是简单地实例化一个JndiObjectFactoryBean类型的对象,然后将其传递到整个地方,直到Spring的某个地方尝试注入属性“password”,它发现没有属性JndiObjectFactoryBean对象的“密码”。
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" >
<property name="jndiName" value="java:comp/env/DS_SERIALISATION"/>
</bean>
JNDI是一个api,它允许您通过名称访问目录(请参阅教程here)。它应该根据您提供的jndiName执行JNDI查找,而不是返回JndiObjectFactoryBean对象。
我认为你需要告诉JndiObjectFactoryBean进行查找并将JNDI结果作为Spring Bean返回。请考虑以下示例。
Spring配置:
<bean id="jndiLookup" class="org.springframework.jndi.JndiObjectLocator">
<property name="jndiName" value="java:comp/env/DS_SERIALISATION"/>
</bean>
<bean id="dataSource" class="com.mypackage.DataSourceLocator">
<property name="jndi" ref="jndiLookup"/>
</bean>
自定义静态工厂以从jndi查找获取对象:
public class DataSourceLocator {
public JndiObjectLocator jndi;
public static Object lookup() {
return jndi.lookup();
}
}
Theres可能是一个更好的方式,但是当谈到jndi时我不是专家!
答案 1 :(得分:1)
在尝试了很多事情之后我决定尝试这个:
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="org.h2.Driver"/>
<property name="url" value="jdbc:h2:mem:"/>
<property name="username" value="sa"/>
<property name="password" value=""/>
<property name="testOnBorrow" value="true"/>
<property name="testWhileIdle" value="true"/>
<property name="timeBetweenEvictionRunsMillis" value="300000"/>
似乎要做的伎俩。不确定为什么Jndi不起作用:S