【问题标题】:Servlet-Context not found : Spring 4 Hibernate 4 Maven JSF PrimeFaces in NetBeans未找到 Servlet-Context:NetBeans 中的 Spring 4 Hibernate 4 Maven JSF PrimeFaces
【发布时间】:2015-08-21 19:12:24
【问题描述】:

开始: - 我是 J2e 的初学者,这个组合对于一个强大的应用程序来说几乎是完美的,但对于一个 J2e 入门者来说也是完美的。 - 我搜索了很多答案,但没有一个更正。

就这么简单: - 我在 Netbeans 8 和 Eclipse Mars 之间重复创建应用程序 8 次,我有所有依赖项。问题在于 Servlet-Context。 Tomcat 抛出 FileNotFound 错误,一旦我删除它:

    <listener>
   <listener-class>
           org.springframework.web.context.ContextLoaderListener
   </listener-class>
 </listener>
 <listener>
   <listener-class>
           org.springframework.web.context.request.RequestContextListener
   </listener-class>
</listener>

它可以工作,但不显示来自数据库的数据,(我的整个应用程序现在是关于在数据库上显示 id = 1 的用户 id。)

Tomcat 中的错误:

    org.apache.catalina.core.StandardContext.listenerStart Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

有人可以帮忙吗?

【问题讨论】:

    标签: java spring hibernate maven netbeans-8


    【解决方案1】:

    尝试将 contextConfigLocation 添加到您的 web.xml,以便它可以找到您的 applicationContext.xml 文件。

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    

    【讨论】:

    • 从这个 PDF 教程中得到了这种用法:nvanhuong.files.wordpress.com/2013/11/…
    • @ChaibiAlaa 好的,我明白你的意思,你可以尝试将 context-param 部分添加到 web.xml 吗?如果仍然不能解决您的问题,那么我将删除此答案
    • 不,它没有。我尝试删除两个侦听器中的一个,它在 Servelet.init() 上引发 500 错误
    • @ChaibiAlaa 我发现了这个类似的问题/答案,看起来还有另一个潜在问题可能与权限相关,请参见此处:stackoverflow.com/questions/8694734/…
    • 是的,我在发帖之前看到,所有用户(系统和我)都拥有所有文件夹文件的所有权限
    【解决方案2】:
         <listener>
       <listener-class>
               org.springframework.web.context.request.RequestContextListener
       </listener-class>
    </listener>
    

    删除它就可以了。 Spring 4 问题。

    【讨论】:

    • 奇怪,我以为你说你已经按照我原来的建议/答案尝试过这个?
    • 是的,我说我删除了两个监听器。
    • 但是我说你应该尝试删除一个或另一个,而不是两个,没关系,至少它已经解决了
    • 我在开始这个线程之前就这样做了,但由于我是一个新手,我不知道代码是否因为它本身的代码或因为该行删除而没有显示结果
    • 好的,您能否将您的答案标记为正确(单击“打勾”图标),以便将问题标记为已解决?也帮助其他有类似问题的人
    猜你喜欢
    • 2014-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 2013-11-19
    • 2012-08-22
    • 1970-01-01
    • 2015-06-10
    相关资源
    最近更新 更多