简体   繁体   English

信息:没有在类路径上检测到Spring WebApplicationInitializer类型

[英]INFO: No Spring WebApplicationInitializer types detected on classpath

I have a spring project that runs fine on my tomcat7 server when I deploy from eclipse: Run As >> Run on server. 当我从eclipse部署时,我有一个在我的tomcat7服务器上正常运行的spring项目:Run As >> Run on server。 In the eclipse tab "Servers" I see: 在eclipse选项卡“Servers”中,我看到:

Servers
 Tomcat v7.0 Server at localhost [Started, Synchronized]
   my_project [Synchronized]
     spring-web-3.2.4-RELEASE.jar

My project: 我的项目:

  • does not use web.xml, I use javaconf @ annotations. 不使用web.xml,我使用javaconf @ annotations。
  • does not use maven, I use a User Library 不使用maven,我使用用户库

I see that the project is in: 我看到该项目在:

/srv/applications/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0

And, I also see the folders: conf,logs,temp,webapps,work,wtpwebapps 而且,我还看到了文件夹:conf,logs,temp,webapps,work,wtpwebapps

I confirm that all runs fine on my tomcat7 server when I deploy from eclipse! 我确认当我从eclipse部署时,我的tomcat7服务器上的所有运行正常!

In eclipse console I get: 在eclipse控制台中,我得到:

Apr 08, 2014 3:26:59 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:my_project' did not find a matching property.
Apr 08, 2014 3:27:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8888"]
Apr 08, 2014 3:27:00 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8843"]
Apr 08, 2014 3:27:01 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3215 ms
Apr 08, 2014 3:27:01 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 08, 2014 3:27:01 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Apr 08, 2014 3:27:11 PM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [my_project.web.context.WebApplicationInitializer@3599e94c]
Apr 08, 2014 3:27:12 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Apr 08, 2014 3:27:24 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Apr 08, 2014 3:27:24 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8888"]
Apr 08, 2014 3:27:24 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8843"]
Apr 08, 2014 3:27:24 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 23821 ms

Now: The problem It is when I deploy the same app (using a file .war) in the same tomcat7 server /var/lib/tomcat7/webapps 现在:问题当我在相同的tomcat7服务器/ var / lib / tomcat7 / webapps中部署相同的应用程序(使用文件.war)时

I can open the my initial page web BUT without data, 我可以打开我的初始页面网络但没有数据,

I see in the log: 我在日志中看到:

INFO: No Spring WebApplicationInitializer types detected on classpath

When I restart tomcat7 I get in the log file: 当我重新启动tomcat7时,我进入了日志文件:

INFO: Destroying ProtocolHandler ["http-bio-8843"]
Apr 8, 2014 3:25:30 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:my_project' did not find a matching property.
Apr 8, 2014 3:25:30 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8888"]
Apr 8, 2014 3:25:31 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8843"]
Apr 8, 2014 3:25:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1664 ms
Apr 8, 2014 3:25:31 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 8, 2014 3:25:31 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
Apr 8, 2014 3:25:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8888"]
Apr 8, 2014 3:25:38 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8843"]
Apr 8, 2014 3:25:38 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7576 ms

I found the error: I have a library that it was built using jdk 1.6. 我发现了错误:我有一个使用jdk 1.6构建的库。 The Spring main controller and components are in this library. Spring主控制器和组件位于此库中。 And how I use jdk 1.7, It does not find the classes built in 1.6. 我如何使用jdk 1.7,它没有找到1.6中构建的类。

The solution was built all using "compiler compliance level: 1.7" and "Generated .class files compatibility: 1.6", "Source compatibility: 1.6". 该解决方案全部使用“编译器合规级别:1.7”和“生成的.class文件兼容性:1.6”,“源兼容性:1.6”构建。

I setup this option in Eclipse: Preferences\\Java\\Compiler. 我在Eclipse中设置了这个选项:Preferences \\ Java \\ Compiler。

Thanks everybody. 谢谢大家。

我的愚蠢理由是: 自动构建被禁用了!

I had this info message "No Spring WebApplicationInitializer types detected on classpath" while deploying a WAR with spring integration beans in WebLogic server. 在WebLogic服务器中部署带有spring集成bean的WAR时,我收到了此消息“在类路径上检测到没有Spring WebApplicationInitializer类型”。 Actually, I could observe that the servlet URL returned 404 Not Found and beside that info message with a negative tone "No Spring ...etc" in Server logs, nothing else was seemingly in error in my spring config; 实际上,我可以观察到servlet URL返回404 Not Found并且在服务器日志中带有否定音“No Spring ... etc”的信息消息旁边,我的spring配置中似乎没有其他任何错误; no build or deployment errors, no complaints. 没有构建或部署错误,没有投诉。 Indeed, I suspected that the beans.xml (spring context XML) was actually not picked up at all and that was bound to the very specific organizing of artefacts in Oracle's jDeveloper. 实际上,我怀疑beans.xml(spring context XML)实际上根本没有被拾取,并且这与Oracle jDeveloper中非常具体的人工制品组织有关。 The solution is to play carefully with the 'contributors' and 'filters' for the WEB-INF/classes category when you edit your deployment profile under the 'deployment' topic in project properties. 在项目属性中的“部署”主题下编辑部署配置文件时,解决方案是仔细使用WEB-INF / classes类别的“贡献者”和“过滤器”。

Precisely, I would advise to name your spring context by the jDeveloper default "beans.xml" and place it side by side to the WEB-INF subdirectory itself (under your web Apllication source path, eg like <...your project path>/public_html/). 确切地说,我建议用jDeveloper默认的“beans.xml”命名你的spring上下文,并将它并排放在WEB-INF子目录本身(在你的web Apllication源路径下,例如<...你的项目路径> /的public_html /)。 Then in the WEB-INF/classes category (when editing the deployment profile) your can check the Project HTML root directory in the 'contributor' list, and then select the beans.xml in filters, and then ensure your web.xml features a context-param value like classpath:beans.xml. 然后在WEB-INF / classes类别中(编辑部署配置文件时),您可以检查“贡献者”列表中的Project HTML根目录,然后选择过滤器中的beans.xml,然后确保您的web.xml具有context-param值类似于classpath:beans.xml。

Once that was fixed, I was able to progress and after some more bean config changes and implementations, the message "No Spring WebApplicationInitializer types detected on classpath" came back! 一旦修复了,我就能够进步,在更多的bean配置更改和实现之后,消息“在类路径上检测到没有Spring WebApplicationInitializer类型”回来了! Actually, I did not notice when and why exactly it came back. 实际上,我没有注意到它何时以及为什么会回来。 This second time, I added a 第二次,我补充说

public class HttpGatewayInit implements WebApplicationInitializer { ... }

which implements empty inherited methods, and the whole application works fine! 它实现了空的继承方法,整个应用程序运行正常!

...If you feel that java EE development has been getting a bit too crazy with cascades of XML configuration files (some edited manually, others through wizards) intepreted by cascades of variant initializers, let me insist that I fully share your point. ...如果您认为Java EE开发对于XML配置文件的级联(有些是手动编辑,有些是通过向导),由级联的变体初始化程序进行了解释,让我坚持认为我完全赞同您的观点。

Make sure that your log4j is configured correctly, there's probably an exception that is being thrown, but you're only seeing half of the picture. 确保你的log4j配置正确,可能会抛出异常,但你只看到了一半的图片。

Please see https://stackoverflow.com/a/16817018/1249304 请参阅https://stackoverflow.com/a/16817018/1249304

I also had the same problem. 我也有同样的问题。 My maven had tomcat7 plugin but the JRE environment was 1.6. 我的maven有tomcat7插件,但JRE环境是1.6。 I changed my tomcat7 to tomcat6 and the error was gone. 我将tomcat7更改为tomcat6,错误消失了。

This is common error, make sure that your file.war is built correctly. 这是常见错误,请确保正确构建file.war。 Just open .war file and check that your WebApplicationInitializer is there. 只需打开.war文件并检查您的WebApplicationInitializer是否存在。

I had similar problem with Tomcat 8 embedded in java7 application. 我在java7应用程序中嵌入了Tomcat 8的类似问题。

When I launched Tomcat in my application, it worked. 当我在我的应用程序中启动Tomcat时,它工作正常。 But when I launched it through Maven for integration test purpose, I got this error : "No Spring WebApplicationInitializer types detected on classpath". 但是当我通过Maven启动它以进行集成测试时,我收到了这样的错误:“没有在类路径上检测到Spring WebApplicationInitializer类型”。

I fixed it by upgrading org.apache.tomcat.embed:tomcat-embed-* dependencies from version 8.0.29 to 8.0.47. 我通过从版本8.0.29到8.0.47升级org.apache.tomcat.embed:tomcat-embed-* embed- org.apache.tomcat.embed:tomcat-embed-* dependencies来修复它。

For eclipse users: solution is simple just change the nature of project Spring Tools->add spring project nature 对于eclipse用户:解决方案很简单只需改变项目Spring Tools的性质 - >添加spring项目的性质

done. 完成。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>          
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
 </plugin>

This is the important plugin that should be in pom.xml. 这是应该在pom.xml中的重要插件。 I spent my two days debugging and researching. 我花了两天时间调试和研究。 This was the solution. 这是解决方案。 This is Apache plugin to tell maven to use the the given Compiler. 这是Apache插件,告诉maven使用给定的编译器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 INFO:在tomcat 8的类路径上未检测到Spring WebApplicationInitializer类型 - INFO: No Spring WebApplicationInitializer types detected on classpath on tomcat 8 INFO:在类路径(jre 1.8)上未检测到Spring WebApplicationInitializer类型 - INFO: No Spring WebApplicationInitializer types detected on classpath (jre 1.8) Jboss在类路径上未检测到Spring WebApplicationInitializer类型 - Jboss No Spring WebApplicationInitializer types detected on classpath 展开战争:在类路径上未检测到Spring WebApplicationInitializer类型 - Deploying war: No Spring WebApplicationInitializer types detected on classpath Glassfish 4共享库Spring在类路径上未检测到Spring WebApplicationInitializer类型 - Glassfish 4 shared library Spring No Spring WebApplicationInitializer types detected on classpath 只有一个错误:没有在类路径上检测到Spring WebApplicationInitializer类型 - only one error: No Spring WebApplicationInitializer types detected on classpath 当我使quarkus适应一个简单的spring boot项目时,“在classpath上没有检测到Spring WebApplicationInitializer类型”? - “No Spring WebApplicationInitializer types detected on classpath” when I adapt quarkus to a simple spring boot project? 在Docker中将Java War部署到Tomcat中,错误在类路径上未检测到Spring WebApplicationInitializer类型 - Deploying Java War to Tomcat in Docker, error No Spring WebApplicationInitializer types detected on classpath Spring WebApplicationInitializer - Spring WebApplicationInitializer Springboot-&gt; Springboot 2:在类路径上检测到2个Spring WebApplicationInitializers - Springboot -> Springboot 2: 2 Spring WebApplicationInitializers detected on classpath
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM