在我的项目中,我一直在使用Spring3和Hibernate4。我已经添加了支持Spring3和Hibernate4项目的所有依赖项。我并不特定于hibernate上的版本,但它应该支持Spring3。
当我尝试在Tomcat7项目上部署时,我得到了以下异常。
原因:org。springframework。豆。工厂BeanCreationException:无法自动关联字段:私有组织。冬眠SessionFactory com。高级kgvk。乌提尔斯。SessionFactoryImpl。会期工厂;嵌套的异常是org。springframework。豆。工厂BeanCreationException:创建名为“sessionFactory”的bean时出错,该bean在ServletContext资源[/WEB-INF/HelloWeb servlet.xml]中定义:调用init方法失败;嵌套的异常是java。lang.CompatibleClassChangeError:在组织上实现类。springframework。豆。工厂注释。AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement。在org上注入(autowirednotationbeanpstoprocessor.java:514)。springframework。豆。工厂注释。注入元数据。在org上注入(InjectionMetadata.java:87)。springframework。豆。工厂注释。AutowiredNotationBeanPostProcessor。后处理属性值(AutoWiredNotationBeanPostProcessor.java:285)。。。68更多的原因是:org。springframework。豆。工厂BeanCreationException:创建名为“sessionFactory”的bean时出错,该bean在ServletContext资源[/WEB-INF/HelloWeb servlet.xml]中定义:调用init方法失败;嵌套的异常是java。lang.CompatibleClassChangeError:在组织上实现类。springframework。豆。工厂支持AbstractAutowireCapableBeanFactory。在org上初始化ebean(AbstractAutowireCapableBeanFactory.java:1482)。springframework。豆。工厂支持AbstractAutowireCapableBeanFactory。org上的doCreateBean(AbstractAutowireCapableBeanFactory.java:521)。springframework。豆。工厂支持AbstractAutowireCapableBeanFactory。在org上创建Bean(AbstractAutowireCapableBeanFactory.java:458)。springframework。豆。工厂支持AbstractBeanFactory 1美元。org上的getObject(AbstractBeanFactory.java:295)。springframework。豆。工厂支持DefaultSingletonBeanRegistry。getSingleton(DefaultSingletonBeanRegistry.java:223)位于org。springframework。豆。工厂支持抽象工厂。org上的doGetBean(AbstractBeanFactory.java:292)。springframework。豆。工厂支持抽象工厂。org上的getBean(AbstractBeanFactory.java:194)。springframework。豆。工厂支持DefaultListableBeanFactory。在org上查找Dautowire候选者(DefaultListableBeanFactory.java:912)。springframework。豆。工厂支持DefaultListableBeanFactory。doResolveDependency(DefaultListableBeanFactory.java:855)位于org。springframework。豆。工厂支持DefaultListableBeanFactory。org上的resolveDependency(DefaultListableBeanFactory.java:770)。springframework。豆。工厂注释。AutoWiredNotationBeanPostProcessor$AutoWiredFeldElement。注入(AutowiredNotationBeanPostProcessor.java:486)。。。70多个原因:java。lang.CompatibleClassChangeError:在java上实现类。lang.ClassLoader。在java上定义Class1(本机方法)。lang.ClassLoader。在java上定义类(ClassLoader.java:800)。安全SecureClassLoader。在org上定义类(SecureClassLoader.java:142)。阿帕奇。卡塔琳娜。加载器。WebappClassLoader。findClassInternal(WebappClassLoader.java:2957)位于org。阿帕奇。卡塔琳娜。加载器。WebappClassLoader。位于org的findClass(WebappClassLoader.java:1210)。阿帕奇。卡塔琳娜。加载器。WebappClassLoader。位于org的loadClass(WebappClassLoader.java:1690)。阿帕奇。卡塔琳娜。加载器。WebappClassLoader。java上的loadClass(WebappClassLoader.java:1571)。朗朗,上课。java上的getDeclaredConstructors0(本机方法)。朗朗,上课。java上的privateGetDeclaredConstructors(Class.java:2585)。朗朗,上课。java上的getConstructor0(Class.java:2885)。朗朗,上课。位于org的getDeclaredConstructor(Class.java:2058)。springframework。豆。小海狸。实例化org上的eclass(BeanUtils.java:105)。springframework。奥姆。冬眠3。LocalSessionFactoryBean。org上的新配置(LocalSessionFactoryBean.java:779)。springframework。奥姆。冬眠3。LocalSessionFactoryBean。buildSessionFactory(LocalSessionFactoryBean.java:561)位于org。springframework。奥姆。冬眠3。AbstractSessionFactoryBean。AfterPropertieSet(AbstractSessionFactoryBean.java:134)位于org。springframework。豆。工厂支持AbstractAutowireCapableBeanFactory。org上的invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)。springframework。豆。工厂支持AbstractAutowireCapableBeanFactory。initializeBean(AbstractAutowireCapableBeanFactory.java:1479)。。。80多
Nov 29, 2014 3:53:58 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /mvc threw load() exception
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
at java.lang.Class.getConstructor0(Class.java:2885)
at java.lang.Class.getDeclaredConstructor(Class.java:2058)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:105)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newConfiguration(LocalSessionFactoryBean.java:779)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:561)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
Spring Configuration file for hibernate4
<?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:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:component-scan base-package="com.sr.kgvk" />
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="jspViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:db.properties" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.databaseurl}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">hibernate-ehcache.xml</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.use_structured_entries">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven/>
</beans>
Here is the Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>webproject</groupId>
<artifactId>mvc</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>mvc</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<spring.version>3.2.4.RELEASE</spring.version>
<spring.security.version>3.2.4.RELEASE</spring.security.version>
<junit.version>4.11</junit.version>
<failsafe.plugin.version>2.16</failsafe.plugin.version>
<jstl.version>1.2</jstl.version>
<mysql-connector-java.version>5.1.29</mysql-connector-java.version>
<spring-tx.version>4.0.1.RELEASE</spring-tx.version>
<spring-jdbc.version>4.0.1.RELEASE</spring-jdbc.version>
</properties>
<build>
<finalName>mvc</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/config</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<!-- <path>/${project.artifactId}</path> -->
<path>/</path>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>${failsafe.plugin.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
build-helper-maven-plugin
</artifactId>
<versionRange>
[1.7,)
</versionRange>
<goals>
<goal>add-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.29</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.2.6.Final</version>
</dependency>
</dependencies>
</project>
Please help me here at the earliest. I got stuck on this error.
Thanks
Ravi
mv.ravikumarece@gmail.com
但是组织。springframework。奥姆。冬眠3。LocalSessionFactory是spring orm的一部分。罐子,对吗?以及spring版本3.2。4.释放
你怎么说呢?
从stacktrace可以很清楚地看到,sessionFactory的类兼容性存在问题。
您正在使用Hibernate4,并且您的class属性标签包含hiberate 3的类引用。
将sessionFactory声明更改为:
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
...........
困惑: 对我来说没有代码段工作,每次我面对404,我想我错过了什么?
问题内容: 他们幸福地结婚了吗? 我正在使用最新版本的hibernate(4)和1.3版的joda-time hibernate支持,我也相信这是当前的最新版本。 使用批注时,一切似乎都正常(按预期方式创建了日期列): 一起使用这些版本是否存在任何已知问题? Update Well证明已创建列,但无法填充任何数据: 处理程序处理失败; 嵌套的异常是java.lang.AbstractMethodE
我的web应用程序使用的是Spring3.1和hibernate4。在这里,我试图为eh缓存,但得到一些错误,这是我的配置,我已经使用:- dispatcher-servlet.xml ehcache.xml 这是依赖性:— 我得到以下错误:-- 严重:在org.springframework.beans.factory中上下文初始化失败。BeanCreationException:创建名为“or
问题内容: 我有一个使用Spring3和Hibernate4的Web项目,现在我想在不使用xml文件的情况下测试DAO。为此,我创建了一个类,该类使用应用程序的xml文件中包含的数据和一个简单的测试类创建一个LocalSessionFactoryBean。 但是, localSessionFactoryBean.getObject() 返回的 sessionFactory 为null。我一直在寻找
到目前为止,我在Ubuntu18.04远程服务器上使用uwsgi和nginx运行了一个Flask应用程序。这个应用程序是由我的网站监听端口5002的子域服务的。我想添加一个新的Flask应用程序来监听端口5003,但我一定是做了一些错误的配置,然后一切都失控了。现在这两个应用程序都不起作用了。 app1的服务器块 null
我正在尝试在eclipse中为java配置带有Tomcat 7的SSL。我已经配置了server.xml: 我正在做一个应用程序客户机/服务器,服务器工作正常,但当我执行客户机时,我出现以下错误: 线程"main"中的异常process_recordClientHandlerException: javjavax.net.ssl.SSLHandshakeException:sun.security