读书人

蛋痛 ssh框架的h4中方言读取不了

发布时间: 2013-01-28 11:49:56 作者: rapoo

蛋疼 ssh框架的h4中方言读取不了
卡两天了 包里也有org.hibernate.dialect.PostgreSQLDialect这个类 但是就是找不到
异常:Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.PostgreSQLDialect;]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:73)
... 57 more
Caused by: java.lang.ClassNotFoundException: org/hibernate/dialect/PostgreSQLDialect;
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:138)
... 58 more
2013-1-22 9:01:08 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
2013-1-22 9:01:08 org.apache.catalina.core.StandardContext startInternal
严重: Context [/s_test1] startup failed due to previous errors
2013-1-22 9:01:08 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2013-1-22 9:01:08 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/s_test1] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2013-1-22 9:01:08 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
2013-1-22 9:01:08 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
2013-1-22 9:01:08 org.apache.catalina.startup.Catalina start
信息: Server startup in 9653 ms
下面是applicationcontext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"

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.5.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-2.5.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.5.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-2.5.xsd

">




<!-- struts配置文件中取得loginaction spring把业务层leeservice注入action中-->
<bean id="LoginAction" class="esw.test.LoginAction" scope="prototype">
<property name="leeService" ref="leeService"/>


</bean>

<!-- 业务逻辑组件 spring把DAO层persondao注入业务层中-->
<bean id="leeService" class= "esw.test.LeeServiceImpl">
<property name="personDao" ref="personDao"></property>
</bean>

<!-- Daobean spring把sessionfactory注入dao层-->
<bean id="personDao" class="esw.test.PersonDaoHibernate">

<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 声明bean -->






<!-- 数据源 tomcat连接池 -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean" >
<property name="jndiName" value="java:comp/env/postgre"/>
</bean>

<!-- sessionfactory代码 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">

<property name="dataSource" ref="dataSource"></property>

<property name="mappingResources">
<list>
<value>Person.hbm.xml</value>
</list>
</property>


<!-- 这种写法为什么有错误?为什么显示红叉? 提示说:cvc-complex-type.2.3: Element 'property' cannot have character [children], because the type's content type is element-only.

<property name="dialect"> org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2dd1.auto">update</property>
<property name="fomat">true</property>
-->



<property name="hibernateProperties">

<value>

hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect;

hibernate.show_sql=true ;

hibernate.hbm2dd1.auto=update;


hibernate.format_sql=true;

</value>
</property>
</bean>




</beans>
ssh 框架 hibernate.dialect bean
[解决办法]

引用:
引用:不知道你用的是不是maven,有的jar包存在,但不一定是需求的那个版本。
我用的都是最新版本hibernate4.2 struts2.3.8 spring3.2 应该是哪个问题?包的冲突?

可以说包的冲突吧。就比如说两个jar包下都有某个类,有可能导入的时候就导入了错误的类。。
当然,这只是我的猜测。。
不是很确定。

读书人网 >Java Web开发

热点推荐