2013-05-01 31 views
12

Dự án Eclipse của tôi đột nhiên không còn triển khai đúng cách nữa. Tôi không thể theo dõi nó với bất kỳ thay đổi cụ thể nào mà tôi đã thực hiện cho môi trường.Không có loại WebApplicationInitializer Spring nào được phát hiện trên đường dẫn lớp

tôi đã thử nghiệm với nhiều dự án mã nguồn điều khiển và tất cả chúng đều hành xử theo cùng một cách:

May 01, 2013 12:00:45 PM org.apache.catalina.core.AprLifecycleListener init 
INFO: The APR based Apache Tomcat Native library which allows optimal performance in  production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jdk1.7.0_11\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\NVIDIA  Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows \System32\WindowsPowerShell\v1.0\;. 
May 01, 2013 12:00:45 PM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:fismacm' did not find a matching property. 
May 01, 2013 12:00:45 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["http-bio-8080"] 
May 01, 2013 12:00:45 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 
May 01, 2013 12:00:45 PM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 296 ms 
May 01, 2013 12:00:45 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
May 01, 2013 12:00:45 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.35 
May 01, 2013 12:00:46 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.startup.TaglibUriRule body 
INFO: TLD skipped. URI: http://www.springframework.org/security/tags is already defined 
May 01, 2013 12:00:48 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
May 01, 2013 12:00:48 PM org.apache.catalina.core.ApplicationContext log 
INFO: No Spring WebApplicationInitializer types detected on classpath 
May 01, 2013 12:00:48 PM org.apache.catalina.core.ApplicationContext log 
INFO: Set web app root system property: 'webapp.root' =  [X:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fismacm\] 
May 01, 2013 12:00:48 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing log4j from [X:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\fismacm\WEB- INF\log4j.properties] 
May 01, 2013 12:00:48 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Spring root WebApplicationContext 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
SLF4J: Defaulting to no-operation (NOP) logger implementation 
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 
May 01, 2013 12:00:49 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-8080"] 
May 01, 2013 12:00:49 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 
May 01, 2013 12:00:49 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 3898 ms 

Điều này có vẻ như thành phần quan trọng: INFO: Các loại Không mùa xuân WebApplicationInitializer phát hiện trên classpath.

Tôi đã thử làm sạch các dự án, xác định lại máy chủ và thậm chí tạo không gian làm việc hoàn toàn mới. Tôi đã bỏ lỡ dấu ấn rõ ràng.

Bất kỳ mẹo nào về việc làm sạch này sẽ được đánh giá cao.

+1

bạn thử bắt đầu ứng dụng của mình trong nhật thực? nó là một dự án maven? nếu có, phụ thuộc maven của bạn được exporte sang WEB-INF/lib? (Properties-> Deployment Assembly) –

+0

Tôi đang chạy ứng dụng từ bên trong Eclipse. Nó không phải là một dự án Maven, mặc dù sau sự thất vọng này, tôi có khuynh hướng di chuyển hướng đó. – Raevik

+0

Bạn có thể thêm một số chi tiết khác, như web.xml không? –

Trả lời

8

Điều này hóa ra là một lỗi ngu ngốc. Log4j của tôi không được định cấu hình để ghi lại kết quả lỗi của tôi. Tôi đã ném lỗi cấu hình trong nền và một khi tôi đã sửa những lỗi tôi đã thực hiện tốt và ánh xạ yêu cầu của tôi hoạt động tốt.

+20

Bạn có nhớ những gì bạn đã làm để sửa cấu hình đầu ra lỗi không? Tôi nghĩ rằng tôi đang gặp vấn đề tương tự – jlars62

+0

Mọi cập nhật một cái này? cùng một vấn đề đối với tôi. –

2

WebApplicationInitializer là một giao diện bạn có thể triển khai ở một trong các lớp học của bạn. Khi khởi động, Spring đang quét các lớp này, miễn là bạn đang sử dụng servlet spec 3 và có thuộc tính metadata-complete = "false" trong tệp tin web.xml của bạn. Nhưng đó không phải là vấn đề. Lỗi duy nhất tôi có thể tìm ra là thiếu slf4j-log4j12.jar.

12

Tôi đã mất nhiều giờ về vấn đề này, và giải pháp là:

  • Dừng Tomcat
  • "Dự án" menu -> sạch -> Làm sạch tất cả các dự án
  • Servers tab -> Tomcat - nhấp chuột> Right -> làm sạch ...
  • nhấp chuột phải vào dự án -> Run as -> Run trên máy chủ
3

INFO: Không có mùa xuân WebApplicati Các kiểu onInitializer được phát hiện trên classpath.

Cũng có thể hiển thị nếu bạn đang sử dụng Maven với Eclipse và triển khai WAR của bạn bằng cách sử dụng;

(Eclipse, Kepler, với M2)

(nhấp chuột phải vào dự án của bạn) -> Run As -> Run on Server

Đó là xuống cho thế hệ và xóa các M2E -wtp thư mục và nội dung.

Đảm bảo, Lưu trữ Maven tệp được tạo trong thư mục xây dựng được chọn.

Under: "Window -> Preferences -> Maven -> Java EE Integration"

Sau đó:

Sử dụng M2, để làm xây dựng của bạn, tức là sạch thông thường -> gói hoặc cài đặt vv .. .

Nếu "Dự án -> Tự động xây dựng" không được chọn. Bạn có thể buộc tạo "thư mục m2e-wtp và nội dung" bằng cách thực hiện;

"(nhấp chuột phải vào dự án của bạn) -> Maven -> Cập nhật dự án ..."

Lưu ý: chắc chắn rằng "Dự án sạch" tùy chọn là un-chọn. Nếu không, nội dung của mục tiêu/lớp sẽ bị xóa và bạn quay lại hình vuông.

Ngoài ra, khi nào;

"Project -> Build Tự động" được chọn là "thư mục M2E-WTP và nội dung" được tạo ra

hoặc "Project -> Build Tất cả"

hoặc "(nhấp chuột phải vào dự án) -> Xây dựng Dự án "

5

Xem bạn có đang sử dụng Maven không. Cấu trúc thư mục của bạn phải là đúng.

Khi sử dụng Maven, thư mục WEB-INF phải bên webapp:

src/main/webapp/WEB-INF 
1

Tôi cũng có cùng một vấn đề. Maven của tôi có plugin tomcat7 nhưng môi trường JRE là 1.6. Tôi đã thay đổi tomcat7 thành tomcat6 và lỗi đã biến mất.

0

xml không nằm trong thư mục WEB-INF, đó là lý do tại sao tôi gặp phải lỗi này, đảm bảo rằng web.xml và xxx-servlet.xml nằm trong thư mục WEB_INF chứ không phải trong thư mục webapp.

+0

Tôi đã sửa đổi triển khai lắp ráp để bao gồm thư mục webapp trong hội đồng triển khai. Cảm ơn, – Satya

+0

Không: toàn bộ điểm [WebApplicationInitializer] (http://www.rockhoppertech.com/blog/spring-mvc-configuration-without-xml/) là để bạn * không * cần web.xml. Thêm web.xml không giải quyết được vấn đề (lỗi thời Java 1.5 lọ), nó chỉ che dấu các triệu chứng: ( – paulsm4

0

tôi nhận được một lỗi ngớ ngẩn nó đã cho tôi một xấu hổ dài để giải quyết .... Kiểm tra pom.xml của tôi ...

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>com.outbottle</groupId> 
<artifactId>PersonalDetailsMVC</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>war</packaging> 

<name>PersonalDetailsMVC</name> 

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <spring.version>4.0.1.RELEASE</spring.version> 
    <jstl.version>1.2</jstl.version> 
    <javax.servlet.version>3.0.1</javax.servlet.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>7.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>${javax.servlet.version}</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>jstl</groupId> 
     <artifactId>jstl</artifactId> 
     <version>${jstl.version}</version> 
    </dependency> 

</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.1</version> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.3</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>7.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

Vấn đề là tên gói của tôi. Nó phải là "com.outbottle" (sau đó config/controllers/model/etc) để nó hoạt động. Như bạn có thể thấy ở trên, tôi đã sử dụng Maven (lần đầu tiên), Spring, 1.8 JDK và gần như đã có một đột quỵ gỡ lỗi vấn đề này. Tất cả chạy trên Glassfish (Tomcat là ok quá cho cấu hình pom trên). Điều đó nói rằng, tôi tất cả đều hạnh phúc với bản thân mình bây giờ và biết Maven và Spring tốt hơn cho bước tiếp theo của đường cong học tập mùa xuân của tôi. Hy vọng điều này sẽ giúp bạn!

+0

Nếu bạn có câu hỏi mới, hãy hỏi nó bằng cách nhấp vào nút [Hỏi câu hỏi] (https://stackoverflow.com/questions/ask). nếu nó giúp cung cấp ngữ cảnh - [Từ đánh giá] (/ đánh giá/chất lượng thấp-bài viết/16787111) –

Các vấn đề liên quan