ssh+oracle开发 部署的时候报错

2009-8-31 4:57:43 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:380)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1112)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:285)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1116)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1214)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Unknown Source)
2009-8-31 4:57:43 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2009-8-31 4:57:43 org.apache.catalina.core.StandardContext start
严重: Context [/guestbook3] startup failed due to previous errors
2009-8-31 4:57:43 org.apache.catalina.core.ApplicationContext log
[b]问题补充:[/b]
这是我的配置文件
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">




com/v512/guestbook/model/Guestbook.hbm.xml




org.hibernate.dialect.Oracle9Dialect










abstract="false" lazy-init="default" autowire="default"
dependency-check="default">




abstract="false" lazy-init="default" autowire="default"
dependency-check="default">




11个回答

要这么写,不能写value,那就代表它是一个字符串类型了

[quote]org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'; [/quote]

Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource'

你看下是不是dataSource类型错了..
而导致'sessionFactory' 错误

/WEB-INF/applicationContext.xml这个文件中'sessionFactory' 的配置粘出来分析

看异常怀疑你的dataSource的注入时出错了
[code="java"] class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

[code="java"][/code]
[/code]

你是不是写成
[code="java"] class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

dataSource[/code]

检查一下吧

[quote]ested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource';[/quote]

无法将你的datasource里配置的字符串转换成javax.sql.DataSource对象,导致SessionFactory无法完成,datasource配置肯定有误,检查[/WEB-INF/applicationContext.xml]文件中的datasource相关的配置。或者贴出来让大家看看。

Oracle一般用OracleThin方式连接数据库,jdbc:oracle:thin:@localhost:1521:orcl。
你用的是DHCP还是c3p0连接池?

顶,本人现在 也在学习sshp

v512 guestbook这些不是都有代码下吗...你照着他给的代码运行,..再看看自己哪里写错了..

[code="java"][/code]
和我猜测的一样!
你配置错了,你这写法Spring会以字符串方式注入,报类型不匹配异常

[size=large][color=darkred] [/color][/size]

[size=large][color=red][/color][/size]

同意~~~


改成

共11条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问