如何避免 WebappClassLoader.findResources 中的 NullPointerException?
当使用管理器应用程序重新部署特定的 Web 应用程序时,下一次调用会由于 WebappClassLoader.findResources(下面的 Stacktrace)而导致“NullPointerException”。重新启动tomcat后,应用程序将顺利运行。
查遍网络,这个问题似乎很常见,但没有具体的解决方案。对我来说,这只是在部署一个特定的网络应用程序时引起的。与某些邮件列表相关,它可能是一个jar(例如axis.jar),它包含在shared/libs/中,但不应该包含在/WEB-INF/libs/中
为了构建和部署web应用程序,我使用maven,它对所有人来说都工作得很好其他应用程序,但这个。该项目的projekt配置与其他项目没有区别。
我可以做一些事情来找到tomcat“崩溃”的原因吗?!有人有解决这个问题的任何想法吗?
java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoader.findResources(WebappClassLoader.java:1245)
at java.lang.ClassLoader.getResources(ClassLoader.java:1041)
at org.apache.commons.discovery.jdk.JDK12Hooks.getResources(JDK12Hooks.java:150)
at org.apache.commons.discovery.resource.DiscoverResources$1.getNextResources(DiscoverResources.java:153)
at org.apache.commons.discovery.resource.DiscoverResources$1.getNextResource(DiscoverResources.java:129)
at org.apache.commons.discovery.resource.DiscoverResources$1.hasNext(DiscoverResources.java:116)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassNames(DiscoverNamesInFile.java:186)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassName(DiscoverNamesInFile.java:170)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.hasNext(DiscoverNamesInFile.java:157)
at org.apache.commons.discovery.resource.names.NameDiscoverers$1.getNextIterator(NameDiscoverers.java:143)
at org.apache.commons.discovery.resource.names.NameDiscoverers$1.hasNext(NameDiscoverers.java:126)
at org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.getNextResource(ResourceClassDiscoverImpl.java:159)
at org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.hasNext(ResourceClassDiscoverImpl.java:147)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:120)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
When redeploying a specific webapp by using the manager-app, the next call causes a 'NullPointerException' because of WebappClassLoader.findResources (Stacktrace below). After restarting the tomcat the app will running smooth.
Looking all over the web, the problem seems to be a very common, but without a concrete solution. For me it's only caused when deploying one specific webapp. Related to some mailinglists it could be a jar (e.g. axis.jar) which is include in shared/libs/ but not should be in /WEB-INF/libs/
For building and deploying the webapp I use maven and it works fine for all other apps, but this one. There are no differences in the projekt configuration of this project and the other ones.
May there are some things I could do to find the reason why the tomcat "crashs"?! Someone have any ideas resolving this issue?!
java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoader.findResources(WebappClassLoader.java:1245)
at java.lang.ClassLoader.getResources(ClassLoader.java:1041)
at org.apache.commons.discovery.jdk.JDK12Hooks.getResources(JDK12Hooks.java:150)
at org.apache.commons.discovery.resource.DiscoverResources$1.getNextResources(DiscoverResources.java:153)
at org.apache.commons.discovery.resource.DiscoverResources$1.getNextResource(DiscoverResources.java:129)
at org.apache.commons.discovery.resource.DiscoverResources$1.hasNext(DiscoverResources.java:116)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassNames(DiscoverNamesInFile.java:186)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.getNextClassName(DiscoverNamesInFile.java:170)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile$1.hasNext(DiscoverNamesInFile.java:157)
at org.apache.commons.discovery.resource.names.NameDiscoverers$1.getNextIterator(NameDiscoverers.java:143)
at org.apache.commons.discovery.resource.names.NameDiscoverers$1.hasNext(NameDiscoverers.java:126)
at org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.getNextResource(ResourceClassDiscoverImpl.java:159)
at org.apache.commons.discovery.resource.classes.ResourceClassDiscoverImpl$1.hasNext(ResourceClassDiscoverImpl.java:147)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder$1.run(EngineConfigurationFactoryFinder.java:120)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:113)
at org.apache.axis.configuration.EngineConfigurationFactoryFinder.newFactory(EngineConfigurationFactoryFinder.java:160)
at org.apache.axis.client.Service.getEngineConfiguration(Service.java:813)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现在 Tomcat/lib 文件夹中包含 commons-discovery.jar 时会出现此问题。
如果您将 commons-discovery.jar 用于项目特定目的,请将其放在项目的 WEB-INF/lib 文件夹中,而不是 Tomcat/lib 文件夹中,这应该可以解决您的问题。
这是部署问题,而不是Tomcat问题。
I've seen this problem occur when including commons-discovery.jar in your Tomcat/lib folder.
If you are using commons-discovery.jar for a project specific purpose, put it in the WEB-INF/lib folder of your project and not the Tomcat/lib folder, this should resolve your issue.
It's a deployment problem, not a Tomcat problem.
今天发生在我身上,是因为 WEB-INF/lib 中没有 saaj.jar。
It happened to me today and it was because of not having saaj.jar in the WEB-INF/lib.