2011-11-29 177 views
0

我使用SpringSource Tool Suite sts来启动关于MVC的hello世界示例。spring-mvc-project hello-world

File -> New -> Spring Template Project -> then choose Spring MVC Project

我补充项目名称:helloworld 并指定顶层包为com.helloworld.myapp

然后完成。

现在我尝试运行该应用程序并选择运行在服务器 ,并且它始终向我显示永久屏幕上显示:请求的资源(/helloworld/)不可用。

服务器显示以下内容:

Nov 30, 2011 4:06:53 PM com.springsource.tcserver.security.PropertyDecoder <init> INFO: tc 

Runtime property decoder using memory-based key Nov 30, 2011 4:06:53 PM com.springsource.tcserver.security.PropertyDecoder INFO: tcServer Runtime property decoder has been initialized in 183 ms Nov 30, 2011 4:06:53 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Nov 30, 2011 4:06:53 PM com.springsource.tcserver.serviceability.rmi.JmxSocketListener init INFO: Started up JMX registry on 127.0.0.1:6969 in 63 ms Nov 30, 2011 4:06:53 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 693 ms Nov 30, 2011 4:06:53 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Nov 30, 2011 4:06:53 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.6.1.RELEASE/7.0.20.B.RELEASE Nov 30, 2011 4:06:53 PM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor insight.xml from D:\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\spring-insight-instance\conf\Catalina\localhost Nov 30, 2011 4:06:53 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start INFO: Context [localhost|insight] will not be woven Nov 30, 2011 4:06:54 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext Nov 30, 2011 4:07:04 PM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet' Nov 30, 2011 4:07:06 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory manager Nov 30, 2011 4:07:06 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start INFO: Context [localhost|manager] will not be woven Nov 30, 2011 4:07:06 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory ROOT Nov 30, 2011 4:07:06 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start INFO: Context [localhost|ROOT] will not be woven Nov 30, 2011 4:07:06 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Nov 30, 2011 4:07:06 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 12820 ms Nov 30, 2011 4:07:56 PM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor EchoSpringMVC.xml from D:\springsource\vfabric-tc-server-developer-2.6.1.RELEASE\spring-insight-instance\conf\Catalina\localhost Nov 30, 2011 4:07:56 PM org.apache.catalina.startup.SetContextPropertiesRule begin WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:EchoSpringMVC' did not find a matching property. Nov 30, 2011 4:07:56 PM com.springsource.insight.collection.tcserver.ltw.TomcatWeavingInsightClassLoader start INFO: Context [localhost|EchoSpringMVC] will not be woven Nov 30, 2011 4:07:56 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.NoClassDefFoundError: org/apache/log4j/Level at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:191) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523) ... 18 more

Nov 30, 2011 4:07:56 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart Nov 30, 2011 4:07:56 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/EchoSpringMVC] startup failed due to previous errors Nov 30, 2011 4:07:56 PM org.apache.catalina.core.ApplicationContext log INFO: Closing Spring root WebApplicationContext Nov 30, 2011 4:07:56 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.ExceptionInInitializerError at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:80) at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4763) at org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5473) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be successfully initialized. See also http://www.slf4j.org/codes.html#unsuccessfulInit at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:272) at org.springframework.web.context.ContextCleanupListener.(ContextCleanupListener.java:43) ... 4 more

我在哪里去了? 请帮忙。

回答

0

它看起来像您有此异常:

https://issuetracker.springsource.com/browse/STS-2128

您的代码将运行良好。这是WTP(Web Tools Project)的缓存问题。干净的版本应该删除错误。

+0

好,非常感谢你我去到 项目 - >清洁 和那个错误不再出现, 但我再次运行应用程序 它去往这个地址里面sts http:// l ocalhost:8080/helloworld/WEB-INF/views/home.jsp 并且它也给出相同的错误 说明请求的资源(/helloworld/WEB-INF/views/home.jsp)不可用。 –

+0

也许这将是很好的提及你,服务器显示以下错误: '2011年11月30日下午4:07:56 org.apache.catalina.core.StandardContext listenerStart SEVERE:异常发送上下文初始化事件侦听器类org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError实例:组织/阿帕奇/ log4j的/水平 2011年11月30日下午4时07分56秒org.apache.catalina.core.StandardContext listenerStop SEVERE:将异常发送上下文销毁事件给类org.springframework.web.context.ContextLoaderListener的监听器实例' –

1

我已经解决了在pom.xml中改变的log4j 1.2.15与1.2.16

新的依赖这个样子的

<dependency> 
    <groupId>log4j</groupId> 
    <artifactId>log4j</artifactId> 
    <version>1.2.16</version> 
    <exclusions> 
     <exclusion> 
      <groupId>javax.mail</groupId> 
      <artifactId>mail</artifactId> 
     </exclusion> 
     <exclusion> 
      <groupId>javax.jms</groupId> 
      <artifactId>jms</artifactId> 
     </exclusion> 
     <exclusion> 
      <groupId>com.sun.jdmk</groupId> 
      <artifactId>jmxtools</artifactId> 
     </exclusion> 
     <exclusion> 
      <groupId>com.sun.jmx</groupId> 
      <artifactId>jmxri</artifactId> 
     </exclusion> 
    </exclusions> 
    <scope>runtime</scope> 
</dependency> 

这是所有

+0

我也有版本列为'1.2.15'。但是,当我将其更改为'1.2.16'并保存文件时,它会变回到'1.2.15'。 – strider