在Tomcat上部署WAR

时间:2015-01-07 15:17:06

标签: java eclipse tomcat deployment

我正在使用appfuse项目构建器开发一些java Web应用程序,我使用struts 2.0框架。我通过Eclipse maven运行它没有问题:tomcat运行。但是当我生成war文件并尝试在tomcat服务器上部署它时(我已经尝试过tomcat 7.0.54,7.0.57,8)它也会出现这个错误,我认为这是我的限制,我不得不问一个问题。我想我已经尝试了一切。 这是我在tomcat上启动时获得的以下错误。

Dec 20, 2014 1:36:20 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class gnv.carnaval.webapp.listener.StartupListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Cannot resolve reference to bean 'userManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void gnv.carnaval.service.impl.UserManagerImpl.setUserDao(gnv.carnaval.dao.UserDao); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [F:\TOMCAT\apache-tomcat-7.0.54\webapps\Carnaval\WEB-INF\classes\gnv\carnaval\dao\hibernate\UserDaoHibernate.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gnv.carnaval.dao.hibernate.UserDaoHibernate]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer$TokenStreamComponents
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:336)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:632)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:140)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    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)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void gnv.carnaval.service.impl.UserManagerImpl.setUserDao(gnv.carnaval.dao.UserDao); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [F:\TOMCAT\apache-tomcat-7.0.54\webapps\Carnaval\WEB-INF\classes\gnv\carnaval\dao\hibernate\UserDaoHibernate.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gnv.carnaval.dao.hibernate.UserDaoHibernate]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer$TokenStreamComponents
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void gnv.carnaval.service.impl.UserManagerImpl.setUserDao(gnv.carnaval.dao.UserDao); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [F:\TOMCAT\apache-tomcat-7.0.54\webapps\Carnaval\WEB-INF\classes\gnv\carnaval\dao\hibernate\UserDaoHibernate.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gnv.carnaval.dao.hibernate.UserDaoHibernate]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer$TokenStreamComponents
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
    ... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [F:\TOMCAT\apache-tomcat-7.0.54\webapps\Carnaval\WEB-INF\classes\gnv\carnaval\dao\hibernate\UserDaoHibernate.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gnv.carnaval.dao.hibernate.UserDaoHibernate]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer$TokenStreamComponents
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1076)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1021)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:960)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:553)
    ... 40 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [gnv.carnaval.dao.hibernate.UserDaoHibernate]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer$TokenStreamComponents
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1069)
    ... 51 more
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer$TokenStreamComponents
    at gnv.carnaval.dao.hibernate.GenericDaoHibernate.<init>(GenericDaoHibernate.java:73)
    at gnv.carnaval.dao.hibernate.UserDaoHibernate.<init>(UserDaoHibernate.java:43)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
    ... 53 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer$TokenStreamComponents
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    ... 60 more

Dec 20, 2014 1:36:20 AM org.apache.catalina.core.ApplicationContext log
INFO: Log4jServletContextListener ensuring that Log4j starts up properly.
Dec 20, 2014 1:36:20 AM org.apache.catalina.core.ApplicationContext log
INFO: Log4jServletContextListener ensuring that Log4j shuts down properly.
Dec 20, 2014 1:36:20 AM org.apache.catalina.core.ApplicationContext log
INFO: Removing LoggerContext for [appfuse].
Dec 20, 2014 1:36:20 AM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Dec 20, 2014 1:36:20 AM org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
Dec 20, 2014 1:36:21 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Dec 20, 2014 1:36:21 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Dec 20, 2014 1:36:21 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@273dafe1')

这是我的 pom.xml 文件

.........    
<plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                    <configuration>
                        <escapeString>\</escapeString>
                        <webResources>
                            <resource>
                                <directory>src/main/resources/packaged</directory>
                                <targetPath>WEB-INF/classes</targetPath>
                                <filtering>true</filtering>
                                <includes>
                                    <include>hibernate.properties</include>
                                </includes>
                            </resource>
                        </webResources>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            </manifest>
                            <manifestEntries>
                                <Implementation-Version>${project.version}</Implementation-Version>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
......

如果有人和我有同样的问题请分享,这对我来说就像是一个奇迹。

谢谢和问候。

1 个答案:

答案 0 :(得分:0)

由于jasper,实际上hibernate已经包含在org.apache.lucene中,所以在jasperreports中你应该排除它。上面的这一步是在 pom.xml

这是我对jasperreport排除的配置

<dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.0.0</version>
                <exclusions>
                    <exclusion>
                        <artifactId>*</artifactId>
                        <groupId>org.apache.lucene</groupId>
                    </exclusion>
                </exclusions>
        </dependency>

感谢大家的帮助和评论,问候:)