严重: Context [/spring] startup failed due to previous errors
四月 08, 2015 12:07:29 下午 org.apache.catalina.deploy.NamingResources cleanUp
警告: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/spring]] so no cleanup was performed for that container
javax.naming.NameNotFoundException: Name [comp/env] is not bound in this Context. Unable to find [comp].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.catalina.deploy.NamingResources.cleanUp(NamingResources.java:986)
at org.apache.catalina.deploy.NamingResources.stopInternal(NamingResources.java:968)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5704)
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:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1859)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>struts</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
struts.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.objextFactory" value="spring"/>
<package name="login" extends="struts-default">
<action name="login" class="loginAction">
<result>/page/success.jsp</result>
<result name="fail">/page/fail.jsp</result>
</action>
</package>
</struts>
applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!--
- Root application context for the Countries application.
- Web-specific beans are defined in "countries-servlet.xml".
-->
<beans>
<!--
- The message source for this context, loaded from localized "messages_xx" files
- in the classpath, i.e. "/WEB-INF/classes/messages.properties" or
- "/WEB-INF/classes/messages_fr.properties".
-
- "getMessage" calls to this context will use this source.
- Child contexts can have their own message sources, inheriting all messages from this
- source, being able to define new messages and override ones defined in this source.
-
- We have no need for application messages in this tiny application, so this
- definition will simply be used by the next level (countries-servlet.xml).
-->
<bean id="hellospring" class="com.pb.HelloSpring">
<property name="str" value="spring"/>
</bean>
<bean id="color" class="com.pb.ColorInk"></bean>
<bean id="grey" class="com.pb.GreyInk"></bean>
<bean id="loginAction" class="com.pb.LoginAction"></bean>
</beans>
刚刚学三大框架整合,不知道是哪里出问题了。单独搭建struts2框架没什么问题,感觉我搭建的spring都不能启动tomcat,一启动控制塔就报这个错误,麻烦各位帮帮忙,困扰我好久了,谢谢
------解决思路----------------------
“严重:”
之前的部分就有错误了。没贴出了呢
------解决思路----------------------
<constant name="struts.objextFactory" value="spring"/>
改成
<constant name="struts.objectFactory" value="spring"/>
------解决思路----------------------
你web.xml中struts2的核心控制器用<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
建议先加入好spring在加stuts2,还有jar包别弄错了,搭建应该很容易的