当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Spring Web MVC: Context initialization failed -- Component Scan fails

问题描述:

I have a Problem at starting my Spring Web MVC Application on Tomcat8. At startup I get the following Error at loading the context:

2015-10-14 20:31:38 INFO ClassPathBeanDefinitionScanner:222 - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning

2015-10-14 20:31:39 ERROR ContextLoader:307 - Context initialization failed

java.lang.IllegalArgumentException

at org.springframework.asm.ClassReader.<init>(Unknown Source)

at org.springframework.asm.ClassReader.<init>(Unknown Source)

at org.springframework.asm.ClassReader.<init>(Unknown Source)

at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52)

at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)

at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101)

at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76)

at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298)

at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)

at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300)

at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:230)

at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:153)

at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:130)

at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:285)

at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223)

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5221)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1587)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1471)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1312)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1404)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:832)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$79(TCPTransport.java:683)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

14-Oct-2015 20:31:39.186 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart

14-Oct-2015 20:31:39.198 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors

2015-10-14 20:31:39 INFO XmlWebApplicationContext:1042 - Closing Root WebApplicationContext: startup date [Wed Oct 14 20:31:38 CEST 2015]; root of context hierarchy

2015-10-14 20:31:39 WARN XmlWebApplicationContext:1052 - Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Wed Oct 14 20:31:38 CEST 2015]; root of context hierarchy

at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)

at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)

at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)

at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:549)

at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)

at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4838)

at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5438)

at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1587)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1471)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1312)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1404)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:832)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$79(TCPTransport.java:683)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

2015-10-14 20:31:39 WARN XmlWebApplicationContext:1060 - Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Wed Oct 14 20:31:38 CEST 2015]; root of context hierarchy

at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)

at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)

at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)

at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:549)

at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)

at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4838)

at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5438)

at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)

at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1587)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)

at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)

at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)

at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)

at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1471)

at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)

at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1312)

at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1404)

at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:832)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)

at sun.rmi.transport.Transport$1.run(Transport.java:200)

at sun.rmi.transport.Transport$1.run(Transport.java:197)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.Transport.serviceCall(Transport.java:196)

at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$79(TCPTransport.java:683)

at java.security.AccessController.doPrivileged(Native Method)

at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

So far I've figured out that there has to be a problem with the component-scan in my MVC config. When the component-scan is commented out, the server starts without error (but the application needs it...).

Here's my MVC config:

<beans xmlns="http://www.springframework.org/schema/beans"

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

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

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

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

xmlns:solr="http://www.springframework.org/schema/data/solr"

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

xsi:schemaLocation="

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

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

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

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

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

http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

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

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

http://www.springframework.org/schema/data/solr

http://www.springframework.org/schema/data/solr/spring-solr-1.0.xsd">

<context:component-scan base-package="at.dbhklu"/>

<mvc:annotation-driven/>

<mvc:resources mapping="/resources/**" location="/resources"/>

<!-- MySQL DataSource -->

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

<property name="driverClass" value="com.mysql.jdbc.Driver"/>

<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/dbh"/>

<property name="user" value="myuser"/>

<property name="password" value="MYPASS"/>

</bean>

<!-- Hibernate SessionFactory -->

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

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

<property name="hibernateProperties">

<value>

hibernate.hbm2ddl.auto=validate

hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

hibernate.c3p0.min_size=5

hibernate.c3p0.max_size=20

hibernate.c3p0.max_statements=50

hibernate.c3p0.idle_test_period=300

hibernate.c3p0.timeout=120

<!--When timeouts does not work, try this-->

<!--http://itellity.wordpress.com/2013/07/18/mysql-reconnect-issues-or-the-last-packet-successfully-received-from-the-server-xx-milliseconds-ago-errors/-->

</value>

</property>

<property name="packagesToScan" value="at.dbhklu.entity"/>

</bean>

<!-- Transaction Management -->

<tx:annotation-driven transaction-manager="txManager"/>

<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">

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

</bean>

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>

<bean id="viewResolver"

class="org.springframework.web.servlet.view.UrlBasedViewResolver">

<property name="viewClass">

<value>

org.springframework.web.servlet.view.tiles2.TilesView

</value>

</property>

<property name="order" value="0"/>

</bean>

<bean id="tilesConfigurer"

class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">

<property name="definitions">

<list>

<value>/WEB-INF/tiles.xml</value>

</list>

</property>

</bean>

<bean id="multipartResolver"

class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

<property name="maxUploadSize" value="10000000"/>

</bean>

<!--Solr Server-->

<solr:solr-server id="solrServer" url="http://localhost:8090/solr-4.6.0/person"/>

<!-- Configures Solr template -->

<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">

<constructor-arg index="0" ref="solrServer"/>

</bean>

<bean class="org.springframework.web.servlet.view.XmlViewResolver">

<property name="location">

<value>/WEB-INF/xml-view.xml</value>

</property>

<property name="order" value="1" />

</bean>

</beans>

My MVN dependencies look like follows:

<properties>

<spring.version>3.2.0.RELEASE</spring.version>

<hibernate.version>4.1.0.Final</hibernate.version>

</properties>

<dependencies>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-core</artifactId>

<version>${spring.version}</version>

<exclusions>

<exclusion>

<groupId>commons-logging</groupId>

<artifactId>commons-logging</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-web</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>servlet-api</artifactId>

<version>2.5</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>javax.servlet.jsp</groupId>

<artifactId>jsp-api</artifactId>

<version>2.1</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-webmvc</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-test</artifactId>

<version>${spring.version}</version>

<scope>test</scope>

</dependency>

<!--DEPENDENCYS FOR HIBERNATE-->

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-orm</artifactId>

<version>${spring.version}</version>

</dependency>

<dependency>

<groupId>org.hibernate</groupId>

<artifactId>hibernate-core</artifactId>

<version>${hibernate.version}</version>

</dependency>

<dependency>

<groupId>org.hibernate</groupId>

<artifactId>hibernate-c3p0</artifactId>

<version>${hibernate.version}</version>

</dependency>

<!--DEPENDENCY FOR BEANVALIDATION-->

<dependency>

<groupId>org.hibernate</groupId>

<artifactId>hibernate-validator</artifactId>

<version>${hibernate.version}</version>

<exclusions>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-api</artifactId>

</exclusion>

</exclusions>

</dependency>

<!--DRIVER FOR MYSQL-->

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>5.1.18</version>

</dependency>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.8.2</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>jstl</groupId>

<artifactId>jstl</artifactId>

<version>1.2</version>

</dependency>

<dependency>

<groupId>org.apache.tiles</groupId>

<artifactId>tiles-extras</artifactId>

<version>2.2.2</version>

<exclusions>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>jcl-over-slf4j</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>cglib</groupId>

<artifactId>cglib</artifactId>

<version>2.2.2</version>

</dependency>

<!--REQUIRED FOR FILEUPLOAD-->

<dependency>

<groupId>commons-fileupload</groupId>

<artifactId>commons-fileupload</artifactId>

<version>1.2.1</version>

</dependency>

<dependency>

<groupId>commons-io</groupId>

<artifactId>commons-io</artifactId>

<version>1.3</version>

</dependency>

<!--LIB FOR JSON CONVERTING-->

<dependency>

<groupId>org.codehaus.jackson</groupId>

<artifactId>jackson-mapper-asl</artifactId>

<version>1.9.12</version>

</dependency>

<!-- Solr -->

<dependency>

<groupId>org.springframework.data</groupId>

<artifactId>spring-data-solr</artifactId>

<version>1.0.0.RELEASE</version>

<exclusions>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>jcl-over-slf4j</artifactId>

</exclusion>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-api</artifactId>

</exclusion>

</exclusions>

</dependency>

<dependency>

<groupId>org.apache.solr</groupId>

<artifactId>solr-core</artifactId>

<version>4.4.0</version>

<exclusions>

<exclusion>

<artifactId>slf4j-jdk14</artifactId>

<groupId>org.slf4j</groupId>

</exclusion>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-api</artifactId>

</exclusion>

<exclusion>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-log4j12</artifactId>

</exclusion>

<exclusion>

<groupId>log4j</groupId>

<artifactId>log4j</artifactId>

</exclusion>

</exclusions>

</dependency>

<!--Logging-->

<dependency>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-log4j12</artifactId>

<version>1.7.7</version>

</dependency>

<dependency>

<groupId>org.slf4j</groupId>

<artifactId>jcl-over-slf4j</artifactId>

<version>1.7.7</version>

</dependency>

</dependencies>

Does anyone know what the problem could be?

My spring version is 3.2.0.RELEASE, Hibernate Version is: 4.1.0.Final.

网友答案:

Are you forced to use Spring framework? Perhaps you may want to Try SpringBoot. It is a micro-framework based on Spring, but since it is an opinionated framework it is very easy to setup. For instance, it does not use xml config files. If you are using Maven you just need to create a new Maven project and add Springboot to your pom file:

http://projects.spring.io/spring-boot/

网友答案:

I found the error... and I'm ashamed that I didn't found it out before I was writing the question. I checked the production server and saw that the Tomcat runs on Java 7. So when I start my local Tomcat with Java 7 it works.

Thanks for your help!

网友答案:

How are you setting the versions for spring and hibernate in your pom.xml file? All other dependencies have versions set explicitly.

I'm missing something like:

<properties>    
    <hibernate.version>4.1.0.RELEASE</hibernate.version>
    <spring.version>3.2.0.Final</spring.version>
</properties>

If you're using eclipse, look in the "folder" Maven Dependencies that those libraries actually are added to your project, I have seen sometimes that if the versions are missing, none is added

分享给朋友:
您可能感兴趣的文章:
随机阅读: