2013-01-06 56 views
1

我在使用Spring MVC 3.2.0,Eclipse Indigo中的Tomcat 7.0.27启动我的Webapp时出现问题。自从昨天以来一切正常。但现在看来,我的Web应用程序将无法正确部署。无法加载Webapp(Spring 3.2.0RC2,Tomcat 7.0.27)

... 
Jan 06, 2013 12:04:49 PM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 477 ms 
Jan 06, 2013 12:04:49 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Jan 06, 2013 12:04:49 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27 
Jan 06, 2013 12:04:50 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
Jan 06, 2013 12:04:51 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
Jan 06, 2013 12:04:51 PM org.apache.catalina.startup.HostConfig deployDirectory 
INFO: Deploying web application directory <...>.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\... 
Jan 06, 2013 12:04:52 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
Jan 06, 2013 12:04:52 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-80"] 
Jan 06, 2013 12:04:52 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
Jan 06, 2013 12:04:52 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
Jan 06, 2013 12:04:52 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 2800 ms 

只有

INFO消息:在类路径

没有检测到春天WebApplicationInitializer类型的感觉,我认为有部署Web应用程序

问题,当我打电话网址

localhost:80 80/myWebApp

我只看到目录列表

我做了什么: 我从server.xml打消了我的Web应用程序的source财产,我/WEB-INF/web.xml看起来是这样的:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 

    <!-- Processes application requests --> 
    <servlet> 
     <servlet-name>appServlet</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet>   

    <servlet-mapping> 
     <servlet-name>appServlet</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 
</web-app> 

我放在servlet定义为/WEB-INF,看起来像这样:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:jms="http://www.springframework.org/schema/jms" 
    xmlns:amq="http://activemq.apache.org/schema/core" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context-3.0.xsd 
         http://www.springframework.org/schema/jms 
         http://www.springframework.org/schema/jms/spring-jms.xsd 
         http://www.springframework.org/schema/mvc 
         http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
         http://activemq.apache.org/schema/core 
         http://activemq.apache.org/schema/core/activemq-core.xsd"> 

    <context:component-scan base-package="net.tud.vorlesung" /> 


    <mvc:annotation-driven /> 

</beans> 
+0

一个项目干净和日食/服务器/“干净...”通常可以帮助像这样的情况。 – Ralph

+0

我通过在新的工作区中从头开始解决了我的问题。清洁Eclipse和服务器不起作用。至少Spring在使用Annotationdriven MVC时在控制台中给出了有关Requestmapping的反馈;)感谢lasat – dpa

回答

1

为了解决这个问题,我将描述我是如何解决自己的问题的。

至少问题是我的项目发布到我的本地服务器,我猜并不是所有的构建类都已经部署。

随着Maven的使用,似乎有必要将Maven-lib包添加到项目部署程序集(项目>右键单击>属性>部署程序集)。

此外,如果您的控制台显示NoClassDef-Exception,则应“清除”您的Serverdeployment。这可以用Eclipse(我使用Juno)完成。只需右键单击您的服务器,然后单击“清理...”。

您的重新部署需要多长时间取决于您的项目。在我的项目中,它需要> 5分钟。

如果这不起作用,请先尝试使用“真实”JAR而不是Maven。 其实我对耶拿有问题(见Sparql Select Query works on Sesame-Workbench but not on Java

希望这会帮助很多人。

+0

我不知道它是否会帮助很多人,但它肯定会帮助我! –