hibernate映射文件写错可能引起的错误

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

	<bean id="dts" class="com.mchange.v2.c3p0.ComboPooledDataSource">

		<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
		<property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:pkwork"></property>
		<property name="user" value="pk"></property>
		<property name="password" value="pk"></property>
		<property name="maxPoolSize" value="100"></property>
		<property name="minPoolSize" value="20"></property>
		<property name="maxIdleTime" value="2000"></property>
	</bean>

	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

		<property name="dataSource" ref="dts"></property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
				<prop key="hibernate.show_sql">true</prop>  
                <prop key="hibernate.format_sql">true</prop>	
			</props>
		</property>
		<property name="mappingResources">
			<list>
				<value>com/peaw/bean/User.hbm.xml</value>
				<value>com/peaw/bean/Admin.hbm.xml</value>
				<value>com/peaw/bean/Accountbook.hbm.xml</value>
				<value>com/peaw/bean/Addresslist.hbm.xml</value>
				<value>com/peaw/bean/Bookmark.hbm.xml</value>
				<value>com/peaw/bean/Bookshelf.hbm.xml</value>
				<value>com/peaw/bean/Comment.hbm.xml</value>
			
				<value>com/peaw/bean/Essay.hbm.xml</value>
				<value>com/peaw/bean/Grow.hbm.xml</value>
				<value>com/peaw/bean/Memorandum.hbm.xml</value>
				<value>com/peaw/bean/Message.hbm.xml</value>
				<value>com/peaw/bean/Note.hbm.xml</value>
				<value>com/peaw/bean/Photoalbum.hbm.xml</value>
				<value>com/peaw/bean/Recyclebin.hbm.xml</value>
				<value>com/peaw/bean/Udrive.hbm.xml</value>
				
					<value>com/peaw/bean/Diary.hbm.xml</value>
			</list>
		</property>

	</bean>

	<bean id="sysdao" abstract="true">
		<property name="sef" ref="sessionFactory"></property>
	</bean>

	<bean id="accountbookdao" class="com.peaw.dao.AccountbookDAO" parent="sysdao"></bean>
	<bean id="addresslistdao" class="com.peaw.dao.AddresslistDAO" parent="sysdao"></bean>
	<bean id="admindao" class="com.peaw.dao.AdminDAO" parent="sysdao"></bean>
	<bean id="bookmarkdao" class="com.peaw.dao.BookmarkDAO" parent="sysdao"></bean>
	<bean id="bookshelfdao" class="com.peaw.dao.BookshelfDAO" parent="sysdao"></bean>
	<bean id="commentdao" class="com.peaw.dao.CommentDAO" parent="sysdao"></bean>
	<bean id="diarydao" class="com.peaw.dao.DiaryDAO" parent="sysdao"></bean>
	<bean id="essaydao" class="com.peaw.dao.EssayDAO" parent="sysdao"></bean>
	<bean id="growdao" class="com.peaw.dao.GrowDAO" parent="sysdao"></bean>
	<bean id="memorandumdao" class="com.peaw.dao.MemorandumDAO" parent="sysdao"></bean>
	<bean id="messagedao" class="com.peaw.dao.MessageDAO" parent="sysdao"></bean>
	<bean id="notedao" class="com.peaw.dao.NoteDAO" parent="sysdao"></bean>
	<bean id="photoalbumdao" class="com.peaw.dao.PhotoalbumDAO" parent="sysdao"></bean>
	<bean id="recyclebindao" class="com.peaw.dao.RecyclebinDAO" parent="sysdao"></bean>
	<bean id="udrivedao" class="com.peaw.dao.UdriveDAO" parent="sysdao"></bean>
	<bean id="userdao" class="com.peaw.dao.UserDAO" parent="sysdao"></bean>


	<bean id="systemservice" class="com.peaw.service.SystemService">
		<property name="mp">
			<map>
				<entry key="Admin" value-ref="admindao"></entry>
				<entry key="User" value-ref="userdao"></entry>
				<entry key="Accountbook" value-ref="accountbookdao"></entry>
				<entry key="Addresslist" value-ref="addresslistdao"></entry>
				<entry key="Bookmark" value-ref="bookmarkdao"></entry>
				<entry key="Bookshelf" value-ref="bookshelfdao"></entry>
				<entry key="Comment" value-ref="commentdao"></entry>
				<entry key="Diary" value-ref="diarydao"></entry>
				<entry key="Essay" value-ref="essaydao"></entry>
				<entry key="Grow" value-ref="growdao"></entry>
				<entry key="Memorandum" value-ref="memorandumdao"></entry>
				<entry key="Message" value-ref="messagedao"></entry>
				<entry key="Note" value-ref="notedao"></entry>
				<entry key="Photoalbum" value-ref="photoalbumdao"></entry>
				<entry key="Recyclebin" value-ref="recyclebindao"></entry>
				<entry key="Udive" value-ref="udrivedao"></entry>
				
			</map>
		</property>
	</bean>
	
	<bean id="vh" class="com.peaw.tool.ViewHelper" scope="session" >
		<property name="service" ref="systemservice"></property>
	</bean>

	<bean id="logAction" class="com.peaw.action.LogAction" scope="prototype">
		<property name="service" ref="systemservice"></property>
	</bean>
	
	
	
</beans>


 

报错信息截选

 

2014-2-25 16:52:30org.apache.catalina.core.StandardContext listenerStart

严重: Exception sending context initialized event to listener instanceof class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'sessionFactory' defined in ServletContextresource [/WEB-INF/classes/applicationContext.xml]: Invocation of init methodfailed; nested exception is java.lang.StringIndexOutOfBoundsException: Stringindex out of range: 0

         atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)

         atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)

         atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)

         atjava.security.AccessController.doPrivileged(Native Method)

         atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)

         atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)

         atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

         atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)

         atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)

         atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)

         atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)

         atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)

         atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)

         atorg.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)

         atorg.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)

         atorg.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)

         atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)

         atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4705)

         atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)

         atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)

         atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)

         atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)

         atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)

         atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)

         atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)

         atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)

         atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)

         atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)

         atorg.apache.catalina.core.StandardHost.start(StandardHost.java:840)

         atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)

         atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

         atorg.apache.catalina.core.StandardService.start(StandardService.java:525)

         atorg.apache.catalina.core.StandardServer.start(StandardServer.java:754)

         atorg.apache.catalina.startup.Catalina.start(Catalina.java:595)

         atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

         atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

         atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

         atjava.lang.reflect.Method.invoke(Method.java:597)

         atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

         atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by:java.lang.StringIndexOutOfBoundsException: String index out of range: 0

         atjava.lang.String.charAt(String.java:686)

         atorg.hibernate.mapping.Table.setName(Table.java:172)

         atorg.hibernate.cfg.Mappings.addTable(Mappings.java:190)

         atorg.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:312)

         atorg.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)

         atorg.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)

         atorg.hibernate.cfg.Configuration.add(Configuration.java:702)

         atorg.hibernate.cfg.Configuration.addInputStream(Configuration.java:537)

         atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:631)

         atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)

         atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)

         atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)

         ...39 more

2014-2-25 16:52:30org.apache.catalina.core.StandardContext start

严重: Error listenerStart

2014-2-25 16:52:30org.apache.catalina.core.StandardContext start

严重: Context [/PEAW] startup failed due to previous errors

2014-2-25 16:52:30org.apache.catalina.core.ApplicationContext log

信息: Closing Spring root WebApplicationContext

2014-2-25 16:52:30org.apache.catalina.startup.HostConfig deployDirectory

信息: Deploying web application directory ROOT

2014-2-25 16:52:30 org.apache.coyote.http11.Http11AprProtocolstart

信息: Starting Coyote HTTP/1.1 on http-8088

2014-2-25 16:52:30org.apache.coyote.ajp.AjpAprProtocol start

信息: Starting Coyote AJP/1.3 on ajp-8009

2014-2-25 16:52:30org.apache.catalina.startup.Catalina start

信息: Server startup in 3806 ms

 

 

这次解决方案:

检查applicationContext.xml文件,没有发现任何错误

上网搜索之后,得到其中一条建议是检查hibernate映射文件中,是否是表结构出现错误。

然后逐个删除和恢复文件中对xxx.hbm.xml文件的引用。

最终发现问题,是因为一个文件中,table属性没有明确指定表。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值