当我尝试在Tomcat上运行我的项目时,我得到了以下异常。我正在使用基于Java的WebInitializer和SpringConfiguration。
18:10:34.039 [localhost-startStop-1] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started
18:10:34.116 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Adding [servletConfigInitParams] PropertySource with lowest search precedence
18:10:34.116 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Adding [servletContextInitParams] PropertySource with lowest search precedence
18:10:34.122 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Adding [jndiProperties] PropertySource with lowest search precedence
18:10:34.122 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
18:10:34.123 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
18:10:34.123 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Initialized StandardServletEnvironment with PropertySources [servletConfigInitParams,servletContextInitParams,jndiProperties,systemProperties,systemEnvironment]
18:10:34.127 [localhost-startStop-1] DEBUG o.s.w.c.s.StandardServletEnvironment - Replacing [servletContextInitParams] PropertySource with [servletContextInitParams]
18:10:34.128 [localhost-startStop-1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Jun 05 18:10:34 IST 2017]; root of context hierarchy
18:10:34.204 [localhost-startStop-1] DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
18:10:34.206 [localhost-startStop-1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class x.x.x.x.x.SpringConfiguration]
18:10:34.223 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:715) ~[na:1.7.0_80]
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:522) ~[na:1.7.0_80]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:348) ~[na:1.7.0_80]
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:283) ~[na:1.7.0_80]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:117) ~[na:1.7.0_80]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70) ~[na:1.7.0_80]
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3281) ~[na:1.7.0_80]
at java.lang.Class.getAnnotations(Class.java:3250) ~[na:1.7.0_80]
at org.springframework.core.type.StandardAnnotationMetadata.<init>(StandardAnnotationMetadata.java:68) ~[spring-core-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.<init>(AnnotatedGenericBeanDefinition.java:56) ~[spring-beans-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:139) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:127) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:122) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210) ~[spring-web-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513) ~[spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) ~[spring-web-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) ~[spring-web-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4725) [catalina.jar:8.5.8]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189) [catalina.jar:8.5.8]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.8]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1404) [catalina.jar:8.5.8]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1394) [catalina.jar:8.5.8]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
Jun 05, 2017 6:10:34 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:715)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:522)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:348)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:283)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:117)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:70)
at java.lang.Class.initAnnotationsIfNecessary(Class.java:3281)
at java.lang.Class.getAnnotations(Class.java:3250)
at org.springframework.core.type.StandardAnnotationMetadata.<init>(StandardAnnotationMetadata.java:68)
at org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.<init>(AnnotatedGenericBeanDefinition.java:56)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:139)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:127)
at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:122)
at org.springframework.web.context.support.AnnotationConfigWebApplicationContext.loadBeanDefinitions(AnnotationConfigWebApplicationContext.java:210)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4725)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1404)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1394)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Jun 05, 2017 6:10:34 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Jun 05, 2017 6:10:34 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/x-x-x-x-x] startup failed due to previous errors
Jun 05, 2017 6:10:34 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
18:10:34.230 [localhost-startStop-1] INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Closing Root WebApplicationContext: startup date [Mon Jun 05 18:10:34 IST 2017]; root of context hierarchy
18:10:34.235 [localhost-startStop-1] WARN o.s.w.c.s.AnnotationConfigWebApplicationContext - 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 [Mon Jun 05 18:10:34 IST 2017]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:416) [spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:997) [spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:956) [spring-context-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:581) [spring-web-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116) [spring-web-4.3.0.RELEASE.jar:4.3.0.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4772) [catalina.jar:8.5.8]
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5411) [catalina.jar:8.5.8]
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226) [catalina.jar:8.5.8]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) [catalina.jar:8.5.8]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1404) [catalina.jar:8.5.8]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1394) [catalina.jar:8.5.8]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]
Jun 05, 2017 6:10:34 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1028)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1004)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:956)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:581)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4772)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5411)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1404)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1394)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我的Webinitializer代码和SpringConfiguration代码是
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { SpringConfiguration.class };
}
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { SpringConfiguration.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}
@Configuration
@ComponentScan(basePackages = "x.x.x.x")
@EnableWebMvc
@Import(
{ HibernateMainConfiguration.class })
public class SpringConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
}
答案 0 :(得分:0)
我遇到了类似的问题,其中描述了there。我的观点是,在Eclipse中是一个与正确部署绑定的错误。